bool CClientCommands::HandleUserInput(std::string strCommand, std::string strParameters) { if(strCommand == "q" || strCommand == "quit") { // Are we connected to the network? if(g_pCore->GetNetworkManager()->IsConnected()) { // Disconnect and shutdown RakNet g_pCore->GetNetworkManager()->Shutdown(500, true); } TerminateProcess(GetCurrentProcess(), 0); return true; } else if(strCommand == "qq" || strCommand == "quickquit") { TerminateProcess(GetCurrentProcess(), 0); return true; } else if(strCommand == "cv") { int iVehicleType = atoi(strParameters.c_str()); CVector3 vecCreatePos; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecCreatePos); vecCreatePos.fX += 4; vecCreatePos.fY += 1; CVehicleEntity * pVehicle = new CVehicleEntity(iVehicleType,vecCreatePos,0.0f,0,0,0,0); if(pVehicle) { // Add our vehicle g_pCore->GetGame()->GetVehicleManager()->Add(pVehicle); pVehicle->SetId(g_pCore->GetGame()->GetVehicleManager()->FindFreeSlot()); pVehicle->Create(); pVehicle->SetPosition(vecCreatePos); } return true; } else if(strCommand == "respawn") { g_pCore->GetGame()->GetLocalPlayer()->Respawn(); return true; } else if(strCommand == "debug") { g_pCore->GetDevelopmentInstance()->CreateDebugPlayer(); return true; } else if(strCommand == "weapon") { if(g_pCore->GetDevelopmentInstance()->GetDebugPlayerPed()) CIVScript::GiveWeaponToChar(g_pCore->GetDevelopmentInstance()->GetDebugPlayerPed()->GetScriptingHandle(),(CIVScript::eWeapon)CIVScript::WEAPON_SHOTGUN,50,true); CIVScript::GiveWeaponToChar(g_pCore->GetGame()->GetLocalPlayer()->GetScriptingHandle(),(CIVScript::eWeapon)CIVScript::WEAPON_SHOTGUN,50,true); return true; } else if(strCommand == "cp") { CVector3 vecCreatePos; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecCreatePos); CPlayerEntity * pPlayer = new CPlayerEntity(false); if(pPlayer) { pPlayer->SetModel(7); pPlayer->Create(); pPlayer->Teleport(vecCreatePos); } return true; } else if(strCommand == "spawn") { g_pCore->GetChat()->Output("Spawning local player ...",false); g_pCore->GetGame()->OnClientReadyToGamePlay(); g_pCore->GetGame()->GetLocalPlayer()->SetModel(7); int iVehicleType = g_pCore->GetGame()->IsUsingEFLCContent() ? 128 : 91; CVector3 vecCreatePos; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecCreatePos); vecCreatePos.fX += 4; vecCreatePos.fY += 1; CVehicleEntity * pVehicle = new CVehicleEntity(iVehicleType,vecCreatePos,0.0f,0,0,0,0); if(pVehicle) { // Add our vehicle g_pCore->GetGame()->GetVehicleManager()->Add(pVehicle); pVehicle->SetId(g_pCore->GetGame()->GetVehicleManager()->FindFreeSlot()); pVehicle->Create(); pVehicle->SetPosition(vecCreatePos); } PTR_CHAT->Output("Type \"/ready\" and seconds later \"/parachute\" to create a parachute!",false); return true; } else if(strCommand == "engine") { if(g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity() != NULL) g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity()->SetEngineState(!g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity()->GetEngineState()); return true; } else if(strCommand == "saveposition" || strCommand == "save") { FILE * file = fopen(SharedUtility::GetAbsolutePath("multiplayer//SavePositions.log"), "a"); if(!file) { g_pCore->GetChat()->Output("Failed to open 'SavedData.log'"); return true; } CVector3 vecPosition; // Get our local player CLocalPlayer * pLocalPlayer = g_pCore->GetGame()->GetLocalPlayer(); if(pLocalPlayer->IsInVehicle()) { CVehicleEntity * pVehicle = pLocalPlayer->GetVehicleEntity(); if(pVehicle) { pVehicle->GetPosition(vecPosition); CVector3 vecRotation; pVehicle->GetRotation(vecRotation); BYTE byteColors[4]; pVehicle->GetColors(byteColors[0], byteColors[1], byteColors[2], byteColors[3]); fprintf_s(file, "createVehicle(%d, %f, %f, %f, %f, %f, %f, %d, %d, %d, %d);%s%s\n", CIVModelManager::ModelHashToVehicleId(pVehicle->GetModelInfo()->GetHash()), vecPosition.fX, vecPosition.fY, vecPosition.fZ, vecRotation.fX, vecRotation.fY, vecRotation.fZ, byteColors[0], byteColors[1], byteColors[2], byteColors[3], strParameters.size() > 0 ? " // " : "", strParameters.size() > 0 ? strParameters.c_str() : ""); } } else { pLocalPlayer->GetPosition(vecPosition); int iModelId = pLocalPlayer->GetPlayerPed()->GetModelIndex(); fprintf_s(file, "PlayerData(%d, %f, %f, %f, %f);%s%s\n", iModelId, vecPosition.fX, vecPosition.fY, vecPosition.fZ, pLocalPlayer->GetRotation() ,strParameters.size() > 0 ? " // " : "", strParameters.size() > 0 ? strParameters.c_str() : ""); } fclose(file); g_pCore->GetChat()->Output("Position data saved to 'SavePositions.log'"); return true; } else if(strCommand == "giveweapon") { int iWeapon = atoi(strParameters.c_str()); CIVScript::GiveWeaponToChar(g_pCore->GetGame()->GetLocalPlayer()->GetScriptingHandle(),(CIVScript::eWeapon)iWeapon, 100, true); return true; } else if(strCommand == "xaxis") { CVector3 vecPositon; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPositon); vecPositon.fX += atoi(strParameters.c_str()); g_pCore->GetGame()->GetLocalPlayer()->SetPosition(vecPositon); return true; } else if(strCommand == "time") { CIVWeather::SetTime(atoi(strParameters.c_str()),0); return true; } else if(strCommand == "setmodel") { g_pCore->GetGame()->GetLocalPlayer()->SetModel(atoi(strParameters.c_str())); return true; } else if(strCommand == "testweapon") { CIVScript::GiveWeaponToChar(g_pCore->GetGame()->GetLocalPlayer()->GetScriptingHandle(),CIVScript::WEAPON_EPISODIC_11,99,false); return true; } else if(strCommand == "ready") { PTR_CHAT->Output("Installing prachute..."); CEFLCSupport::InstallPreGameLoad(); return true; } else if(strCommand == "parachute") { PTR_CHAT->Output("Adding prachute..."); CVector3 vecPosition; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPosition); unsigned int uiPlayerIndex = g_pCore->GetGame()->GetLocalPlayer()->GetScriptingHandle(); DWORD dwParachute = 0x58D6A0A0; //CIVScript::GiveWeaponToChar(uiPlayerIndex, 41, 1, false); //CIVScript::CreateObject(dwParachute, vecPosition.fX, vecPosition.fY, vecPosition.fZ + 2, &pObj, 1); //CIVScript::AttachObjectToPed(pObj, uiPlayerIndex, 0, 0.02500000, -0.12500000, 5.45000000, 0.00000000, 0.00000000, 0.00000000, 1); if(pObj != NULL) CIVScript::DeleteObject(&pObj); dwParachute = 0x4C19FE43; //0x402B7648; CIVScript::CreateObject(dwParachute, vecPosition.fX, vecPosition.fY, -25.0 , &pObj, 1); l_U40 = pObj; CIVScript::SetObjectDynamic(pObj, 0); CIVScript::SetObjectCollision(pObj, 0); CIVScript::SetObjectVisible(pObj, 0); CIVScript::SetActivateObjectPhysicsAsSoonAsItIsUnfrozen(pObj, 1); CIVScript::SetObjectDynamic( pObj, 1 ); CIVScript::SetObjectCollision( pObj, 1 ); CIVScript::SetObjectVisible( pObj, 1 ); CIVScript::AttachObjectToPed( pObj, uiPlayerIndex, 1202, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1 ); CIVScript::PlayObjectAnim( pObj, "obj_chute_off", "PARACHUTE", 1000.00000000, 0, 1 ); CIVScript::TaskPlayAnimWithFlags( uiPlayerIndex, "chute_off", "PARACHUTE", 3.00000000, 0, 1280 ); return true; } else if(strCommand == "bahama") { CVector3 vecPos = CVector3(-15.9453f, -13.5865f, -11.7456f); g_pCore->GetGame()->GetLocalPlayer()->CPlayerEntity::Teleport(vecPos); return true; } else if(strCommand == "spawnvehicles") { CVector3 vecPos; PTR_LOCALPLAYER->GetPosition(vecPos); for(int i = 0; i < 179; i++) { vecPos.fX += 5; CVehicleEntity * pVehicle = new CVehicleEntity(i,vecPos,0.0f,0,0,0,0); if(pVehicle) { // Add our vehicle g_pCore->GetGame()->GetVehicleManager()->Add(pVehicle); pVehicle->SetId(g_pCore->GetGame()->GetVehicleManager()->FindFreeSlot()); pVehicle->Create(); pVehicle->SetPosition(vecPos); } } return true; } else if(strCommand == "getvehpos") { int iVehicle = atoi(strParameters.c_str()); if(g_pCore->GetGame()->GetVehicleManager()->DoesExists(iVehicle)) { CVector3 vecPosition; g_pCore->GetGame()->GetVehicleManager()->GetAt(iVehicle)->GetPosition(vecPosition); PTR_CHAT->Outputf(false,"Position of vehicle %d: %f, %f,%f",iVehicle, vecPosition.fX, vecPosition.fY, vecPosition.fZ); } } else if(strCommand == "ivhelp") { PTR_CHAT->Output(false, "List of Default IV:MP Commands..."); PTR_CHAT->Output(false, "** /cv /respawn /debug /weapon /cp /spawn /engine /save /giveweapon /xaxis /time"); PTR_CHAT->Output(false, "** /setmodel /testweapon /ready /parachute /bahama /spawnvehicles /getvehpos"); return true; } }
bool CClientCommands::HandleUserInput(CString strCommand, CString strParameters) { if(strCommand == "q" || strCommand == "quit") { // Are we connected to the network? if(g_pCore->GetNetworkManager()->IsConnected()) { // Disconnect and shutdown RakNet g_pCore->GetNetworkManager()->Shutdown(500, true); } TerminateProcess(GetCurrentProcess(), 0); return true; } else if(strCommand == "qq" || strCommand == "quickquit") { TerminateProcess(GetCurrentProcess(), 0); return true; } else if (strCommand == "saveposition" || strCommand == "save") { FILE * file = fopen(SharedUtility::GetAbsolutePath("multiplayer//SavePositions.log"), "a"); if (!file) { g_pCore->GetChat()->Print("Failed to open 'SavePositions.log'"); return true; } CVector3 vecPosition; // Get our local player CLocalPlayer * pLocalPlayer = g_pCore->GetGame()->GetLocalPlayer(); if (pLocalPlayer->IsInVehicle()) { CVehicleEntity * pVehicle = pLocalPlayer->GetVehicleEntity(); if (pVehicle) { pVehicle->GetPosition(vecPosition); CVector3 vecRotation; pVehicle->GetRotation(vecRotation); DWORD dwColors[5]; pVehicle->GetColors(dwColors[0], dwColors[1], dwColors[2], dwColors[3], dwColors[4]); fprintf_s(file, "createVehicle(%d, %f, %f, %f, %f, %f, %f, %d, %d, %d, %d, %d);%s%s\n", CIVModelManager::ModelHashToVehicleId(pVehicle->GetModelInfo()->GetHash()), vecPosition.fX, vecPosition.fY, vecPosition.fZ, vecRotation.fX, vecRotation.fY, vecRotation.fZ, dwColors[0], dwColors[1], dwColors[2], dwColors[3], dwColors[4], strParameters.GetLength() > 0 ? " // " : "", strParameters.GetLength() > 0 ? strParameters.Get() : ""); } } else { pLocalPlayer->GetPosition(vecPosition); int iModelId = pLocalPlayer->GetPlayerPed()->GetModelIndex(); fprintf_s(file, "PlayerData(%d, %f, %f, %f, %f);%s%s\n", iModelId, vecPosition.fX, vecPosition.fY, vecPosition.fZ, pLocalPlayer->GetHeading(), strParameters.GetLength() > 0 ? " // " : "", strParameters.GetLength() > 0 ? strParameters.Get() : ""); } fclose(file); g_pCore->GetChat()->Print("Position data saved to 'SavePositions.log'"); return true; } #ifdef _DEBUG else if(strCommand == "cv") { CVector3 vecCreatePos; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecCreatePos); vecCreatePos.fX += 4; CVehicleEntity * pVehicle = new CVehicleEntity(atoi(strParameters.Get()), vecCreatePos, 0.0f, 0x000000, 0x000000, 0x000000, 0x000000, 0xFFFFFF); if(pVehicle) { // Add our vehicle pVehicle->SetId(g_pCore->GetGame()->GetVehicleManager()->Add(pVehicle)); pVehicle->Create(); g_pCore->GetGame()->GetLocalPlayer()->WarpIntoVehicle(pVehicle); } return true; } else if(strCommand == "respawn") { g_pCore->GetGame()->GetLocalPlayer()->Respawn(); return true; } else if(strCommand == "cp") { CVector3 vecCreatePos; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecCreatePos); CPlayerEntity * pPlayer = new CPlayerEntity(false); if(pPlayer) { pPlayer->SetModel(7); pPlayer->Create(); pPlayer->Teleport(vecCreatePos); } return true; } else if(strCommand == "engine") { if(g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity() != NULL) g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity()->SetEngineState(!g_pCore->GetGame()->GetLocalPlayer()->GetVehicleEntity()->GetEngineState()); return true; } else if(strCommand == "giveweapon") { CIVScript::GiveWeaponToChar(g_pCore->GetGame()->GetLocalPlayer()->GetScriptingHandle(), (CIVScript::eWeapon)atoi(strParameters.Get()), 100, true); return true; } else if(strCommand == "xaxis") { CVector3 vecPositon; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPositon); vecPositon.fX += atoi(strParameters.Get()); g_pCore->GetGame()->GetLocalPlayer()->SetPosition(vecPositon); return true; } else if(strCommand == "yaxis") { CVector3 vecPositon; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPositon); vecPositon.fY += atoi(strParameters.Get()); g_pCore->GetGame()->GetLocalPlayer()->SetPosition(vecPositon); return true; } else if(strCommand == "zaxis") { CVector3 vecPositon; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPositon); vecPositon.fZ += atoi(strParameters.Get()); g_pCore->GetGame()->GetLocalPlayer()->SetPosition(vecPositon); return true; } else if(strCommand == "port") { CVector3 vecPositon; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPositon); vecPositon.fX = 900; vecPositon.fY = -71; vecPositon.fZ += 20; g_pCore->GetGame()->GetLocalPlayer()->SetPosition(vecPositon); return true; } else if(strCommand == "time") { g_pCore->GetTimeManagementInstance()->SetTime(atoi(strParameters.Get()), 0); CGameFunction::SetTimeOfDay(atoi(strParameters.Get()), 0); return true; } else if(strCommand == "setmodel") { g_pCore->GetGame()->GetLocalPlayer()->SetModel(atoi(strParameters.Get())); return true; } else if(strCommand == "setclothes") { CString strParameter = CString("%s", strParameters.Get()); g_pCore->GetChat()->Print(strParameter.Get()); // Get the end of the command size_t sCommandEnd = strParameter.Find(" "); // If we don't have a valid end use the end of the string if (sCommandEnd == std::string::npos) { sCommandEnd = strParameter.GetLength(); } // Get the command name std::string strCommand2 = strParameter.Substring(0, (sCommandEnd)); // Get the command parameters std::string strParams; // Do we have any parameters? if(sCommandEnd < strParameter.GetLength()) { strParams = strParameter.Substring((sCommandEnd + 1), strParameter.GetLength()); } g_pCore->GetChat()->Print(CString("Setting clothes part %d to %d", atoi(strCommand2.c_str()), atoi(strParams.c_str()))); g_pCore->GetGame()->GetLocalPlayer()->SetPedClothes(atoi(strCommand2.c_str()), atoi(strParams.c_str())); return true; } else if(strCommand == "bahama") { g_pCore->GetGame()->GetLocalPlayer()->CPlayerEntity::SetPosition(CVector3(-15.9453f, -13.5865f, -11.7456f)); return true; } else if(strCommand == "spawnvehs") { CVector3 vecPos; PTR_LOCALPLAYER->GetPosition(vecPos); for (int i = 0; i < 179; i++) { vecPos.fX += 5; CVehicleEntity * pVehicle = new CVehicleEntity(i, vecPos, 0.0f, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF); if(pVehicle) { // Add our vehicle g_pCore->GetGame()->GetVehicleManager()->Add(pVehicle); pVehicle->SetId(g_pCore->GetGame()->GetVehicleManager()->FindFreeSlot()); pVehicle->Create(); pVehicle->SetPosition(vecPos, true); } } return true; } else if(strCommand == "getvehpos") { int iVehicle = atoi(strParameters.Get()); if(g_pCore->GetGame()->GetVehicleManager()->DoesExists(iVehicle)) { CVector3 vecPosition; g_pCore->GetGame()->GetVehicleManager()->GetAt(iVehicle)->GetPosition(vecPosition); PTR_CHAT->Print(CString("Position of vehicle %d: %f, %f,%f", iVehicle, vecPosition.fX, vecPosition.fY, vecPosition.fZ)); } return true; } else if(strCommand == "ivhelp") { PTR_CHAT->Print("List of Default IV:N Commands..."); PTR_CHAT->Print("** /cv /respawn /debug /weapon /cp /spawn /engine /save /giveweapon /xaxis /time"); PTR_CHAT->Print("** /setmodel /testweapon /ready /parachute /bahama /spawnvehicles /getvehpos"); return true; } else if(strCommand == "createtrain") { g_pCore->GetGame()->GetIVManagement()->CreateTrain(g_pCore->GetGame()->GetLocalPlayer()->GetPosition(), 3, 20.0f, 0); return true; } else if(strCommand == "blip") { unsigned int uiBlip; CIVScript_NativeInvoke::Invoke<unsigned int>(CIVScript::NATIVE_ADD_BLIP_FOR_COORD, 0, 0, 0,&uiBlip); CIVScript_NativeInvoke::Invoke<unsigned int>(CIVScript::NATIVE_CHANGE_BLIP_SPRITE, 10); return true; } else if(strCommand == "sethealth") { g_pCore->GetGame()->GetLocalPlayer()->SetHealth(atoi(strParameters.Get())); return true; } else if (strCommand == "setarmour") { g_pCore->GetGame()->GetLocalPlayer()->SetArmour(atoi(strParameters.Get())); return true; } #endif #ifdef SYNC_TEST else if (strCommand == "syncTest") { // Add the player CPlayerEntity * pPlayer = new CPlayerEntity; pPlayer->SetModel(0); // Set temporary to nico lol pPlayer->Create(); pPlayer->SetNick("Keks"); pPlayer->SetId(1); pPlayer->SetColor(0xFFFFFFFF); g_pCore->GetGame()->GetPlayerManager()->Add(1, pPlayer); CVector3 vecPosition; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPosition); vecPosition.fX += 2.0f; pPlayer->SetPosition(vecPosition); } else if (strCommand == "getP") { CVector3 vecPosition; g_pCore->GetGame()->GetLocalPlayer()->GetPosition(vecPosition); vecPosition.fX += 2.0f; g_pCore->GetGame()->GetPlayerManager()->GetAt(1)->SetPosition(vecPosition); } else if (strCommand = "vehicleSync") { g_pCore->GetGame()->GetLocalPlayer()->PutInVehicle(g_pCore->GetGame()->GetVehicleManager()->GetAt(0), 0); CVector3 vecPosition; g_pCore->GetGame()->GetPlayerManager()->GetAt(1)->GetPosition(vecPosition); CVehicleEntity * pVehicle = new CVehicleEntity(90, vecPosition, 90, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); if (pVehicle) { // // Add our vehicle g_pCore->GetGame()->GetVehicleManager()->Add(1, pVehicle); pVehicle->SetId(1); pVehicle->Create(); pVehicle->SetPosition(vecPosition, true); } //g_pCore->GetGame()->GetPlayerManager()->GetAt(1)->PutInVehicle(g_pCore->GetGame()->GetVehicleManager()->GetAt(0), 0); //CVehicleEntity * pVehicle = new CVehicleEntity(90, vecPosition, 90, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); //if (pVehicle) //{ // // // Add our vehicle // g_pCore->GetGame()->GetVehicleManager()->Add(vehicleId, pVehicle); // pVehicle->SetId(vehicleId); // pVehicle->Create(); // pVehicle->SetPosition(vecPosition, true); //} } #endif return false; }