Checking if the player destroyed a vehicle?
#1

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.
Reply
#2

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

Thanks Pharre, Works great! Rep+
Reply
#4

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

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

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.
Reply
#7

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.
Reply
#8

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?
Reply
#9

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


Forum Jump:


Users browsing this thread: 1 Guest(s)