-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspg.inc
92 lines (75 loc) · 1.68 KB
/
spg.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
SetPlayerGravity
*/
#if defined _SPG_included
#endinput
#endif
#define _SPG_included
#if ! defined PAWNRAKNET_INC_
#error You must have Pawn.RakNet include in order to use this one.
#endif
#if !defined GetGravity
native Float:GetGravity();
#endif
static Float:SPG_PlayerGravity[MAX_PLAYERS];
/*Functions*/
stock SetPlayerGravity(playerid, Float:gravity)
{
if(!IsPlayerConnected(playerid)) return 0;
SPG_PlayerGravity[playerid] = gravity;
new BitStream:spg_bs = BS_New();
BS_WriteValue(
spg_bs,
PR_FLOAT, gravity
);
BS_RPC(spg_bs, playerid, 0x92);
BS_Delete(spg_bs);
return 1;
}
stock Float:GetPlayerGravity(playerid, &Float:gravity = 0.0)
{
if(!IsPlayerConnected(playerid)) return gravity;
return (gravity = SPG_PlayerGravity[playerid]);
}
/*Callbacks*/
public OnPlayerConnect(playerid)
{
SPG_PlayerGravity[playerid] = GetGravity();
#if defined SPG_OnPlayerConnect
return SPG_OnPlayerConnect(playerid);
#else
return 1;
#endif
}
public OnOutcomingRPC(playerid, rpcid, BitStream:bs)
{
if(rpcid == 0x92)
{
BS_ReadValue(bs, PR_FLOAT, SPG_PlayerGravity[playerid]);
BS_ResetReadPointer(bs);
}
#if defined SPG_OnOutcomingRPC
return SPG_OnOutcomingRPC(playerid, rpcid, bs);
#else
return 1;
#endif
}
/*Hooks*/
#if defined _ALS_OnOutcomingRPC
#undef OnOutcomingRPC
#else
#define _ALS_OnOutcomingRPC
#endif
#define OnOutcomingRPC SPG_OnOutcomingRPC
#if defined SPG_OnOutcomingRPC
forward SPG_OnOutcomingRPC(playerid, rpcid, BitStream:bs);
#endif
#if defined _ALS_OnPlayerConnect
#undef OnPlayerConnect
#else
#define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect SPG_OnPlayerConnect
#if defined SPG_OnPlayerConnect
forward SPG_OnPlayerConnect(playerid);
#endif