Just a simple question.
#1

Okay guys I was wondering how to Detect the player who hit you to blow you your car.

For example: Two players hit me when I'm in my car, my car catches on fire. My car blows up. How can I detect the player who got the winning hit?
Reply
#2

Quote:
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    printf("Vehicle ID %d was damaged by playerid %d.", vehicleid, playerid);
    return 1;
}
At least you can use this..
My sugestion:
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    new Float:h;
    GetVehicleHealth(vehicleid,h);
    if(h =< 0){//car is burning
          printf("Player %s has set the car with id %d on fire",playerid,vehicleid);
    }
    return 1;
}
Then you just search for an GetVehicleDriver function and voila.

or put this in your script(Made by me, not bug-free due to code-limitations):
pawn Код:
new vehicledriverid[MAX_VEHICLES] = {-1,...};

stock GetVehicleDriver(vehicleid)return vehicledriverid[vehicleid];//returns -1 if vehicle has no driver
/*
ALT:
*/

/*
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)vehicledriverid[GetPlayerVehicleID(playerid)] = playerid;
    if(oldstate == PLAYER_STATE_DRIVER && newstate != PLAYER_STATE_DRIVER)vehicledriverid[GetPlayerVehicleID(playerid)] = -1;
    return 1;
}
*/

/*
RECOMMENDED YOU USE:
*/


public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger){
    if(!ispassenger) vehicledriverid[vehicleid] = playerid;
    return 1;
}

public OnPlayerExitVehicle(playerid,vehicleid){
//Important Note: Not called if the player falls off a bike or is removed from a vehicle by other means such as using SetPlayerPos
    if(GetVehicleDriver(vehicleid) == playerid)vehicledriverid[vehicleid] = -1;
    return 1;
}
Reply
#3

If you set vehicle HP to 100 it starts to burn, so I would increase the vehicle health check to atleast 100(100.0) instead of 0
Reply
#4

Vehicles burn from 250 downwards. OnVehicleDamageStatusUpdate only gets called when VISUAL damage is inflicted - you can't detect when someone shoots your vehicle (okay perhaps a highly in-accurate one with complicated maths and the camera functions, but a native function would be better tbh.)
Reply
#5

Why not just onplayerdeath get the killerid.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)