Car Spawner Help - 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: Car Spawner Help (
/showthread.php?tid=287375)
Car Spawner Help -
TyThaBomb - 02.10.2011
Well, I made a car spawner, but obviously the cars pile and pile and pile. I was trying to find a way to when they spawn one car it stays, then if they spawn another, the one before it gets destroyed. I'll just show you a snip of it. Any help would be greatly appreciated!
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/carmenu",true)==0)
{
if(IsPlayerConnected(playerid))
{
if(spawnedcar[playerid] != 0)
{
new scar;
scar= GetPlayerVehicleID(playerid);
RemovePlayerFromVehicle(playerid);
DestroyVehicle(scar);
ShowMenuForPlayer(CarMenu,playerid);
spawnedcar[playerid] = 0;
TogglePlayerControllable(playerid, 0);
}
else if(spawnedcar[playerid] != 1)
{
ShowMenuForPlayer(CarMenu,playerid);
spawnedcar[playerid] = 1;
TogglePlayerControllable(playerid, 0);
}
}
return 1;
}
DIALOG:
pawn Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
new Menu:CurrentMenu = GetPlayerMenu(playerid);
new Float:x, Float:y, Float:z, Float:a;
GetPlayerFacingAngle(playerid,a);
GetPlayerPos(playerid, x, y, z);
new car;
if(CurrentMenu == CarMenu)
{
switch(row)
{
case 0: //infernus
{
car=CreateVehicle(411,x,y,z+4,a,-1,-1,30000);
PutPlayerInVehicle(playerid,car,0);
spawnedcar[playerid] = 1;
SendClientMessage(playerid, 0x33CCFFAA, "<| You Have Selected the: Infernus |>");
TogglePlayerControllable(playerid, 1);
}
Re: Car Spawner Help -
henry jiggy - 02.10.2011
When the car spawns, assign its id to a global variable, example.
pawn Код:
//OUTSIDE of any function
new PlayerVehicle[MAX_PLAYERS];
//On the vehicle spawn
DestroyVehicle(PlayerVehicle[playerid]);
PlayerVehicle[playerid] = CreateVehicle(411,x,y,z+4,a,-1,-1,30000)
PutPlayerInVehicle(playerid,PlayerVehicle[playerid],0);
spawnedcar[playerid] = 1;
//OnPlayerDisconnect
DestroyVehicle(PlayerVehicle[playerid]);
PlayerVehicle[playerid] = 9999999999999999999999999999;
Just put that propperly on your script with the proper car modelids and you're good to go!