[Help] Vehicle Spawner
#1

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;

Reply
#2

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

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;
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)