SHOW:
|
|
- or go back to the newest paste.
1 | /* | |
2 | s-Admin V1.5 Release | |
3 | ->About: | |
4 | s-Admin is a simple admin script with just the nessesary commands, why ? | |
5 | Well i like admin scripts clean and usefull, and not full of useless commands. | |
6 | ||
7 | It supports MYSQL, but also Y_INI so the users can decide for themself if they want to use | |
8 | textfiles or an online database. s-Admin also provides a dialogged GUI, the administrator can just | |
9 | doubleclick on a player in the scorelist and it will show up a dialog with several options. | |
10 | ||
11 | s-Admin also saves the player stats (like score,money) and includes an anti-jail/mute evade. | |
12 | ||
13 | ->Commands: | |
14 | Player (Level 0): | |
15 | Command: Parameters: Explaination: | |
16 | /admins none Lists all online administrator | |
17 | /changepassword [oldpassword] [newpassword] Allows the player to change his password | |
18 | /stats none Rettreive's playerstats | |
19 | /whois [playerid] Rettreive information about given playerid | |
20 | /whowas [playername] Rettreive information about given playername | |
21 | /report [playerid] [reason] Reports another player (this will be shown to online admins and in Rcon console) | |
22 | ||
23 | Moderator (Level 1): | |
24 | Command: Parameters: Explaination: | |
25 | /acmds none Shows all admin commands | |
26 | /a [text] Adminchat | |
27 | /announce [text] Announce a message | |
28 | /spectate [playerid] Spectate player | |
29 | /stop none Stops spectating player | |
30 | /disarm [playerid] Resets player weapons of playerid | |
31 | /mute [playerid] [reason (optional)] Mutes player | |
32 | /unmute [playerid] Unmutes player | |
33 | /freeze [playerid] [reason (optional)] Freezes player | |
34 | /unfreeze [playerid] Unfreezes player | |
35 | /jail [playerid] [reason (optional)] Jails player | |
36 | /unjail [playerid] Unjails player | |
37 | /kick [playerid] [reason (optional)] Kicks player | |
38 | ||
39 | Administrator (Level 2): | |
40 | Command: Parameters: Explaination: | |
41 | /veh [vehiclename] Spawns a vehicle for the admin | |
42 | /get [playerid] Teleports given playerid to the admin | |
43 | /goto [playerid] Teleports admin to the given playerid | |
44 | /giveweapon [playerid][weaponid][ammo] Gives weapon to given playerid | |
45 | /setmoney [playerid][ammount] Changes money of playerid | |
46 | /setscore [playerid][ammount] Changes score of playerid | |
47 | /explode [playerid] Explodes playerid | |
48 | /ban [playerid] [reason (optional)] Bans the playerid | |
49 | /banip [ip] Bans the given IP | |
50 | /annoy [playerid] Releases a cow on the player! (Known from Hiddos's annoying cow script) | |
51 | /catchcow Removes released cow | |
52 | ||
53 | Owner (Level 3): | |
54 | Command: Parameters: Explaination: | |
55 | /setlevel [playerid][level] Adjust the rights of the player (Level 0/3) | |
56 | /unbanip [ip] Unbans the given IP | |
57 | ||
58 | ||
59 | ->Credits: | |
60 | Hiddos for his annoying cow script | |
61 | Zeex for ZCMD | |
62 | Y_Less for sscanf2 | |
63 | Y_Less for Y_INI | |
64 | G-sTyLeZzZ for his MYSQL Plugin | |
65 | ||
66 | ->Changelog: | |
67 | 1b: | |
68 | - /stats colors are better | |
69 | - /admins colors are better | |
70 | - adminchat has now a space | |
71 | 1c: | |
72 | - You cannot click on yourself in the scorelist anymore | |
73 | - /countdown command added | |
74 | - /veh has been optimised | |
75 | - /giveweapon is now using weapon names instead of ID's | |
76 | - s-Admin is now using gLibrary 1.1 | |
77 | 1.1: | |
78 | - Optimised code (using gLibrary 1.2) and better colors | |
79 | - s-Admin now also saves IP | |
80 | - passwords will now be hashed with WhirlPool | |
81 | - /whois is now public | |
82 | - /whowas added | |
83 | 1.2: | |
84 | - Returns fixed | |
85 | - Colors changed again (looks much better now) | |
86 | - Some VERY important security issues fixed (logging in) | |
87 | - Return problem fixed (compability with other scripts using dialogs) | |
88 | 1.3: | |
89 | - System uses new gLibrary (problem solved with OnPlayerDisconnect) | |
90 | 1.4 | |
91 | - /veh has been fixed | |
92 | - /report has been fixed | |
93 | 1.5 | |
94 | - gLibrary has been updated fixing the chat bug | |
95 | - login dialog for existing users is now using password dialog style | |
96 | */ | |
97 | #include <a_samp> | |
98 | #include <sscanf2> | |
99 | #include <zcmd> | |
100 | #include <gLibrary> | |
101 | native WP_Hash(buffer[], len, const str[]); | |
102 | //================================================================================================================ | |
103 | //------------------Settings------------------ | |
104 | #define USE_MYSQL_DATABASE false //if defined false, it will use Y_INI (text files) instead | |
105 | ||
106 | #define MAX_LOGIN_ATTEMPTS 3 //maximum login attempts before kick | |
107 | #define DIALOG_RANGE 100 //dialog range (100 by default, will use dialogid's 100-104) | |
108 | ||
109 | #define ALLOW_ANNOY true //allow administrators so release a crazy cow on players! | |
110 | #define ALLOW_ADMINS true //you can turn this off if you dont want to allow players using /admins to see if there is an admin online | |
111 | #define ALLOW_VEH true //allows admins to spawn vehicles | |
112 | //----------------SQL Settings---------------- //only needs to be set when you use mysql db | |
113 | #define HOST "localhost" | |
114 | #define USER "root" | |
115 | #define DB "s-admin" | |
116 | #define PASS "" | |
117 | ||
118 | //================================================================================================================ | |
119 | //ignore these | |
120 | #define abs(%0) ((%0) >= 0 ? (%0) : -(%0)) | |
121 | new cow_victim = -1, object_cow, movecow_timer; | |
122 | #if USE_MYSQL_DATABASE == true | |
123 | #include <yoursql> | |
124 | #else | |
125 | #define MAX_INI_ENTRY_TEXT 129 | |
126 | #include <YSI/y_ini> | |
127 | #endif | |
128 | #define color_red gCOLOR_RED | |
129 | #define color_green gCOLOR_GREEN | |
130 | #define color_gray gCOLOR_GRAY | |
131 | #define color_orange gCOLOR_ORANGE | |
132 | #define color_blue 0xADD8E6FF | |
133 | #define color_yellow gCOLOR_YELLOW | |
134 | #define DIALOG_REGISTER DIALOG_RANGE | |
135 | #define DIALOG_LOGIN DIALOG_RANGE +1 | |
136 | #define DIALOG_CHANGENICK DIALOG_RANGE +2 | |
137 | #define DIALOG_REPORT DIALOG_RANGE +3 | |
138 | #define DIALOG_ADMIN DIALOG_RANGE +4 | |
139 | ||
140 | enum gPlayerInfo | |
141 | { | |
142 | Username[32], | |
143 | Password[129], | |
144 | Muted, | |
145 | Jailed, | |
146 | Score, | |
147 | Money, | |
148 | Level, | |
149 | Ip[32] | |
150 | } | |
151 | new PlayerInfo[MAX_PLAYERS][gPlayerInfo]; | |
152 | ||
153 | enum gTempInfo | |
154 | { | |
155 | Username[32], | |
156 | Password[129], | |
157 | Muted, | |
158 | Jailed, | |
159 | Score, | |
160 | Money, | |
161 | Level, | |
162 | Ip[32] | |
163 | } | |
164 | new TempInfo[gPlayerInfo]; | |
165 | ||
166 | new UpdateSpectateTimer[MAX_PLAYERS]; | |
167 | new bool:CountDownInProgress = false; | |
168 | new countdown_counter = 5; | |
169 | ||
170 | //================================================================================================================ | |
171 | //basic script | |
172 | public OnFilterScriptInit() | |
173 | { | |
174 | print("\n--------------------------------------"); | |
175 | print(" Gamer's admin script V1.5 "); | |
176 | print("--------------------------------------\n"); | |
177 | #if USE_MYSQL_DATABASE == true | |
178 | yoursql_connect(HOST,USER,DB,PASS); | |
179 | #endif | |
180 | for(new i = 0;i<MAX_PLAYERS;i++) | |
181 | { | |
182 | if(!IsPlayerConnected(i)) continue; | |
183 | OnPlayerConnect(i); | |
184 | } | |
185 | return 1; | |
186 | } | |
187 | ||
188 | public OnFilterScriptExit() | |
189 | { | |
190 | for(new i = 0;i<MAX_PLAYERS;i++) | |
191 | { | |
192 | if(!IsPlayerConnected(i)) continue; | |
193 | SaveUser(i); | |
194 | } | |
195 | #if USE_MYSQL_DATABASE == true | |
196 | yoursql_close(); | |
197 | #endif | |
198 | return 1; | |
199 | } | |
200 | ||
201 | public OnPlayerConnect(playerid) | |
202 | { | |
203 | format(PlayerInfo[playerid][Username],32," "); | |
204 | format(PlayerInfo[playerid][Password],32," "); | |
205 | PlayerInfo[playerid][Level] = 0; | |
206 | new pName[MAX_PLAYER_NAME],string[96];GetPlayerName(playerid,pName,sizeof pName); | |
207 | if(IsPlayerNPC(playerid)) return 1; | |
208 | #if USE_MYSQL_DATABASE == true | |
209 | format(string,sizeof string,"SELECT * FROM users WHERE Username = '%s'",yoursql_escape_string(pName)); | |
210 | if(yoursql_countrows(string) == 0) | |
211 | { | |
212 | ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Account registration","You need to register in order to play on this server! Please fill in a password.","Register","Quit"); | |
213 | } else { | |
214 | LoadUser(playerid,pName); | |
215 | ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Account registration","This account is registered! Please fill in a password to join.","Login","Change name"); | |
216 | SetPVarInt(playerid,"attempt",0); | |
217 | } | |
218 | #else | |
219 | format(string,sizeof string,"Users/%s.ini",pName); | |
220 | if(!fexist(string)) | |
221 | { | |
222 | ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Account registration","You need to register in order to play on this server! Please fill in a password.","Register","Quit"); | |
223 | } else { | |
224 | LoadUser(playerid,pName); | |
225 | ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Account registration","This account is registered! Please fill in a password to join.","Login","Change name"); | |
226 | SetPVarInt(playerid,"attempt",0); | |
227 | } | |
228 | #endif | |
229 | return 1; | |
230 | } | |
231 | public OnPlayerSpawn(playerid) | |
232 | { | |
233 | if(PlayerInfo[playerid][Jailed] == 1) | |
234 | { | |
235 | SendClientMessageToAllEx(color_red,"ss",PlayerInfo[playerid][Username]," is automaticly jailed (Jail evade)."); | |
236 | SetTimerEx("JailOnSpawnDelay",1000,false,"i",playerid); | |
237 | } else if (PlayerInfo[playerid][Muted] == 1){ | |
238 | SendClientMessageToAllEx(color_red,"ss",PlayerInfo[playerid][Username]," is automaticly muted (Mute evade)."); | |
239 | } | |
240 | return 1; | |
241 | } | |
242 | forward JailOnSpawnDelay(playerid); | |
243 | public JailOnSpawnDelay(playerid) | |
244 | { | |
245 | JailPlayer(playerid); | |
246 | } | |
247 | ||
248 | public OnPlayerDisconnect(playerid, reason) | |
249 | { | |
250 | if(!IsPlayerNPC(playerid)) | |
251 | { | |
252 | SaveUser(playerid); | |
253 | if(cow_victim == playerid) | |
254 | { | |
255 | StopAnnoying(); | |
256 | } | |
257 | } | |
258 | return 1; | |
259 | } | |
260 | ||
261 | public OnPlayerClickPlayer(playerid, clickedplayerid, source) | |
262 | { | |
263 | if(playerid == clickedplayerid) return SendClientMessage(playerid,color_red,"You cannot open the usermenu for yourself!"); | |
264 | SetPVarInt(playerid,"selectedid",clickedplayerid); | |
265 | switch(PlayerInfo[playerid][Level]) | |
266 | { | |
267 | case 0:{ | |
268 | if(!IsPlayerAdmin(playerid)) | |
269 | { | |
270 | ShowPlayerDialog(playerid,DIALOG_REPORT,DIALOG_STYLE_INPUT,"Report player","Please fill in a valid reason:","OK","Cancel"); | |
271 | } else ShowPlayerDialog(playerid,DIALOG_ADMIN,DIALOG_STYLE_LIST,"Administrator menu","Spectate\nDisarm\nMute\nUnmute\nFreeze\nUnfreeze\nJail\nUnjail\nKick\nGet\nGoto\nAnnoy\nBan","OK","Cancel"); | |
272 | } | |
273 | case 1:ShowPlayerDialog(playerid,DIALOG_ADMIN,DIALOG_STYLE_LIST,"Moderator menu","Spectate\nDisarm\nMute\nUnmute\nFreeze\nUnfreeze\nJail\nUnjail\nKick","OK","Cancel"); | |
274 | case 2,3:ShowPlayerDialog(playerid,DIALOG_ADMIN,DIALOG_STYLE_LIST,"Administrator menu","Spectate\nDisarm\nMute\nUnmute\nFreeze\nUnfreeze\n\nJail\nUnjail\nKick\nGet\nGoto\nAnnoy\nBan","OK","Cancel"); | |
275 | } | |
276 | return 1; | |
277 | } | |
278 | ||
279 | //================================================================================================================ | |
280 | //dialog handler | |
281 | public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) | |
282 | { | |
283 | switch(dialogid) | |
284 | { | |
285 | case(DIALOG_REGISTER): | |
286 | { | |
287 | if(!response) | |
288 | { | |
289 | SendClientMessageToAllEx(color_gray,"ss",PlayerInfo[playerid][Username]," has been kicked by the server (Quit at registration)."); | |
290 | Kick(playerid); | |
291 | } | |
292 | OnPlayerRegister(playerid,inputtext); | |
293 | } | |
294 | ||
295 | case(DIALOG_LOGIN): | |
296 | { | |
297 | if(!response) return ShowPlayerDialog(playerid,DIALOG_CHANGENICK,DIALOG_STYLE_INPUT,"Account registration","Please fill in a nickname:","OK","Quit"); | |
298 | if(GetPVarInt(playerid,"attempt") == MAX_LOGIN_ATTEMPTS) | |
299 | { | |
300 | SendClientMessageToAllEx(color_gray,"ss",PlayerInfo[playerid][Username]," has been kicked by the server (Failed to login)."); | |
301 | Kick(playerid); | |
302 | } else { | |
303 | if(!strlen(inputtext)) | |
304 | { | |
305 | SendClientMessageEx(playerid,color_red,"sisis","You have failed to login (attempt ",GetPVarInt(playerid,"attempt") +1,"/",MAX_LOGIN_ATTEMPTS,")."); | |
306 | ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Account registration","This account is registered! Please fill in a password to join.","Login","Change username"); | |
307 | SetPVarInt(playerid,"attempt",GetPVarInt(playerid,"attempt") +1); | |
308 | printf("%s failed to login (attempt %i/%i).",PlayerInfo[playerid][Username],GetPVarInt(playerid,"attempt"),MAX_LOGIN_ATTEMPTS); | |
309 | } | |
310 | new buffer[129];WP_Hash(buffer,sizeof buffer,inputtext); | |
311 | if(!strcmp(buffer,PlayerInfo[playerid][Password])) | |
312 | { | |
313 | if(PlayerInfo[playerid][Level] > 0) | |
314 | { | |
315 | SendClientMessageEx(playerid,color_green,"sis","You have succesfully logged in as level ",PlayerInfo[playerid][Level]," admin!"); | |
316 | } else SendClientMessage(playerid,color_green,"You have succesfully logged in."); | |
317 | SendClientMessageToAllEx(color_green,"ss",PlayerInfo[playerid][Username]," has logged in, welcome back!"); | |
318 | printf("%s has logged in.",PlayerInfo[playerid][Username]); | |
319 | } else { | |
320 | SendClientMessageEx(playerid,color_red,"sisis","You have failed to login (attempt ",GetPVarInt(playerid,"attempt") +1,"/",MAX_LOGIN_ATTEMPTS,")."); | |
321 | ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Account registration","This account is registered! Please fill in a password to join.","Login","Change username"); | |
322 | SetPVarInt(playerid,"attempt",GetPVarInt(playerid,"attempt") +1); | |
323 | printf("%s failed to login (attempt %i/%i).",PlayerInfo[playerid][Username],GetPVarInt(playerid,"attempt"),MAX_LOGIN_ATTEMPTS); | |
324 | } | |
325 | } | |
326 | } | |
327 | ||
328 | case(DIALOG_CHANGENICK): | |
329 | { | |
330 | if(!response) | |
331 | { | |
332 | SendClientMessageToAllEx(color_gray,"ss",PlayerInfo[playerid][Username]," has been kicked by the server (Quit at registration)."); | |
333 | Kick(playerid); | |
334 | } | |
335 | if(!strlen(inputtext)) | |
336 | { | |
337 | SendClientMessage(playerid,color_red,"Account registration: Please fill in a valid username!"); | |
338 | ShowPlayerDialog(playerid,DIALOG_CHANGENICK,DIALOG_STYLE_INPUT,"Account registration","Please fill in a nickname:","OK","Quit"); | |
339 | } | |
340 | SetPlayerName(playerid,inputtext); | |
341 | OnPlayerConnect(playerid); | |
342 | } | |
343 | case(DIALOG_REPORT): | |
344 | { | |
345 | if(!response) return 1; | |
346 | new id = GetPVarInt(playerid,"selectedid"); | |
347 | new reason[64];format(reason,sizeof reason,"%s",inputtext); | |
348 | if(!strlen(reason)) return SendClientMessage(playerid,color_red,"No valid reason."); | |
349 | new counter = 0;for(new i = 0;i<MAX_PLAYERS;i++) | |
350 | { | |
351 | if(!IsPlayerConnected(i)) continue; | |
352 | if(PlayerInfo[i][Level] > 0) | |
353 | { | |
354 | SendClientMessageEx(i,color_orange,"sssisssisss","Incomming report from ",PlayerInfo[playerid][Username],"(",playerid,") Reporting ",PlayerInfo[id][Username],"(",id,"), Reason: ",reason,"."); | |
355 | counter++; | |
356 | } | |
357 | } | |
358 | printf("%s has reported %s (Reason:%s)",PlayerInfo[playerid][Username],PlayerInfo[id][Username],reason); | |
359 | return SendClientMessageEx(playerid,color_orange,"sis","Your report has been sent to all online administrators (",counter," at the moment)."); | |
360 | } | |
361 | case(DIALOG_ADMIN): | |
362 | { | |
363 | if(!response) return 1; | |
364 | new id = GetPVarInt(playerid,"selectedid"); | |
365 | switch(listitem) | |
366 | { | |
367 | case 0://spectate | |
368 | { | |
369 | if(GetPVarInt(playerid,"spectating") == 1) return SendClientMessage(playerid,color_red,"You are already spectating! Please use /stop to turn spectatemode off."); | |
370 | TogglePlayerSpectating(playerid,1); | |
371 | SetPVarInt(playerid,"spectating",1); | |
372 | if(IsPlayerInAnyVehicle(id)) | |
373 | { | |
374 | SetPVarInt(playerid,"state",1); | |
375 | PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id)); | |
376 | } else { | |
377 | SetPVarInt(playerid,"state",0); | |
378 | PlayerSpectatePlayer(playerid,id); | |
379 | } | |
380 | UpdateSpectateTimer[playerid] = SetTimerEx("UpdateAdminSpectate",1000,true,"ii",playerid,id); | |
381 | return SendClientMessageEx(playerid,color_green,"sss","You are now spectating ",PlayerInfo[id][Username]," . You can use /stop to switch back to normal mode."); | |
382 | } | |
383 | case 1: //disarm | |
384 | { | |
385 | ResetPlayerWeapons(id); | |
386 | return SendClientMessageToAllEx(color_red,"ssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} disarmed ",PlayerInfo[id][Username],"."); | |
387 | } | |
388 | case 2://mute | |
389 | { | |
390 | if(PlayerInfo[id][Muted] == 1) return SendClientMessage(playerid,color_red,"Player is already muted!"); | |
391 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} muted ",PlayerInfo[id][Username],"."); | |
392 | PlayerInfo[id][Muted] = 1; | |
393 | return MutePlayer(id); | |
394 | } | |
395 | case 3://unmute | |
396 | { | |
397 | if(PlayerInfo[id][Muted] == 0) return SendClientMessage(playerid,color_red,"Player is not muted!"); | |
398 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} unmuted ",PlayerInfo[id][Username],"."); | |
399 | PlayerInfo[id][Muted] = 0; | |
400 | return UnMutePlayer(id); | |
401 | } | |
402 | case 4://freeze | |
403 | { | |
404 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} froze ",PlayerInfo[id][Username],"."); | |
405 | return TogglePlayerControllable(id,0); | |
406 | } | |
407 | case 5://unfreeze | |
408 | { | |
409 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} unfroze ",PlayerInfo[id][Username],"."); | |
410 | return TogglePlayerControllable(id,1); | |
411 | } | |
412 | case 6://jail | |
413 | { | |
414 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} jailed ",PlayerInfo[id][Username],"."); | |
415 | PlayerInfo[id][Jailed] = 1; | |
416 | return JailPlayer(id); | |
417 | } | |
418 | case 7: //unjail | |
419 | { | |
420 | if(PlayerInfo[id][Jailed] == 0) return SendClientMessage(playerid,color_red,"Player is not jailed!"); | |
421 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} unjailed ",PlayerInfo[id][Username],"."); | |
422 | PlayerInfo[id][Jailed] = 0; | |
423 | return UnJailPlayer(id); | |
424 | } | |
425 | case 8://kick | |
426 | { | |
427 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} kicked ",PlayerInfo[id][Username],"."); | |
428 | return Kick(id); | |
429 | } | |
430 | case 9://get | |
431 | { | |
432 | new Float:x,Float:y,Float:z;GetPlayerPos(playerid,x,y,z);x = x +2; | |
433 | SetPlayerPos(id,x,y,z); | |
434 | SendClientMessageEx(playerid,color_green,"sss","You have teleported ",PlayerInfo[id][Username]," to your position!"); | |
435 | return SendClientMessageEx(id,color_green,"sss","Administrator ",PlayerInfo[playerid][Username]," has teleported you to his position!"); | |
436 | } | |
437 | case 10://goto | |
438 | { | |
439 | new Float:x,Float:y,Float:z;GetPlayerPos(id,x,y,z);x = x +2; | |
440 | SetPlayerPos(playerid,x,y,z); | |
441 | return SendClientMessageEx(playerid,color_red,"sss","You have teleported to ",PlayerInfo[id][Username],"'s position!"); | |
442 | } | |
443 | case 11://annoy | |
444 | { | |
445 | if(cow_victim != -1) return SendClientMessage(playerid,color_red,"Sorry! It seems like your cow has already been stolen by another administrator."); | |
446 | #if ALLOW_ANNOY == false | |
447 | return SendClientMessage(playerid,color_red,"Sorry! This feature has been disabled."); | |
448 | #else | |
449 | AnnoyPlayer(id); | |
450 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} has released his cow on ",PlayerInfo[id][Username]," !!!"); | |
451 | return SendClientMessageEx(playerid,color_green,"sss","You have released your cow on ",PlayerInfo[id][Username],"! please use /catchcow to bring him back."); | |
452 | #endif | |
453 | } | |
454 | case 12://ban | |
455 | { | |
456 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} banned ",PlayerInfo[id][Username],"."); | |
457 | return Ban(id); | |
458 | } | |
459 | } | |
460 | } | |
461 | } | |
462 | return 0; | |
463 | } | |
464 | //================================================================================================================ | |
465 | //Player commands: | |
466 | COMMAND:in(playerid,params[]) | |
467 | { | |
468 | return SendClientMessageEx(playerid,gCOLOR_RED,"sf","Speed: ",GetVehicleSpeed(GetPlayerVehicleID(playerid),0)); | |
469 | } | |
470 | ||
471 | COMMAND:test(playerid,params[]) | |
472 | { | |
473 | return PutPlayerInVehicle(playerid,GetClosestVehicleForPlayer(playerid),0); | |
474 | } | |
475 | ||
476 | COMMAND:reconnect(playerid,params[]) | |
477 | { | |
478 | SendClientMessage(playerid,gCOLOR_RED,"You will now be reconnected to the server, DO NOT LEAVE!"); | |
479 | SetPlayerToReconnect(playerid); | |
480 | return 1; | |
481 | } | |
482 | COMMAND:changepassword(playerid,params[]) | |
483 | { | |
484 | new oldpass[129],newpass[129]; | |
485 | if(sscanf(params,"s[32]s[32]",oldpass,newpass)) return SendClientMessage(playerid,color_red,"USAGE: /changepassword [oldpassword] [newpassword]"); | |
486 | WP_Hash(oldpass,sizeof oldpass,oldpass); | |
487 | if(strcmp(PlayerInfo[playerid][Password],oldpass)) return SendClientMessage(playerid,color_red,"ERROR! Your current password does not match with your entered password!"); | |
488 | #if USE_MYSQL_DATABASE == true | |
489 | WP_Hash(PlayerInfo[playerid][Password],129,newpass); | |
490 | #else | |
491 | WP_Hash(PlayerInfo[playerid][Password],129,newpass); | |
492 | #endif | |
493 | SaveUser(playerid); | |
494 | return SendClientMessage(playerid,color_green,"Your password has succesfully been changed."); | |
495 | } | |
496 | COMMAND:stats(playerid,params[]) | |
497 | { | |
498 | SendClientMessage(playerid,color_green,"Your current stats:"); | |
499 | SendClientMessageEx(playerid,color_yellow,"sis","Score: ",GetPlayerScore(playerid),"."); | |
500 | SendClientMessageEx(playerid,color_yellow,"sis","Money: ",GetPlayerMoney(playerid),"."); | |
501 | return 1; | |
502 | } | |
503 | ||
504 | COMMAND:whois(playerid,params[]) | |
505 | { | |
506 | new id; | |
507 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /whois [playerid]"); | |
508 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
509 | SendClientMessageEx(playerid,color_orange,"sis","Who is ID ",id,"."); | |
510 | SendClientMessageEx(playerid,color_yellow,"sss","Username: {FFFFFF}",PlayerInfo[id][Username],"."); | |
511 | switch(PlayerInfo[id][Level]) | |
512 | { | |
513 | case 0:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Player."); | |
514 | case 1:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Moderator."); | |
515 | case 2:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Administrator."); | |
516 | case 3:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Server owner."); | |
517 | } | |
518 | SendClientMessageEx(playerid,color_yellow,"sis","Score: ",GetPlayerScore(id),"."); | |
519 | SendClientMessageEx(playerid,color_yellow,"sis","Money: ",GetPlayerMoney(id),"."); | |
520 | SendClientMessageEx(playerid,color_yellow,"sss","IP: ",GetPlayerIpEx(id),"."); | |
521 | return 1; | |
522 | } | |
523 | ||
524 | COMMAND:whowas(playerid,params[]) | |
525 | { | |
526 | new pName[MAX_PLAYER_NAME]; | |
527 | if(sscanf(params,"s[32]",pName)) return SendClientMessage(playerid,color_red,"USAGE: /whowas [playername]"); | |
528 | ||
529 | #if USE_MYSQL_DATABASE == true | |
530 | new query[128];format(query,sizeof query,"SELECT * FROM users WHERE Username = '%s'",pName); | |
531 | if(yoursql_countrows(query) != 1) return SendClientMessage(playerid,color_red,"User not found in our database!"); | |
532 | format(query,sizeof query,"Username = '%s'",pName); | |
533 | sscanf(yoursql_receive("users",query),"p<|>e<s[32]s[129]iiiiis[32]>",TempInfo); | |
534 | #else | |
535 | new file[64];format(file,sizeof file,"Users/%s.ini",pName); | |
536 | if(!fexist(file)) return SendClientMessage(playerid,color_red,"User not found in our database!"); | |
537 | INI_ParseFile(file, "YINI_TEMPLOAD", .bExtra = true, .extra = playerid); | |
538 | #endif | |
539 | ||
540 | SendClientMessageEx(playerid,color_orange,"sss","Who was ",pName,"."); | |
541 | SendClientMessageEx(playerid,color_yellow,"sss","Username: {FFFFFF}",TempInfo[Username],"."); | |
542 | switch(TempInfo[Level]) | |
543 | { | |
544 | case 0:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Player."); | |
545 | case 1:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Moderator."); | |
546 | case 2:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Administrator."); | |
547 | case 3:SendClientMessage(playerid,color_yellow,"Level: {FFFFFF}Server owner."); | |
548 | } | |
549 | SendClientMessageEx(playerid,color_yellow,"sis","Score: ",TempInfo[Score],"."); | |
550 | SendClientMessageEx(playerid,color_yellow,"sis","Money: ",TempInfo[Money],"."); | |
551 | SendClientMessageEx(playerid,color_yellow,"sss","IP: ",TempInfo[Ip],"."); | |
552 | format(TempInfo[Username],32," "); | |
553 | format(TempInfo[Password],192," "); | |
554 | format(TempInfo[Muted],32," "); | |
555 | format(TempInfo[Jailed],32," "); | |
556 | format(TempInfo[Score],32," "); | |
557 | format(TempInfo[Money],32," "); | |
558 | format(TempInfo[Level],32," "); | |
559 | format(TempInfo[Ip],32," "); | |
560 | return 1; | |
561 | } | |
562 | forward YINI_TEMPLOAD(playerid,Name[],Value[]); | |
563 | public YINI_TEMPLOAD(playerid,Name[],Value[]) | |
564 | { | |
565 | if(!strcmp(Name,"Username")){format(TempInfo[Username],32,"%s",Value);} | |
566 | if(!strcmp(Name,"Score")){TempInfo[Score] = strval(Value);} | |
567 | if(!strcmp(Name,"Money")){TempInfo[Money] = strval(Value);} | |
568 | if(!strcmp(Name,"Level")){TempInfo[Level] = strval(Value);} | |
569 | if(!strcmp(Name,"Ip")){format(TempInfo[Ip],32,"%s",Value);} | |
570 | return 1; | |
571 | } | |
572 | ||
573 | COMMAND:report(playerid,params[]) | |
574 | { | |
575 | new id,reason[64]; | |
576 | if(sscanf(params,"is[64]",id,reason)) return SendClientMessage(playerid,color_red,"USAGE: /report [playerid] [reason]"); | |
577 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
578 | new counter = 0;for(new i = 0;i<MAX_PLAYERS;i++) | |
579 | { | |
580 | if(!IsPlayerConnected(i)) continue; | |
581 | if(PlayerInfo[i][Level] > 0) | |
582 | { | |
583 | SendClientMessageEx(i,color_orange,"sssisssisss","Incomming report from ",PlayerInfo[playerid][Username],"(",playerid,") Reporting ",PlayerInfo[id][Username],"(",id,"), Reason: ",reason,"."); | |
584 | counter++; | |
585 | } | |
586 | } | |
587 | printf("%s has reported %s (Reason:%s)",PlayerInfo[playerid][Username],PlayerInfo[id][Username],reason); | |
588 | return SendClientMessageEx(playerid,color_orange,"sis","Your report has been sent to all online administrators (",counter," at the moment)."); | |
589 | } | |
590 | COMMAND:admins(playerid,params[]) | |
591 | { | |
592 | #if ALLOW_ADMINS == false | |
593 | return SendClientMessage(playerid,color_red,"Sorry! This feature has been disabled."); | |
594 | #else | |
595 | new counter = 0; | |
596 | SendClientMessage(playerid,color_green,"Online admins:"); | |
597 | for(new i = 0;i<MAX_PLAYERS;i++) | |
598 | { | |
599 | if(!IsPlayerConnected(i)) continue; | |
600 | if(PlayerInfo[i][Level] > 0) | |
601 | { | |
602 | SendClientMessageEx(playerid,color_orange,"s",PlayerInfo[i][Username]); | |
603 | counter++; | |
604 | } | |
605 | } | |
606 | if(counter == 0) | |
607 | { | |
608 | SendClientMessage(playerid,color_red,"There are no admins online!"); | |
609 | } | |
610 | return 1; | |
611 | #endif | |
612 | } | |
613 | ||
614 | COMMAND:acmds(playerid,params[]) | |
615 | { | |
616 | if(PlayerInfo[playerid][Level] == 0) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
617 | SendClientMessage(playerid,color_orange,"Moderator (Level 1 and up):"); | |
618 | SendClientMessage(playerid,color_yellow,"/a /countdown /whois /announce /spectate /disarm /(un)mute /(un)freeze /(un)jail /kick"); | |
619 | SendClientMessage(playerid,color_orange,"Administrator (Level 2 and up):"); | |
620 | SendClientMessage(playerid,color_yellow,"/veh /get /goto /giveweapon /setmoney /setscore /explode /ban /banip /annoy"); | |
621 | SendClientMessage(playerid,color_orange,"Owner (Level 3):"); | |
622 | SendClientMessage(playerid,color_yellow,"/setlevel /unbanip"); | |
623 | return 1; | |
624 | } | |
625 | ||
626 | //================================================================================================================ | |
627 | //Moderator commands | |
628 | COMMAND:a(playerid,params[]) | |
629 | { | |
630 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
631 | new text[128]; | |
632 | if(sscanf(params,"s[128]",text)) return SendClientMessage(playerid,color_red,"USAGE: /a [text]"); | |
633 | for(new i = 0;i<MAX_PLAYERS;i++) | |
634 | { | |
635 | if(!IsPlayerConnected(i)) continue; | |
636 | if(PlayerInfo[i][Level] < 1) continue; | |
637 | SendClientMessageEx(i,color_yellow,"ssss","Adminchat: ",PlayerInfo[playerid][Username],": {FFFFFF}",text); | |
638 | } | |
639 | return 1; | |
640 | } | |
641 | ||
642 | COMMAND:countdown(playerid,params[]) | |
643 | { | |
644 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
645 | if(CountDownInProgress == true) return SendClientMessage(playerid,color_red,"There is already a countdown in progress!"); | |
646 | CountDownInProgress = true; | |
647 | SetTimer("countdown",1000,false); | |
648 | SendClientMessageToAllEx(color_red,"sss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} has started a countdown!"); | |
649 | return 1; | |
650 | } | |
651 | forward countdown(); | |
652 | public countdown() | |
653 | { | |
654 | if(countdown_counter == 0){countdown_counter = 5;CountDownInProgress = false;return GameTextForAll("GO GO GO!",1000,6);} | |
655 | new str[32];format(str,sizeof str,"~g~%i",countdown_counter); | |
656 | GameTextForAll(str,1000,6); | |
657 | countdown_counter--; | |
658 | return SetTimer("countdown",1000,false); | |
659 | } | |
660 | ||
661 | ||
662 | COMMAND:announce(playerid,params[]) | |
663 | { | |
664 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
665 | new msg[128]; | |
666 | if(sscanf(params,"s",msg)) return SendClientMessage(playerid,color_red,"USAGE: /announce [text]"); | |
667 | SendClientMessageToAllEx(color_yellow,"ss","ANNOUNCEMENT: ",msg); | |
668 | return GameTextForAll(msg,5000,4); | |
669 | } | |
670 | COMMAND:spectate(playerid,params[]) | |
671 | { | |
672 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
673 | new id; | |
674 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /spectate [id]"); | |
675 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
676 | if(id == playerid) return SendClientMessage(playerid,color_red,"You cannot spectate yourself!"); | |
677 | if(GetPVarInt(playerid,"spectating") == 1) return SendClientMessage(playerid,color_red,"You are already spectating! Please use /stop to turn spectatemode off."); | |
678 | TogglePlayerSpectating(playerid,1); | |
679 | SetPVarInt(playerid,"spectating",1); | |
680 | if(IsPlayerInAnyVehicle(id)) | |
681 | { | |
682 | SetPVarInt(playerid,"state",1); | |
683 | PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id)); | |
684 | } else { | |
685 | SetPVarInt(playerid,"state",0); | |
686 | PlayerSpectatePlayer(playerid,id); | |
687 | } | |
688 | UpdateSpectateTimer[playerid] = SetTimerEx("UpdateAdminSpectate",1000,true,"ii",playerid,id); | |
689 | return SendClientMessageEx(playerid,color_green,"sss","You are now spectating ",PlayerInfo[id][Username]," . You can use /stop to switch back to normal mode."); | |
690 | } | |
691 | forward UpdateAdminSpectate(playerid,id); | |
692 | public UpdateAdminSpectate(playerid,id) | |
693 | { | |
694 | if(GetPVarInt(playerid,"state") == 1 && !IsPlayerInAnyVehicle(id)) | |
695 | { | |
696 | PlayerSpectatePlayer(playerid,id); | |
697 | SetPVarInt(playerid,"state",0); | |
698 | } else if (GetPVarInt(playerid,"state") == 0 && IsPlayerInAnyVehicle(id)) { | |
699 | PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id)); | |
700 | SetPVarInt(playerid,"state",1); | |
701 | } | |
702 | } | |
703 | ||
704 | COMMAND:stop(playerid,params[]) | |
705 | { | |
706 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
707 | if(GetPVarInt(playerid,"spectating") == 0) return SendClientMessage(playerid,color_red,"You are not spectating a player! use /spectate [ID] to spectate a player."); | |
708 | TogglePlayerSpectating(playerid,0); | |
709 | SetPVarInt(playerid,"spectating",0); | |
710 | KillTimer(UpdateSpectateTimer[playerid]); | |
711 | return 1; | |
712 | } | |
713 | ||
714 | COMMAND:disarm(playerid,params[]) | |
715 | { | |
716 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
717 | new id; | |
718 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /disarm [playerid]"); | |
719 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
720 | ResetPlayerWeapons(id); | |
721 | SendClientMessageToAllEx(color_red,"ssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} disarmed ",PlayerInfo[id][Username],"."); | |
722 | return 1; | |
723 | } | |
724 | ||
725 | COMMAND:mute(playerid,params[]) | |
726 | { | |
727 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
728 | new id,reason[64]; | |
729 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /mute [id] [reason]"); | |
730 | sscanf(params,"is[64]",id,reason); | |
731 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
732 | if(PlayerInfo[id][Muted] == 1) return SendClientMessage(playerid,color_red,"Player is already muted!"); | |
733 | if(!strlen(reason)) | |
734 | { | |
735 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} muted ",PlayerInfo[id][Username],"."); | |
736 | } else { | |
737 | SendClientMessageToAllEx(color_red,"sssssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} muted ",PlayerInfo[id][Username]," Reason:",reason,"."); | |
738 | } | |
739 | PlayerInfo[id][Muted] = 1; | |
740 | MutePlayer(id); | |
741 | return 1; | |
742 | } | |
743 | COMMAND:unmute(playerid,params[]) | |
744 | { | |
745 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
746 | new id; | |
747 | if(sscanf(params,"i",id))return SendClientMessage(playerid,color_red,"USAGE: /unmute [id]"); | |
748 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
749 | if(PlayerInfo[id][Muted] == 0) return SendClientMessage(playerid,color_red,"Player is not muted!"); | |
750 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} unmuted ",PlayerInfo[id][Username],"."); | |
751 | PlayerInfo[id][Muted] = 0; | |
752 | UnMutePlayer(playerid); | |
753 | return 1; | |
754 | } | |
755 | ||
756 | COMMAND:freeze(playerid,params[]) | |
757 | { | |
758 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
759 | new id,reason[64]; | |
760 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /freeze [id] [reason]"); | |
761 | sscanf(params,"is[64]",id,reason); | |
762 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
763 | if(!strlen(reason)) | |
764 | { | |
765 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} froze ",PlayerInfo[id][Username],"."); | |
766 | } else { | |
767 | SendClientMessageToAllEx(color_red,"sssssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} froze ",PlayerInfo[id][Username]," Reason:",reason,"."); | |
768 | } | |
769 | TogglePlayerControllable(id,0); | |
770 | return 1; | |
771 | } | |
772 | COMMAND:unfreeze(playerid,params[]) | |
773 | { | |
774 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
775 | new id; | |
776 | if(sscanf(params,"i",id))return SendClientMessage(playerid,color_red,"USAGE: /unfreeze [id]"); | |
777 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
778 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} unfroze ",PlayerInfo[id][Username],"."); | |
779 | TogglePlayerControllable(id,1); | |
780 | return 1; | |
781 | } | |
782 | ||
783 | COMMAND:jail(playerid,params[]) | |
784 | { | |
785 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
786 | new id,reason[64]; | |
787 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /jail [id] [reason]"); | |
788 | sscanf(params,"is[64]",id,reason); | |
789 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
790 | if(!strlen(reason)) | |
791 | { | |
792 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} jailed ",PlayerInfo[id][Username],"."); | |
793 | } else { | |
794 | SendClientMessageToAllEx(color_red,"sssssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} jailed ",PlayerInfo[id][Username]," Reason:",reason,"."); | |
795 | } | |
796 | PlayerInfo[id][Jailed] = 1; | |
797 | JailPlayer(id); | |
798 | return 1; | |
799 | } | |
800 | COMMAND:unjail(playerid,params[]) | |
801 | { | |
802 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
803 | new id; | |
804 | if(sscanf(params,"i",id))return SendClientMessage(playerid,color_red,"USAGE: /unjail [id]"); | |
805 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
806 | if(PlayerInfo[id][Jailed] == 0) return SendClientMessage(playerid,color_red,"Player is not jailed!"); | |
807 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} unjailed ",PlayerInfo[id][Username],"."); | |
808 | PlayerInfo[id][Jailed] = 0; | |
809 | UnJailPlayer(id); | |
810 | return 1; | |
811 | } | |
812 | ||
813 | COMMAND:kick(playerid,params[]) | |
814 | { | |
815 | if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
816 | new id,reason[64]; | |
817 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /kick [id] [reason]"); | |
818 | sscanf(params,"is[64]",id,reason); | |
819 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
820 | if(!strlen(reason)) | |
821 | { | |
822 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} kicked ",PlayerInfo[id][Username],"."); | |
823 | } else { | |
824 | SendClientMessageToAllEx(color_red,"sssssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} kicked ",PlayerInfo[id][Username]," Reason:",reason,"."); | |
825 | } | |
826 | return Kick(id); | |
827 | } | |
828 | ||
829 | //================================================================================================================ | |
830 | //Administrator commands | |
831 | COMMAND:veh(playerid,params[]) | |
832 | { | |
833 | #if ALLOW_VEH == false | |
834 | return SendClientMessage(playerid,color_red,"Sorry! This feature has been disabled."); | |
835 | #else | |
836 | if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
837 | new vehicle[32],c1 = -1,c2 = -1; | |
838 | if(sscanf(params,"s[24]",vehicle)) return SendClientMessage(playerid,color_red,"USAGE: /veh [vehiclename] [color1] [color2]"); | |
839 | sscanf(params,"s[24]ii",vehicle,c1,c2); | |
840 | new model = GetVehicleModelIdByName(vehicle); | |
841 | if(model == 0) return SendClientMessage(playerid,color_red,"Sorry! Cannot find a vehicle with your entered vehiclename."); | |
842 | new Float:x,Float:y,Float:z; | |
843 | GetPlayerPos(playerid,x,y,z); | |
844 | CreateVehicle(model,x+5,y,z,0,c1,c2,-1); | |
845 | SendClientMessageEx(playerid,color_orange,"sss","You succesfully spawned a ",vehicle," !"); | |
846 | printf("%s has spawned a %s.",PlayerInfo[playerid][Username],vehicle); | |
847 | return 1; | |
848 | #endif | |
849 | } | |
850 | ||
851 | COMMAND:get(playerid,params[]) | |
852 | { | |
853 | if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
854 | new id; | |
855 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /get [playerid]"); | |
856 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
857 | new Float:x,Float:y,Float:z;GetPlayerPos(playerid,x,y,z);x = x +2; | |
858 | SetPlayerPos(id,x,y,z); | |
859 | SendClientMessageEx(playerid,color_green,"sss","You have teleported ",PlayerInfo[id][Username]," to your position!"); | |
860 | SendClientMessageEx(id,color_green,"sss","Administrator ",PlayerInfo[playerid][Username]," has teleported you to his position!"); | |
861 | return 1; | |
862 | } | |
863 | COMMAND:goto(playerid,params[]) | |
864 | { | |
865 | if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
866 | new id; | |
867 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /goto [playerid]"); | |
868 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
869 | new Float:x,Float:y,Float:z;GetPlayerPos(id,x,y,z);x = x +2; | |
870 | SetPlayerPos(playerid,x,y,z); | |
871 | SendClientMessageEx(playerid,color_green,"sss","You have teleported to ",PlayerInfo[id][Username],"'s position!"); | |
872 | return 1; | |
873 | } | |
874 | ||
875 | COMMAND:giveweapon(playerid,params[]) | |
876 | { | |
877 | if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
878 | new id,weapon[32],ammo; | |
879 | if(sscanf(params,"is[32]i",id,weapon,ammo)) return SendClientMessage(playerid,color_red,"USAGE: /giveweapon [playerid] [weaponname] [ammo]"); | |
880 | new wid = GetWeaponIdByName(weapon); | |
881 | if(wid == -1) return SendClientMessage(playerid,color_red,"Invalid weapon name!"); | |
882 | GivePlayerWeapon(id,wid,ammo); | |
883 | SendClientMessageEx(id,color_green,"sssss","Administrator ",PlayerInfo[playerid][Username]," gave you a ",weapon,"!"); | |
884 | SendClientMessageEx(playerid,color_green,"sssss","You have given ",PlayerInfo[id][Username]," a ",weapon,"."); | |
885 | return 1; | |
886 | } | |
887 | ||
888 | COMMAND:setmoney(playerid,params[]) | |
889 | { | |
890 | if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
891 | new id,value; | |
892 | if(sscanf(params,"ii",id,value)) return SendClientMessage(playerid,color_red,"USAGE: /setmoney [playerid] [value]"); | |
893 | SetPlayerMoney(id,value); | |
894 | SendClientMessageEx(id,color_green,"sssis","Administrator ",PlayerInfo[playerid][Username]," has changed your money to ",value," !"); | |
895 | SendClientMessageEx(playerid,color_green,"sssis","You have succesfully changed ",PlayerInfo[id][Username],"'s money to ",value," ."); | |
896 | return 1; | |
897 | } | |
898 | ||
899 | COMMAND:setscore(playerid,params[]) | |
900 | { | |
901 | if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
902 | new id,value; | |
903 | if(sscanf(params,"ii",id,value)) return SendClientMessage(playerid,color_red,"USAGE: /setscore [playerid] [value]"); | |
904 | SetPlayerScore(id,value); | |
905 | SendClientMessageEx(id,color_green,"sssis","Administrator ",PlayerInfo[playerid][Username]," has changed your score to ",value," !"); | |
906 | SendClientMessageEx(playerid,color_green,"sssis","You have succesfully changed ",PlayerInfo[id][Username],"'s score to ",value," ."); | |
907 | return 1; | |
908 | } | |
909 | ||
910 | COMMAND:explode(playerid,params[]) | |
911 | { | |
912 | if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
913 | new id; | |
914 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /explode [playerid]"); | |
915 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
916 | new Float:x,Float:y,Float:z;GetPlayerPos(id,x,y,z); | |
917 | CreateExplosion(x,y,z,0,5); | |
918 | CreateExplosion(x,y+3,z,0,7); | |
919 | CreateExplosion(x+3,y,z,0,8); | |
920 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} made ",PlayerInfo[id][Username]," go boom!"); | |
921 | return 1; | |
922 | } | |
923 | ||
924 | COMMAND:ban(playerid,params[]) | |
925 | { | |
926 | if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
927 | new id,reason[64]; | |
928 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /ban [id] [reason]"); | |
929 | sscanf(params,"is[64]",id,reason); | |
930 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
931 | if(!strlen(reason)) | |
932 | { | |
933 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} banned ",PlayerInfo[id][Username],"."); | |
934 | } else { | |
935 | SendClientMessageToAllEx(color_red,"sssssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} banned ",PlayerInfo[id][Username]," Reason:",reason,"."); | |
936 | } | |
937 | return Ban(id); | |
938 | } | |
939 | ||
940 | COMMAND:banip(playerid,params[]) | |
941 | { | |
942 | if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
943 | new ip[32];if(sscanf(params,"s[32]",ip)) return SendClientMessage(playerid,color_red,"USAGE: /banip [ip]"); | |
944 | new str[64];format(str,sizeof str,"banip %s",ip); | |
945 | SendRconCommand(str); | |
946 | SendClientMessageEx(playerid,color_green,"sss","You have succesfully banned ",ip," !"); | |
947 | printf("%s has banned %s.",PlayerInfo[playerid][Username],ip); | |
948 | return 1; | |
949 | } | |
950 | ||
951 | COMMAND:annoy(playerid,params[]) | |
952 | { | |
953 | if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
954 | new id; | |
955 | if(sscanf(params,"i",id)) return SendClientMessage(playerid,color_red,"USAGE: /annoy [playerid]"); | |
956 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
957 | if(cow_victim != -1) return SendClientMessage(playerid,color_red,"Sorry! It seems like your cow has already been stolen by another administrator."); | |
958 | #if ALLOW_ANNOY == false | |
959 | return SendClientMessage(playerid,color_red,"Sorry! This feature has been disabled."); | |
960 | #else | |
961 | AnnoyPlayer(id); | |
962 | SendClientMessageToAllEx(color_red,"sssss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} has released his cow on ",PlayerInfo[id][Username]," !!!"); | |
963 | SendClientMessageEx(playerid,color_green,"sss","You have released your cow on ",PlayerInfo[id][Username],"! please use /catchcow to bring him back."); | |
964 | return 1; | |
965 | #endif | |
966 | } | |
967 | COMMAND:catchcow(playerid,params[]) | |
968 | { | |
969 | if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
970 | if(cow_victim == -1) return SendClientMessage(playerid,color_red,"You cannot catch the cow if it isnt released yet!"); | |
971 | StopAnnoying(); | |
972 | SendClientMessageToAllEx(color_red,"sss","***Administrator ",PlayerInfo[playerid][Username],"{FFFFFF} has brought his cow back to the farm!"); | |
973 | return 1; | |
974 | } | |
975 | ||
976 | //================================================================================================================ | |
977 | //Server owner commands | |
978 | COMMAND:setlevel(playerid,params[]) | |
979 | { | |
980 | if(PlayerInfo[playerid][Level] < 3&& !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
981 | new id,level;if(sscanf(params,"ii",id,level)) return SendClientMessage(playerid,color_red,"USAGE: /setlevel [playerid] [level 0/3]"); | |
982 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Player not connected."); | |
983 | if(level > 3) return SendClientMessage(playerid,color_red,"Error! You can only pick between level 0/3 (0: Player - 1: Moderator - 2: Administrator - 3: Owner)"); | |
984 | if(PlayerInfo[id][Level] < level) | |
985 | { | |
986 | PlayerInfo[id][Level] = level; | |
987 | SendClientMessageEx(playerid,color_green,"sssis","You have promoted ",PlayerInfo[id][Username]," succesfully to level ",level,"."); | |
988 | SendClientMessageEx(id,color_green,"sis","Congratulations! You have been promoted to level ",level,"."); | |
989 | } else { | |
990 | PlayerInfo[id][Level] = level; | |
991 | SendClientMessageEx(playerid,color_green,"sssis","You have demoted ",PlayerInfo[id][Username]," succesfully to level ",level,"."); | |
992 | SendClientMessageEx(id,color_green,"sis","You have been demoted to level ",level,"."); | |
993 | } | |
994 | SaveUser(id); | |
995 | return 1; | |
996 | } | |
997 | ||
998 | COMMAND:unbanip(playerid,params[]) | |
999 | { | |
1000 | if(PlayerInfo[playerid][Level] < 3 ) return SendClientMessage(playerid,color_red,"You have no permission to use this command!"); | |
1001 | new ip[32];if(sscanf(params,"s[32]",ip)) return SendClientMessage(playerid,color_red,"USAGE: /unbanip [ip]"); | |
1002 | new str[64];format(str,sizeof str,"unbanip %s",ip); | |
1003 | SendRconCommand(str); | |
1004 | SendClientMessageEx(playerid,color_green,"sss","You have succesfully unbanned ",ip," !"); | |
1005 | printf("%s has unbanned %s.",PlayerInfo[playerid][Username],ip); | |
1006 | return 1; | |
1007 | } | |
1008 | ||
1009 | //================================================================================================================ | |
1010 | //stocks for admin script | |
1011 | stock OnPlayerRegister(playerid,password[]) | |
1012 | { | |
1013 | GetPlayerName(playerid,PlayerInfo[playerid][Username],MAX_PLAYER_NAME); | |
1014 | WP_Hash(PlayerInfo[playerid][Password],129,password); | |
1015 | PlayerInfo[playerid][Muted] = 0; | |
1016 | PlayerInfo[playerid][Score] = GetPlayerScore(playerid); | |
1017 | PlayerInfo[playerid][Money] = GetPlayerMoney(playerid); | |
1018 | PlayerInfo[playerid][Level] = 0; | |
1019 | format(PlayerInfo[playerid][Ip],32,"%s",GetPlayerIpEx(playerid)); | |
1020 | #if USE_MYSQL_DATABASE == true | |
1021 | yoursql_insert("users","ssiiiiis",yoursql_escape_string(PlayerInfo[playerid][Username]),PlayerInfo[playerid][Password],PlayerInfo[playerid][Muted],PlayerInfo[playerid][Jailed],PlayerInfo[playerid][Score],PlayerInfo[playerid][Money],PlayerInfo[playerid][Level],PlayerInfo[playerid][Ip]); | |
1022 | #else | |
1023 | new string[128];format(string,sizeof string,"Users/%s.ini",PlayerInfo[playerid][Username]); | |
1024 | new INI:handler = INI_Open(string); | |
1025 | INI_WriteString(handler,"Username",PlayerInfo[playerid][Username]); | |
1026 | INI_WriteString(handler,"Password",PlayerInfo[playerid][Password]); | |
1027 | INI_WriteInt(handler,"Muted",PlayerInfo[playerid][Muted]); | |
1028 | INI_WriteInt(handler,"Jailed",PlayerInfo[playerid][Jailed]); | |
1029 | INI_WriteInt(handler,"Score",GetPlayerScore(playerid)); | |
1030 | INI_WriteInt(handler,"Money",GetPlayerMoney(playerid)); | |
1031 | INI_WriteInt(handler,"Level",0); | |
1032 | INI_WriteString(handler,"Ip",GetPlayerIpEx(playerid)); | |
1033 | INI_Close(handler); | |
1034 | #endif | |
1035 | printf("%s has registered an account.",PlayerInfo[playerid][Username]); | |
1036 | SendClientMessageToAllEx(color_green,"ss",PlayerInfo[playerid][Username]," has registered an account, welcome!"); | |
1037 | } | |
1038 | ||
1039 | stock LoadUser(playerid,pName[]) | |
1040 | { | |
1041 | new identifier[64]; | |
1042 | #if USE_MYSQL_DATABASE == true | |
1043 | format(identifier,sizeof identifier,"Username = '%s'",pName); | |
1044 | sscanf(yoursql_receive("users",identifier),"p<|>e<s[32]s[129]iiiiis[12]>",PlayerInfo[playerid]); | |
1045 | #else | |
1046 | format(identifier,sizeof identifier,"Users/%s.ini",pName); | |
1047 | INI_ParseFile(identifier, "YINI_LOAD", .bExtra = true, .extra = playerid); | |
1048 | #endif | |
1049 | SetPlayerScore(playerid,PlayerInfo[playerid][Score]); | |
1050 | SetPlayerMoney(playerid,PlayerInfo[playerid][Money]); | |
1051 | return 1; | |
1052 | } | |
1053 | ||
1054 | forward YINI_LOAD(playerid,Name[],Value[]); | |
1055 | public YINI_LOAD(playerid,Name[],Value[]) | |
1056 | { | |
1057 | if(!strcmp(Name,"Username")){format(PlayerInfo[playerid][Username],32,"%s",Value);} | |
1058 | if(!strcmp(Name,"Password")){format(PlayerInfo[playerid][Password],129,"%s",Value);} | |
1059 | if(!strcmp(Name,"Muted")){PlayerInfo[playerid][Muted] = strval(Value);} | |
1060 | if(!strcmp(Name,"Jailed")){PlayerInfo[playerid][Jailed] = strval(Value);} | |
1061 | if(!strcmp(Name,"Score")){PlayerInfo[playerid][Score] = strval(Value);} | |
1062 | if(!strcmp(Name,"Money")){PlayerInfo[playerid][Money] = strval(Value);} | |
1063 | if(!strcmp(Name,"Level")){PlayerInfo[playerid][Level] = strval(Value);} | |
1064 | if(!strcmp(Name,"Ip")){format(PlayerInfo[playerid][Ip],32,"%s",Value);} | |
1065 | return 1; | |
1066 | } | |
1067 | ||
1068 | stock SaveUser(playerid) | |
1069 | { | |
1070 | new string[320]; | |
1071 | #if USE_MYSQL_DATABASE == true | |
1072 | format(string,sizeof string,"password = '%s', muted = %i, jailed = %i, score = %i, money = %i, level = %i, Ip = '%s'",yoursql_escape_string(PlayerInfo[playerid][Password]),PlayerInfo[playerid][Muted],PlayerInfo[playerid][Jailed],GetPlayerScore(playerid),GetPlayerMoney(playerid),PlayerInfo[playerid][Level],GetPlayerIpEx(playerid)); | |
1073 | new identifier[32];format(identifier,sizeof identifier,"Username = '%s'",PlayerInfo[playerid][Username]); | |
1074 | yoursql_update("users",string,identifier); | |
1075 | #else | |
1076 | format(string,sizeof string,"Users/%s.ini",PlayerInfo[playerid][Username]); | |
1077 | new INI:handler = INI_Open(string); | |
1078 | INI_WriteString(handler,"Password",PlayerInfo[playerid][Password]); | |
1079 | INI_WriteInt(handler,"Muted",PlayerInfo[playerid][Muted]); | |
1080 | INI_WriteInt(handler,"Jailed",PlayerInfo[playerid][Jailed]); | |
1081 | INI_WriteInt(handler,"Score",GetPlayerScore(playerid)); | |
1082 | INI_WriteInt(handler,"Money",GetPlayerMoney(playerid)); | |
1083 | INI_WriteInt(handler,"Level",PlayerInfo[playerid][Level]); | |
1084 | INI_Close(handler); | |
1085 | #endif | |
1086 | } | |
1087 | //================================================================================================================ | |
1088 | //Parts from Hiddos's annoying cow script | |
1089 | stock AnnoyPlayer(playerid) | |
1090 | { | |
1091 | object_cow = CreateObject(16442, 0, 0, 0, 0, 0, 0); | |
1092 | cow_victim = playerid; | |
1093 | new Float:Pos[4]; | |
1094 | if(IsPlayerInAnyVehicle(cow_victim)) GetVehiclePos(GetPlayerVehicleID(cow_victim), Pos[0], Pos[1], Pos[2]); | |
1095 | else GetPlayerPos(cow_victim, Pos[0], Pos[1], Pos[2]); | |
1096 | Pos[0] += float(random(30) - 15); | |
1097 | Pos[1] += float(random(30) - 15); | |
1098 | StopObject(object_cow); | |
1099 | SetObjectPos(object_cow, Pos[0], Pos[1], Pos[2] - 7.5); | |
1100 | MoveObject(object_cow, Pos[0], Pos[1], Pos[2], 5.0); | |
1101 | movecow_timer = SetTimer("MoveCow", 2000, true); | |
1102 | } | |
1103 | stock StopAnnoying() | |
1104 | { | |
1105 | KillTimer(movecow_timer); | |
1106 | DestroyObject(object_cow); //Bai bai cow :( | |
1107 | cow_victim = -1; | |
1108 | } | |
1109 | stock Float:GetPlayerSpeed(playerid) | |
1110 | { | |
1111 | new Float:x,Float:y,Float:z; | |
1112 | if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z); | |
1113 | else GetPlayerVelocity(playerid,x,y,z); | |
1114 | return floatsqroot(x*x+y*y+z*z) * 48.5; | |
1115 | } | |
1116 | forward MoveCow(); | |
1117 | public MoveCow() | |
1118 | { | |
1119 | if(cow_victim == -1) return; | |
1120 | new Float:Pos[7]; | |
1121 | GetObjectPos(object_cow, Pos[0], Pos[1], Pos[2]); | |
1122 | if(IsPlayerInAnyVehicle(cow_victim)) GetVehiclePos(GetPlayerVehicleID(cow_victim), Pos[3], Pos[4], Pos[5]); | |
1123 | else GetPlayerPos(cow_victim, Pos[3], Pos[4], Pos[5]); | |
1124 | Pos[3] += float(random(10) - 5); | |
1125 | Pos[4] += float(random(10) - 5); | |
1126 | Pos[6] = atan( floatdiv(abs(Pos[4] - Pos[1]), abs(Pos[3] - Pos[0])) ); | |
1127 | ||
1128 | if(Pos[3] < Pos[0] && Pos[4] < Pos[1]) Pos[6] += 180; | |
1129 | else if(!(Pos[3] > Pos[0] && Pos[4] > Pos[1])) | |
1130 | { | |
1131 | Pos[6] *= float(-1); | |
1132 | Pos[6] += float((Pos[3] > Pos[0] && Pos[4] < Pos[1]) ? (90) : (270)); | |
1133 | Pos[6] -= float(90); | |
1134 | } | |
1135 | SetObjectRot(object_cow, 0, 0, Pos[6]); | |
1136 | MoveObject(object_cow, Pos[3], Pos[4], Pos[5] + 1.2, GetPlayerSpeed(cow_victim) + 7.8); | |
1137 | } |