Simple function question..?
#1

Hi everyone, im making a car ownership system buuuut, i need to know how to spawn a car so that the player spawns with the car in the car? I need him to be in the car when he buy's it because i need to get the vehicle id so then later i can unspawn the car using "DestroyVehicle(veh);" ..


Any answers?






If you're good at scripting and know what you are doing can you inbox me please? I have few simple questions to ask would be so grateful
Reply
#2

new vehicle[playerid]
then set the coordinates where the car should spawn
vehicle[playerid] = CreateVehicle(vehicleid,coordinates);
after then
PutPlayerIntoVehicle(vehicle[playerid]);
and destroy your sellable car
that should do it
Reply
#3

so like this?
Quote:

else if(PlayerInfo[playerid][pCar] == 402)
{
new vehicle[playerid]
CreateVehicle(402,-2467.9888,2223.9019,4.5598,1,1,1,0);
vehicle[playerid] = CreateVehicle(402,-2467.9888,2223.9019,4.5598,1,1,1,0);
PlayerIntoVehicle(vehicle[playerid]);
GameTextForPlayer(playerid,"~h~~w~You brought a ~n~~h~~w~~h~~r~ Buffalo!",2500,1);
bike_reload[playerid] = gettime() + 20000;
return 1;
}

??
And how could i get the vehicleid now? so i can save it in my enume as pCarid? I want to save it so that then i can do cmd:unspawn and it will destroy that vehicle id



And of course thanks alot +rep
Reply
#4

If you want to save the vehicle ID to an enum then its pretty simple, do something like this:

pawn Код:
else if(PlayerInfo[playerid][pCar] == 402)
{
    new veh = CreateVehicle(402,-2467.9888,2223.9019,4.5598,1,1,1,0);
    PutPlayerInVehicle(playerid, veh, 0);
    GameTextForPlayer(playerid,"~h~~w~You brought a ~n~~h~~w~~h~~r~ Buffalo!",2500,1);
    new carid = GetPlayerVehicleID(playerid);
    Playerinfo[playerid][pCarID] = carid;
}
This is untested, let me know your results.
Reply
#5

@Abreezy ok one sec, was round my girlfriends so didn't have the time now ill test it and will do
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)