SA-MP Forums Archive
Detecting if player crashed in wall/etc... - 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: Detecting if player crashed in wall/etc... (/showthread.php?tid=336917)



Detecting if player crashed in wall/etc... - RollTi - 24.04.2012

i read OnPlayerStateChange on SA-MP Wiki however
the code i made is not working the helmet is still on attached in players head
i get the few helmet codes from MasterJoker's Helmet [FS] i modify it

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vid = GetPlayerVehicleID(playerid);
    new Float:hp;
    GetPlayerHealth(playerid, hp);
    if(GetVehicleModel(vid) == 448 || GetVehicleModel(vid) == 461 || GetVehicleModel(vid) == 462
    || GetVehicleModel(vid) == 463 || GetVehicleModel(vid) == 468 || GetVehicleModel(vid) == 471
    || GetVehicleModel(vid) == 481 || GetVehicleModel(vid) == 509 || GetVehicleModel(vid) == 510
    || GetVehicleModel(vid) == 521 || GetVehicleModel(vid) == 522 || GetVehicleModel(vid) == 523 ||
    GetVehicleModel(vid) == 571 || GetVehicleModel(vid) == 581 || GetVehicleModel(vid) == 586)
    {
        if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
        {
            SetPlayerHealth(playerid, hp - 1.8);
            pInfo[playerid][WearingHelmet] = false;
            if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
        }
    }
    return 1;
}



Respuesta: Detecting if player crashed in wall/etc... - Marricio - 24.04.2012

pawn Код:
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
     pInfo[playerid][WearingHelmet] = false;
     if( IsPlayerAttachedObjectSlotUsed( playerid, 1 ) )
            RemovePlayerAttachedObject( playerid, 1 );
}
As simple as that.


Re: Detecting if player crashed in wall/etc... - RollTi - 24.04.2012

Thanks rep+