Advertisement
bigbossbro08

Untitled

Jul 11th, 2020
1,880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.66 KB | None | 0 0
  1. /*bool showPedSpawnerWindow;*/ void ShowPedSpawnerWindow()
  2. {
  3.     //if (!showPedSpawnerWindow) return;
  4.     CPlayerPed* pLocalPlayer = FindPlayerPed();
  5.  
  6.     std::string elementName = std::to_string(pedID) + "-" + peds[pedID];
  7.     ImGuiComboFlags flags = ImGuiComboFlags_NoArrowButton;
  8.  
  9.     ImGuiStyle& style = ImGui::GetStyle();
  10.     float w = ImGui::CalcItemWidth();
  11.     float spacing = style.ItemInnerSpacing.x;
  12.     float button_sz = ImGui::GetFrameHeight();
  13.  
  14.     ImGui::PushItemWidth(w - spacing * 2.0f - button_sz * 2.0f);
  15.  
  16.     if (ImGui::BeginCombo("##vehicleid", elementName.c_str()))
  17.     {
  18.         for (std::map<int, std::string>::iterator it = peds.begin(); it != peds.end(); ++it) {
  19.             elementName = std::to_string(it->first) + " - " + it->second;
  20.             bool isSelected = (pedID == it->first);
  21.             if (ImGui::Selectable(elementName.c_str(), isSelected))
  22.             {
  23.                 pedID = it->first;
  24.                 if (isSelected)
  25.                     ImGui::SetItemDefaultFocus();
  26.             }
  27.         }
  28.         ImGui::EndCombo();
  29.     }
  30.  
  31.     std::map<int, std::string>::iterator pedIterateID = peds.find(pedID);
  32.  
  33.     ImGui::PopItemWidth();
  34.     ImGui::SameLine(0, spacing);
  35.     if (ImGui::ArrowButton("##l", ImGuiDir_Left))
  36.     {
  37.         if (pedIterateID->first > 0)
  38.             pedIterateID = --pedIterateID;
  39.         pedID = pedIterateID->first;
  40.         if (pedID < 0)
  41.             pedID = 0;
  42.     }
  43.     ImGui::SameLine(0, spacing);
  44.     if (ImGui::ArrowButton("##r", ImGuiDir_Right))
  45.     {
  46.         if (pedIterateID->first < 299)
  47.             pedIterateID = ++pedIterateID;
  48.         pedID = pedIterateID->first;
  49.         if (pedID > 299)
  50.             pedID = 299;
  51.     }
  52.     ImGui::SameLine(0, style.ItemInnerSpacing.x);
  53.     ImGui::Text("Ped ID");
  54.  
  55.     if (ImGui::Button("Spawn ped", ImVec2(100, 20)))
  56.     {
  57.         CStreaming::RequestModel(pedID, 0);
  58.         CStreaming::LoadAllRequestedModels(false);
  59.  
  60.         CPed* ped = new CCivilianPed(CPopulation::IsFemale(pedID) ? PED_TYPE_CIVFEMALE : PED_TYPE_CIVMALE, pedID);
  61.         if (ped)
  62.         {
  63.             ped->SetPosn(pLocalPlayer->TransformFromObjectSpace(CVector(0.0f, 5.0f, 2.0f)));
  64.             CVector pedOrientation;
  65.             pLocalPlayer->GetOrientation(pedOrientation.x, pedOrientation.y, pedOrientation.z);
  66.             ped->SetOrientation(pedOrientation.x, pedOrientation.y, pedOrientation.z);
  67.             CWorld::Add(ped);
  68.             ped->PositionAnyPedOutOfCollision();
  69.             ped->m_pIntelligence->m_TaskMgr.SetTask(new CTaskSimpleGoToPoint(PEDMOVE_WALK, pLocalPlayer->GetPosition(), 1.5f, true, true), 4, false);
  70.         }
  71.     }
  72.     //ImGui::End();
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement