Give - health when car collides
#6

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
1) That code would do nothing but heal the player.
2) The posted is asking if you can damage the player if the car crashes or runs into an object, like in GTA IV.

My opinion on this is, I don't actually think there's a code to detect if a car has hit an object, the only thing I can think of is using GetVehicleHealth and SetPlayerHealth.
That's the problem, i already have something that gives player -health when the car gets -health, but the problem is when i SetCarHealth, it kills the player, also when the car respawns when the player is in it, it kills the player...

EDIT: For people interested, I fixed it, and this is the code:
pawn Код:
//Credits to FALLOUT for this code, credits to Jari_Johnson* for finding out that if you just place it inside this //callback that it also works lol
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    if(IsPlayerInAnyVehicle(playerid) == 1 && Seatbelt[playerid] == 0)
    {
        new Float:TempCarHealth;
        GetVehicleHealth(GetPlayerVehicleID(playerid), TempCarHealth);
        new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
        if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,100.0) == 1))
        {
            Difference = floatdiv(Difference, 10.0);
            new Float:OldHealth;
            GetPlayerHealth(playerid, OldHealth);
            SetPlayerHealth(playerid, floatsub(OldHealth, Difference));
        }
        CarHealth[playerid] = TempCarHealth;
    }
    else
    {
        CarHealth[playerid] = 0.0; //To aviod that a player dies when he enters a vehicle
    }
    return 1;
}
Reply


Messages In This Thread
[SOLVED - Give - health when car collides] (solved code in last post) - by Jstylezzz - 11.07.2012, 15:07
Re: Give - health when car collides - by Captain_Mani - 11.07.2012, 16:33
Re: Give - health when car collides - by clarencecuzz - 11.07.2012, 16:36
Re: Give - health when car collides - by Andregood - 11.07.2012, 16:39
Re: Give - health when car collides - by clarencecuzz - 11.07.2012, 16:43
Re: Give - health when car collides - by Jstylezzz - 11.07.2012, 17:09

Forum Jump:


Users browsing this thread: 1 Guest(s)