[HELP] Vehicle destroy - 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 destroy (
/showthread.php?tid=404467)
[HELP] Vehicle destroy -
beasty - 03.01.2013
Hey guys. So, I have a car script, and wanna create function which will destroy vehicle after she death (becouse without destroying it appears in spawn).
Okay. I was creating destroy script in callback OnVehicleDeath like this:
PHP код:
if(CreateCar[playerid] != -1)
{
DestroyVehicle(CreateCar[playerid]);
CreateCar[playerid] = -1;
}
But then i get errors about playerid, becouse OnVehicleDeath cannot read playerid......
I was trying to create script like this
PHP код:
public OnVehicleDeath(vehicleid, killerid)
{
for(new playerid;playerid<MAX_PLAYERS;playerid++)
{
if(CreateCar[playerid] != -1)
{
DestroyVehicle(CreateCar[playerid]);
CreateCar[playerid] = -1;
}
}
return 1;
}
But after destroying, vehicles is disappears for all server players.
Please help!
Re: [HELP] Vehicle destroy -
Konstantinos - 03.01.2013
I'm not sure if you can destroy a vehicle when it marked as death vehicle. From what I understood, you want to check if the vehicleid is the one the variable holds from the loop, right?
pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
for(new playerid;playerid<MAX_PLAYERS;playerid++)
{
if(CreateCar[playerid] != -1 && CreateCar[playerid] == vehicleid)
{
DestroyVehicle(vehicleid);
CreateCar[playerid] = -1;
}
}
return 1;
}
Re: [HELP] Vehicle destroy -
beasty - 03.01.2013
Thanks very much, it's works. And how can i send message for every player with automsg, when i got 2 languages in the server and need playerid for if(en[playerid] == 1).
Like :
pawn Код:
for(new playerid;playerid<MAX_PLAYERS;playerid++)
{
if(lt[playerid] == 1)
{
new randMSG = random(sizeof(RandomLT));
SendClientMessageToAll(0xFFFFFFFF, RandomLT[randMSG]);
}
if(en[playerid] == 1)
{
new randMSG = random(sizeof(RandomEN));
SendClientMessageToAll(0xFFFFFFFF, RandomEN[randMSG]);
}
}
With
pawn Код:
for(new playerid;playerid<MAX_PLAYERS;playerid++)
players gets a lot of messages together. :/
Re: [HELP] Vehicle destroy -
Konstantinos - 03.01.2013
SendClientMessageToAll sends a message to all. Use
pawn Код:
SendClientMessage(playerid, 0xFFFFFFFF, RandomLT[randMSG]);
And
pawn Код:
SendClientMessage(playerid, 0xFFFFFFFF, RandomEN[randMSG]);
instead.