Vehicle spawn command - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Vehicle spawn command (
/showthread.php?tid=265720)
Vehicle spawn command -
Moron - 02.07.2011
I have this vehicle spawning command, but there is a problem with it ;/ When a spawned vehicle is destroyed it respawns and i dont want them to respawn when they are spawned using this command.
Код:
if(!strcmp(cmdtext, "/scar", false, 5))
{
if(!strlen(cmdtext[5]) return SendClientMessage(playerid, red, "Usage: /scar [Model ID]");
new veh = strval(cmdtext[5]);
if(veh < 400 || veh > 611) return SendClientMessage(playerid, red, "ERROR: Invalid Vehicle Model");
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x,y,z); GetPlayerFacingAngle(playerid, a);
CreateVehicle(veh, x,y,z, a, -1, -1, -1);
return 1;
}
Re: Vehicle spawn command -
[HiC]TheKiller - 02.07.2011
You could always do this
pawn Код:
if(!strcmp(cmdtext, "/scar", false, 5))
{
if(!strlen(cmdtext[5]) return SendClientMessage(playerid, red, "Usage: /scar [Model ID]");
new veh = strval(cmdtext[5]);
if(veh < 400 || veh > 611) return SendClientMessage(playerid, red, "ERROR: Invalid Vehicle Model");
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x,y,z); GetPlayerFacingAngle(playerid, a);
sCar[playerid] = CreateVehicle(veh, x,y,z, a, -1, -1, -1);
return 1;
}
pawn Код:
public OnVehicleDeath(vehicleid)
{
for(new x; x<MAX_PLAYERS; x++)
{
if(sCar[x] != 0) continue;
if(sCar[x] == vehicleid)
{
DestroyVehicle(vehicleid);
break;
}
}
return 1;
}
Re: Vehicle spawn command -
Moron - 02.07.2011
I would prefer the first offer
Okay i will try it out.
Re: Vehicle spawn command -
Moron - 02.07.2011
Is it possible to do it without [playerid] in this line
because it causes some problems ;/
Re: Vehicle spawn command -
[HiC]TheKiller - 02.07.2011
What line is the error on? There was a missing equals sign on OnVehicleDeath.
Re: Vehicle spawn command -
Moron - 02.07.2011
Yes i see but is it possible to use just sCar instead of sCar[playerid] ? Because [playerid] causes some problems :/
Re: Vehicle spawn command -
[HiC]TheKiller - 02.07.2011
Unless you are going to have one player on the server constantly, no. What I have done is made it so there is one vehicle ID per player.
Re: Vehicle spawn command -
Moron - 02.07.2011
Well i got another idea. OnPlayerDeath i get the vehicle model and if that model is from the car market it is destroyed. /scar command was like a comparison.