SA-MP Forums Archive
Checking if the player destroyed a vehicle? - 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: Checking if the player destroyed a vehicle? (/showthread.php?tid=298492)



Checking if the player destroyed a vehicle? - -Rebel Son- - 21.11.2011

Howdy, Haven't scripted in awhile, Trying to figure out how to check if the player died/ruined a vehicle,
so i can count it in a variable, "totaled"
example,
players driving, hit something car starts to flame, he runs away from it, it explodes, he gets +1 to his totaled.

Don't even know where to start on this, contimplating either on OnVehicleDeath or OnPlayerDeath.

Any help is apriciated.


Re: Checking if the player destroyed a vehicle? - Pharrel - 21.11.2011

pawn Код:
//global variables
new Totaled[MAX_PLAYERS];
new LastTotaled[MAX_PLAYERS];

//OnVehicleDamageStatusUpdate
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
    new Float:Health;
    GetVehicleHealth(GetPlayerVehicleID(playerid), Health);
    if(Health < 250 && LastTotaled[playerid] != GetPlayerVehicleID(playerid))
    {
        Totaled[playerid]++;
        LastTotaled[playerid] = GetPlayerVehicleID(playerid);
    }
}

//OnPlayerStateChange
if(oldstate == PLAYER_STATE_DRIVER && LastTotaled[playerid] != 0) LastTotaled[playerid] = 0;



Re: Checking if the player destroyed a vehicle? - -Rebel Son- - 21.11.2011

Thanks Pharre, Works great! Rep+


Re: Checking if the player destroyed a vehicle? - cruising - 21.11.2011

Does this work somehow if you kill a vehicle that a another player is driving to?


Re: Checking if the player destroyed a vehicle? - -Rebel Son- - 21.11.2011

Not sure, Haven't attempted it yet. but it works if you blow up in a vehicle.


Re: Checking if the player destroyed a vehicle? - cruising - 21.11.2011

Quote:
Originally Posted by -Rebel Son-
Посмотреть сообщение
Not sure, Haven't attempted it yet. but it works if you blow up in a vehicle.
Ok, because i would be happy if it also could work that way, need something like that on my server.


Re: Checking if the player destroyed a vehicle? - -Rebel Son- - 21.11.2011

Yeah, I'm making a offroad server, trying to account each time someone totals a vehicle, Still trying to figure out how to mark it up even if they'r not in the vehicle, Like if they jumped out and ran when it caught on fire, Still cant find the right pattern for it.


Re: Checking if the player destroyed a vehicle? - cruising - 21.11.2011

Quote:
Originally Posted by -Rebel Son-
Посмотреть сообщение
Yeah, I'm making a offroad server, trying to account each time someone totals a vehicle, Still trying to figure out how to mark it up even if they'r not in the vehicle, Like if they jumped out and ran when it caught on fire, Still cant find the right pattern for it.
An off road server sounds interesting. Im not that good at scripting, but how about check the nearest player of that vehicle and if hes not in a vehicle? or check the last player driven the vehicle? if that even is possible?


Re: Checking if the player destroyed a vehicle? - -Rebel Son- - 29.11.2011

Never thought about that, I Will attempt to do that, thanks for the thought!