-
Notifications
You must be signed in to change notification settings - Fork 0
/
playerstates.inc
74 lines (64 loc) · 1.67 KB
/
playerstates.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
Player states Include (playerstates.inc)
* Gives player's current state, or status!
Author: (creator)
* Gammix
(c) Copyright 2015
* This file is provided as is (no warranties).
*/
/*
FUNCTIONS:
native IsPlayerSpawned(playerid);
native IsPlayerSpectating(playerid);
native IsPlayerDriver(playerid);
native IsPlayerInClassSelection(playerid);
native IsPlayerDead(playerid);
native IsPlayerInWater(playerid);
native IsPlayerAiming(playerid);
*/
stock IsPlayerSpawned(playerid)
{
switch(GetPlayerState(playerid))
{
case PLAYER_STATE_ONFOOT, PLAYER_STATE_DRIVER, PLAYER_STATE_PASSENGER, PLAYER_STATE_SPAWNED: return true;
default: return false;
}
return false;
}
stock IsPlayerSpectating(playerid)
{
if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING) return true;
return false;
}
stock IsPlayerDriver(playerid)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return true;
return false;
}
stock IsPlayerInClassSelection(playerid)
{
new Float: health = 0.0;
GetPlayerHealth(playerid, health);
if(GetPlayerState(playerid) == PLAYER_STATE_WASTED && health > 0.0) return true;
return false;
}
stock IsPlayerDead(playerid)
{
new Float: health = 0.0;
GetPlayerHealth(playerid, health);
if(GetPlayerState(playerid) == PLAYER_STATE_WASTED && health <= 0.0) return true;
return false;
}
stock IsPlayerInWater(playerid)
{
new anim = GetPlayerAnimationIndex(playerid);
if(((anim >= 1538) && (anim <= 1542)) || (anim == 1544) || (anim == 1250) || (anim == 1062)) return true;
return false;
}
stock IsPlayerAiming(playerid)
{
new keys, updown, leftright;
GetPlayerKeys(playerid, keys, updown, leftright);
if(keys & KEY_AIM) return true;
return false;
}