Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new LastAttemptedJack[MAX_PLAYERS] = {INVALID_PLAYER_ID, ...};
- new LastEnteredVehicle[MAX_PLAYERS] = {INVALID_VEHICLE_ID, ...};
- stock GetVehicleDriverID(vehicleid)
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(GetPlayerVehicleID(i) == vehicleid && GetPlayerState(i) == PLAYER_STATE_DRIVER)
- {
- return i;
- }
- }
- }
- return INVALID_PLAYER_ID;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- if(!ispassenger)
- {
- LastAttemptedJack[playerid] = GetVehicleDriverID(vehicleid);
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER)
- {
- LastEnteredVehicle[playerid] = GetPlayerVehicleID(playerid);
- }
- if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
- {
- LastEnteredVehicle[playerid] = INVALID_VEHICLE_ID;
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(killerid == INVALID_PLAYER_ID)
- {
- new jacker = GetVehicleDriverID(LastEnteredVehicle[playerid]);
- if(jacker != INVALID_PLAYER_ID)
- {
- if(LastAttemptedJack[jacker] == playerid)
- {
- killerid = jacker;
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement