GetPlayerDrunkLevel

From SA-MP Wiki

Jump to: navigation, search

GetPlayerDrunkLevel


Warning: This function was added in SA-MP version 0.3. It is not available in previous versions.


Checks the player's level of drunkenness. If the level is less than 2000, the player is sober. The player's level of drunkness goes down slowly automatically (26 levels per second). The higher drunkenness levels affect the player's camera, and the car driving handling. The level of drunkenness increases when the player drinks from a bottle (You can use SetPlayerSpecialAction to give them bottles).


Parameters:
(playerid)
playeridThe player you want to check the drunkenness level of.


ReturnsAn integer with the level of drunkenness of the player.


public OnPlayerStateChange(playerid, oldstate, newstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerDrunkLevel(playerid) > 1999)
    {
        SendClientMessage(playerid,0xFFFFFFFF,"Don't drink and drive!");
        RemovePlayerFromVehicle(playerid);
    }
}

TIP: You can use ApplyAnimation to apply a drunk animation.

Related Functions

The following functions might be useful as well, as they're related to this function in one way or another.

Personal tools
In other languages