SA-MP Forums Archive
[Help] Vehicle Spawner - 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: [Help] Vehicle Spawner (/showthread.php?tid=574963)



[Help] Vehicle Spawner - kalanerik99 - 22.05.2015

Hello

I have one problem!
When one of the players spawns vehicle someone others vehicle disaphears
How to fix it(I am using mSelection and this function!)
PHP Code:
function VehicleSpawner(playerid,model)
{
new 
Float:x,Float:y,Float:z,Float:a;
new 
componentid;
for (new 
i14i++)
{
componentid GetVehicleComponentInSlot(veh1[playerid], i);
if (
componentid != 0)
RemoveVehicleComponent(veh1[playerid], componentid);
}
DestroyVehicle(veh1[playerid]);
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
veh1[playerid] = CreateVehicle(model,x+1,y+1,z,a,-1,-1,-1);
SetVehicleNumberPlate(veh1[playerid],""COL_WHITE"-"COL_RED"U"COL_GREEN"G"COL_BLUE"F"COL_WHITE"-");
LinkVehicleToInterior(veh1[playerid], GetPlayerInterior(playerid));
SetVehicleVirtualWorld(veh1[playerid],GetPlayerVirtualWorld(playerid));
SetVehiclePos(veh1[playerid],x+1,y+1,z);
SetVehicleHealth(veh1[playerid],  1000.0);
PutPlayerInVehicle(playeridveh1[playerid], 0);
return 
1;




Re: [Help] Vehicle Spawner - Luis- - 22.05.2015

Looks like the vehicle id's are getting mixed up, you should try doing some debugging.


Re: [Help] Vehicle Spawner - Konstantinos - 22.05.2015

Quote:
Originally Posted by Luis-
View Post
Looks like the vehicle id's are getting mixed up, you should try doing some debugging.
That.

When destroying a vehicle for a player A, you must reset the variable because if another vehicle is created with the same vehicle ID for player B, it will remove the vehicle of player B when it's supposed not to.

pawn Code:
// whenever destroying player's vehicle:
DestroyVehicle(veh1[playerid]);
veh1[playerid] = INVALID_VEHICLE_ID;



Re: [Help] Vehicle Spawner - kalanerik99 - 22.05.2015

Ok Thanks konstantinos and louis
Can you 2 please check my changename problem(look at my threads started)
Please Thanks =)