Extended Vehicle Sp...
 
Notifications
Clear all

Extended Vehicle Spawner C++/SPRX

Page 1 / 3

KranK
Posts: 336
Topic starter
(@KranK)
Reputable Member
Joined: 9 years ago

Hey Rivals

This is Set Of functions that toke me some time to create and very simple to use when you understand it

1.Instant Spawn Vehicles Online/Offline
2.Toogble Bool For Replace Previous Vehicle / Save Previous Vehicle Speed
3.Dynamic Vehicles Reader / Read From Pointer Array and Determine the Vehicle Name Into The Menu
4.No Need Add Option For Every Vehicle In Menu
5.Simple Switch Case For Every Single Vehicle You Spawn

NOTE: This Setup Is Also Apply To Spawning PEDS Changing Weather And Any Thing Else That Defined In Game As Strings/Hashes ETC

[HIDE]Variables

int OutinfiniteScrollCount;
	int carspawnActiveLineIndex = 0;
	char* Super_Cars[1][11] = { { "ADDER", "ENTITYXF", "CHEETAH", "INFERNUS", "VACCA", "BULLET" , "VOLTIC" , "ZENTORNO" , "TURISMOR", "OSIRIS", "T20" } };
	int Super_Cars_Count = 11;
	bool Replace_Previous_Vehicle = false;

Vehicle Spawner Function It Self Must Run From The Hook / Looped

//Vehicle Spawner loop
	
	if (SpawnCarLoop)
	    {
	        int veh;
	        int Last_Veh;
	        float Speed;
	        char buf[90];
	        Vector3 Coords = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
	        int Hash = GAMEPLAY::GET_HASH_KEY(cartospawn);
	        if (STREAMING::IS_MODEL_IN_CDIMAGE(Hash) && STREAMING::IS_MODEL_A_VEHICLE(Hash))
	        {
	            STREAMING::REQUEST_MODEL(Hash);
	            if (STREAMING::HAS_MODEL_LOADED(Hash))
	            {
	                if (!ENTITY::DOES_ENTITY_EXIST(veh))
	                {
	                    if (Replace_Previous_Vehicle)
	                    {
	                        Last_Veh = PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), true);
	                        if (Last_Veh != 0)
	                        {
	                            Speed = ENTITY::GET_ENTITY_SPEED(Last_Veh);
	                            ENTITY::SET_ENTITY_AS_MISSION_ENTITY(Last_Veh, true, false);
	                            VEHICLE::DELETE_VEHICLE(&Last_Veh);
	                        }
	
	                    }
	                    if (ENTITY::DOES_ENTITY_EXIST((veh = VEHICLE::CREATE_VEHICLE(Hash, Coords.x + 3.5f, Coords.y, Coords.z, ENTITY::GET_ENTITY_HEADING(PLAYER::PLAYER_PED_ID()), true, false))))
	                    {
	                        PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), veh, -1);
	                        VEHICLE::SET_VEHICLE_ENGINE_ON(veh, true, true);
	                        VEHICLE::SET_VEHICLE_FORWARD_SPEED(veh, Speed);
	                        STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(Hash);
	                        snprintf(buf, sizeof(buf), "Spawned: n ~b~%s~HUD_COLOUR_GREEN~", cartospawn);
	                        printonscreen(buf, 2000);
	                        KeyBoardString = "";
	                        SpawnCarLoop = false;
	
	                    }
	                }
	            }
	        }
	        else
	        {
	
	        }
	
	    }
	

Spawner Caller Function

char * cartospawn;
	int Create_Vehicle(char * Vehicle_Name)
	{
	    SpawnCarLoop = true;
	    cartospawn = Vehicle_Name;
	}

Calling Switch Function

#pragma region Super Vehicles
	    case Super_Vehicles:
	        addTitle("Super Cars");
	        for (int i = 0; i < Super_Cars_Count; i++)
	        {
	            int _Pointer = i;
	            OutinfiniteScrollCount = i + 1;
	            addOption(Super_Cars[carspawnActiveLineIndex][_Pointer]);
	        }
	        switch (getOption())
	        {
	        case 0:break;
	        default:Create_Vehicle(Super_Cars[carspawnActiveLineIndex][currentOption - 1]); Replace_Previous_Vehicle = true; break;
	        }
	        break;
	[HASHTAG]#pragma[/HASHTAG] endregion

[/HIDE]

Reply
Name of the Video Game, and any other Tags
12 Replies
Cain532
Posts: 1280
(@cain532)
Noble Member
Joined: 10 years ago

Very nice 😀 Thanks for posting some good shit dude!!!!

Reply
KranK
Posts: 336
Topic starter
(@KranK)
Reputable Member
Joined: 9 years ago

Very nice 😀 Thanks for posting some good shit dude!!!!

Thank you Boss xD

Reply
Rivalz
Posts: 307
(@Rivalz)
Reputable Member
Joined: 9 years ago

Well done Krank, thank you. 😉
Does this mean modders can benefit from this - this code for vehicle spawner - will it change the vehicle you are already in, or will it spawn another vehicle?

Reply
KranK
Posts: 336
Topic starter
(@KranK)
Reputable Member
Joined: 9 years ago

Well done Krank, thank you. 😉
Does this mean modders can benefit from this - this code for vehicle spawner - will it change the vehicle you are already in, or will it spawn another vehicle?

This one dosnt have store previous vehicle handle and not replacing it
But I easy can add variable for this if you wish

Reply
Page 1 / 3