[HELP] Vehicle destroy
#1

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(vehicleidkillerid)
{
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!
Reply
#2

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;
}
Reply
#3

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. :/
Reply
#4

SendClientMessageToAll sends a message to all. Use
pawn Код:
SendClientMessage(playerid, 0xFFFFFFFF, RandomLT[randMSG]);
And
pawn Код:
SendClientMessage(playerid, 0xFFFFFFFF, RandomEN[randMSG]);
instead.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)