Simple function question..? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Simple function question..? (
/showthread.php?tid=390486)
Simple function question..? -
MatZZPL - 06.11.2012
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
Re: Simple function question..? -
redreaper666 - 06.11.2012
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
Re: Simple function question..? -
MatZZPL - 06.11.2012
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
Re: Simple function question..? -
Abreezy - 06.11.2012
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.
Re: Simple function question..? -
MatZZPL - 06.11.2012
@Abreezy ok one sec, was round my girlfriends so didn't have the time now ill test it and will do