-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathweaponskill.inc
209 lines (169 loc) · 3.81 KB
/
weaponskill.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
About: weapon skill functions
Author: ziggi
*/
#if !defined _samp_included
#error "Please include a_samp or a_npc before weaponskill"
#endif
#if defined _weaponskill_included
#endinput
#endif
#define _weaponskill_included
/*
Defines
*/
#if !defined MAX_WEAPON_SKILL_LEVEL
#define MAX_WEAPON_SKILL_LEVEL 999
#endif
#if !defined MIN_WEAPON_SKILL_LEVEL
#define MIN_WEAPON_SKILL_LEVEL 0
#endif
#define MAX_WEAPON_SKILLS 10
#define INVALID_WEAPON_SKILL_ID -1
/*
Vars
*/
static const
gWeaponSkills[] = {
WEAPONSKILL_PISTOL, // 22
WEAPONSKILL_PISTOL_SILENCED, // 23
WEAPONSKILL_DESERT_EAGLE, // 24
WEAPONSKILL_SHOTGUN, // 25
WEAPONSKILL_SAWNOFF_SHOTGUN, // 26
WEAPONSKILL_SPAS12_SHOTGUN, // 27
WEAPONSKILL_MICRO_UZI, // 28
WEAPONSKILL_MP5, // 29
WEAPONSKILL_AK47, // 30
WEAPONSKILL_M4, // 31
WEAPONSKILL_MICRO_UZI // 32
};
static const
gSkillNames[MAX_WEAPON_SKILLS][15 char] = {
!"Pistol", // WEAPONSKILL_PISTOL
!"Pistol Silenced", // WEAPONSKILL_PISTOL_SILENCED
!"Desert Eagle", // WEAPONSKILL_DESERT_EAGLE
!"Shotgun", // WEAPONSKILL_SHOTGUN
!"Sawnoff Shotgun", // WEAPONSKILL_SAWNOFF_SHOTGUN
!"SPAS12 Shotgun", // WEAPONSKILL_SPAS12_SHOTGUN
!"Micro-UZI", // WEAPONSKILL_MICRO_UZI
!"MP5", // WEAPONSKILL_MP5
!"AK47", // WEAPONSKILL_AK47
!"M4" // WEAPONSKILL_M4
};
static
gPlayerWeaponSkill[MAX_PLAYERS][MAX_WEAPON_SKILLS];
/*
OnPlayerConnect
*/
public OnPlayerConnect(playerid)
{
for (new skill = 0; skill < sizeof(gPlayerWeaponSkill[]); skill++) {
gPlayerWeaponSkill[playerid][skill] = 999;
}
#if defined WS_OnPlayerConnect
return WS_OnPlayerConnect(playerid);
#else
return 1;
#endif
}
#if defined _ALS_OnPlayerConnect
#undef OnPlayerConnect
#else
#define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect WS_OnPlayerConnect
#if defined WS_OnPlayerConnect
forward WS_OnPlayerConnect(playerid);
#endif
/*
SetPlayerSkillLevel
*/
stock WS_SetPlayerSkillLevel(playerid, skill, level)
{
if (!(0 <= skill < MAX_WEAPON_SKILLS)) {
return 0;
}
if (level > MAX_WEAPON_SKILL_LEVEL) {
level = MAX_WEAPON_SKILL_LEVEL;
} else if (level < MIN_WEAPON_SKILL_LEVEL) {
level = MIN_WEAPON_SKILL_LEVEL;
}
gPlayerWeaponSkill[playerid][skill] = level;
return
SetPlayerSkillLevel(playerid, skill, level);
}
#if defined _ALS_SetPlayerSkillLevel
#undef SetPlayerSkillLevel
#else
#define _ALS_SetPlayerSkillLevel
#endif
#define SetPlayerSkillLevel WS_SetPlayerSkillLevel
/*
GetPlayerSkillLevel
*/
stock GetPlayerSkillLevel(playerid, skill)
{
if (!(0 <= skill < MAX_WEAPON_SKILLS)) {
return INVALID_WEAPON_SKILL_ID;
}
return gPlayerWeaponSkill[playerid][skill];
}
/*
GivePlayerSkillLevel
*/
stock GivePlayerSkillLevel(playerid, skill, amount)
{
if (!(0 <= skill < MAX_WEAPON_SKILLS)) {
return 0;
}
amount += GetPlayerSkillLevel(playerid, skill);
return
SetPlayerSkillLevel(playerid, skill, amount);
}
/*
GetPlayerSkillLevelArray
*/
stock GetPlayerSkillLevelArray(playerid, array[MAX_WEAPON_SKILLS])
{
array = gPlayerWeaponSkill[playerid];
}
/*
SetPlayerSkillLevelArray
*/
stock SetPlayerSkillLevelArray(playerid, const array[MAX_WEAPON_SKILLS])
{
gPlayerWeaponSkill[playerid] = array;
for (new skill = 0; skill < MAX_WEAPON_SKILLS; skill++) {
SetPlayerSkillLevel(playerid, skill, array[skill]);
}
}
/*
ResetPlayerSkillLevel
*/
stock ResetPlayerSkillLevel(playerid)
{
for (new skill = 0; skill < MAX_WEAPON_SKILLS; skill++) {
SetPlayerSkillLevel(playerid, skill, 0);
}
}
/*
GetWeaponSkillName
*/
stock GetWeaponSkillName(skill, name[], const size = sizeof(name))
{
if (!(0 <= skill < MAX_WEAPON_SKILLS)) {
return 0;
}
return strunpack(name, gSkillNames[skill], size);
}
/*
GetWeaponSkillID
*/
stock GetWeaponSkillID(weaponid)
{
new index = weaponid - 22;
if (!(0 <= index < sizeof(gWeaponSkills))) {
return INVALID_WEAPON_SKILL_ID;
}
return gWeaponSkills[index];
}