· 7 years ago · Feb 06, 2019, 11:06 PM
1/*
2*
3*
4*
5*/
6
7
8#include <a_samp>
9#undef MAX_PLAYERS
10#define MAX_PLAYERS 500
11//----------
12// INCLUDE
13#include <a_mysql>
14#include <zcmd>
15#include <sscanf2>
16#include <foreach>
17#include <vehchecktype>
18
19// Define
20// stili dialogo
21#define d_input DIALOG_STYLE_INPUT
22#define d_list DIALOG_STYLE_LIST
23
24// Configurazione MySQL
25#define MYSQL_HOST "127.0.0.1"
26#define MYSQL_USER "root"
27#define MYSQL_PASSWORD "Pass123!"
28#define MYSQL_DATABASE "dbrp"
29
30//-------------
31// info server
32#define emailserver "asd@gmail.com"
33#define nomeserver "server bello"
34
35//==========================================
36
37
38
39
40
41// controllo pressione tasti
42#define PRESSED(%0) \
43 (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) //Detecting keys
44
45
46#define VTYPE_CAR_CHECK 1
47
48
49//=========================
50// pickup per entrare negli interior
51// Caserma di polizia entra - esci
52new PoliceEnterInterior, PoliceExitInterior;
53new /*PulaPorta1, */PulaPorta2, PulaPorta3;
54
55//============================================
56// Textdraw
57// admin in duty
58new Text:AdminInDuty;
59new Text:SPEEDOS[MAX_PLAYERS];
60new Text:HEALTH[MAX_PLAYERS];
61new Text:BoxVeicolo;
62new Text:TitoloBoxInfoVeicolo;
63new Text:TitoloMotoreVita;
64new Text:InfoMotoreOnOff;
65new Text:TitoloStatoMotore;
66new Text:FloatVitaMotore;
67new Text:CodiceNomeVeicolo;
68new Text:TitoloVelocita;
69new Text:NumeroVelocitaVeh;
70
71// mostra documento: carta d'identitÃ
72new Text:doc_boxcartadidentita;
73new Text:doc_cartadidentitatitolo;
74new Text:doc_nomecognomeplayer;
75new Text:doc_codicenome;
76new Text:doc_etaplayer;
77new Text:doc_codiceeta;
78new Text:doc_casaplayer;
79new Text:doc_codicecasaplayer;
80new Text:doc_lavoroplayer;
81new Text:doc_codicelavorofazione;
82new Text:doc_nomesindaco;
83new Text:doc_codicenomesindaco;
84
85
86
87
88
89
90
91
92// domande di sicurezza
93// per modificare la password con il comando /cambia -> password
94#define MAX_SECURITY_QUESTION_SIZE 128
95
96
97// colori
98// system color
99#define COLOR_SYSTEM_ERROR 0xAA3333AA
100#define COLOR_SYSTEM_TITLE 0xFFFFFFAA
101#define COLOR_SYSTEM_TEXT 0xFFFFFFAA
102#define COLOR_SYSTEM_SUCCESS 0x33AA33AA
103#define COLOR_SYSTEM_INFO 0xAFAFAFAA
104#define COLOR_SYSTEM_ADMIN 0xFFFF00AA
105#define COLOR_PURPLE 0xC2A2DAAA
106
107#define COL_STRING_ERROR "{FF0000}"
108#define COL_STRING_SUCCESS "{00FF00}"
109#define COLOR_RED 0xFF0000
110#define COLOR_INFO 0xAFAFAF
111#define COLOR_WHITE (0xFFFFFFFF)
112#define COL_WHITE "{FFFFFF}"
113#define COLOR_TOMATO (0xFF6347FF)
114#define COL_TOMATO "{FF6347}"
115#define COLOR_YELLOW (0xFFDD00FF)
116#define COL_YELLOW "{FFDD00}"
117#define COLOR_GREEN (0x00FF00FF)
118#define COL_GREEN "{00FF00}"
119#define COLOR_DEFAULT (0xA9C4E4FF)
120#define COL_DEFAULT "{A9C4E4}"
121
122// timers
123#define SECONDS_TO_LOGIN 30
124#define NAME_CHECKER1 30
125#define DOCUMENT_SHOW 5
126
127// Spawn default dopo la registrazione
128#define DEFAULT_POS_X -1965.3541
129#define DEFAULT_POS_Y 158.4787
130#define DEFAULT_POS_Z 27.6940
131#define DEFAULT_POS_A 90.0000
132#define DEFAULT_POS_INTERIOR 0
133/* Es: Las Venturas
134#define DEFAULT_POS_X 1958.3783
135#define DEFAULT_POS_Y 1343.1572
136#define DEFAULT_POS_Z 15.3746
137#define DEFAULT_POS_A 270.1425
138#define DEFAULT_POS_INTERIOR 0
139*/
140// MySQL connection handle
141new MySQL: g_SQL;
142new pID[MAX_PLAYERS];
143new timerP[MAX_PLAYERS];
144
145// player data
146enum E_PLAYERS
147{
148 ID,
149 Name[MAX_PLAYER_NAME],
150 Password[65], // the output of SHA256_PassHash function (which was added in 0.3.7 R1 version) is always 256 bytes in length, or the equivalent of 64 Pawn cells
151 Salt[17],
152 RPName[MAX_PLAYER_NAME],
153 Kills,
154 Admin,
155 Age,
156 Warns,
157 ADuty,
158 Sex[64],
159 Soldi,
160 FactionID,
161 FactionRank,
162 PatenteA[64],
163 PatenteB[64],
164 PatenteC[64],
165 PatenteD[64],
166 PortoDarmi[64],
167 Deaths,
168 Float:Vita,
169 Float:Armatura,
170 e_USER_SECURITY_QUESTION[MAX_SECURITY_QUESTION_SIZE],
171 e_USER_SECURITY_ANSWER[64],
172 PlayerEmail[64],
173 Float: X_Pos,
174 Float: Y_Pos,
175 Float: Z_Pos,
176 Float: A_Pos,
177 Interior,
178 WeapID,
179 WeapAmmo,
180
181 Cache: Cache_ID,
182 bool: IsLoggedIn,
183 LoginAttempts,
184 AdminSpec,
185 AdminWhoSpec[64],
186 LoginTimer
187};
188new Player[MAX_PLAYERS][E_PLAYERS];
189
190
191
192
193new g_MysqlRaceCheck[MAX_PLAYERS];
194
195
196
197
198
199
200
201
202
203
204// dialog data
205enum
206{
207 DIALOG_UNUSED,
208 DIALOG_LOGIN,
209 DIALOG_REGISTER,
210 DIALOG_REGISTER_AGE,
211 DIALOG_REGISTER_SEX,
212 DIALOG_REGISTER_EMAIL,
213 DIALOG_REGISTER_DOMANDASEC,
214 DIALOG_REGISTER_RISPOSTASEC,
215 D_CAMBIA_INIZIO,
216 DIALOG_PROVA
217};
218
219
220
221
222// protocollo controllo nome RP
223stock RPnamecheck(playerid)
224{
225 new pname[MAX_PLAYER_NAME],underline=0;
226 GetPlayerName(playerid, pname, sizeof(pname));
227 if(strfind(pname,"[",true) != (-1)) return 0;
228 else if(strfind(pname,"]",true) != (-1)) return 0;
229 else if(strfind(pname,"$",true) != (-1)) return 0;
230 else if(strfind(pname,"(",true) != (-1)) return 0;
231 else if(strfind(pname,")",true) != (-1)) return 0;
232 else if(strfind(pname,"=",true) != (-1)) return 0;
233 else if(strfind(pname,"@",true) != (-1)) return 0;
234 else if(strfind(pname,"1",true) != (-1)) return 0;
235 else if(strfind(pname,"2",true) != (-1)) return 0;
236 else if(strfind(pname,"3",true) != (-1)) return 0;
237 else if(strfind(pname,"4",true) != (-1)) return 0;
238 else if(strfind(pname,"5",true) != (-1)) return 0;
239 else if(strfind(pname,"6",true) != (-1)) return 0;
240 else if(strfind(pname,"7",true) != (-1)) return 0;
241 else if(strfind(pname,"8",true) != (-1)) return 0;
242 else if(strfind(pname,"9",true) != (-1)) return 0;
243 else if(strfind(pname,"fuck",true) != (-1)) return 0;
244 else if(strfind(pname,"FUCK",true) != (-1)) return 0;
245 else if(strfind(pname,"Boobies",true) != (-1)) return 0;
246 else if(strfind(pname,"Tupac_Shakur",true) != (-1)) return 0;
247 else if(strfind(pname,"Pussy",true) != (-1)) return 0;
248 else if(strfind(pname,"Rape",true) != (-1)) return 0;
249 else if(strfind(pname,"kill",true) != (-1)) return 0;
250 else if(strfind(pname,"shit",true) != (-1)) return 0;
251 else if(strfind(pname,"ass",true) != (-1)) return 0;
252 else if(strfind(pname,"Jack_Black",true) != (-1)) return 0;
253 else if(strfind(pname,"Max_Kenton",true) != (-1)) return 0;
254 else if(strfind(pname,"Will_Smith",true) != (-1)) return 0;
255 else if(strfind(pname,"Jaden_Smith",true) != (-1)) return 0;
256 else if(strfind(pname,"Megan_Fox",true) != (-1)) return 0;
257 else if(strfind(pname,"Charlie_Kenton",true) != (-1)) return 0;
258 else if(strfind(pname,"Hugh_Hefner",true) != (-1)) return 0;
259 else if(strfind(pname,"Paris_Hilton",true) != (-1)) return 0;
260 else if(strfind(pname,"Marshall_Mathers",true) != (-1)) return 0;
261 else if(strfind(pname,"Sheldon_Cooper",true) != (-1)) return 0;
262 else if(strfind(pname,"Jet_Lee",true) != (-1)) return 0;
263 else if(strfind(pname,"Jackie_Chan",true) != (-1)) return 0;
264 else if(strfind(pname,"Chuck_Norris",true) != (-1)) return 0;
265 else if(strfind(pname,"Peter_Parker",true) != (-1)) return 0;
266 else if(strfind(pname,"Spider_Man",true) != (-1)) return 0;
267 else if(strfind(pname,"Bat_Man",true) != (-1)) return 0;
268 else if(strfind(pname,"Emma_Stone",true) != (-1)) return 0;
269 else if(strfind(pname,"whore",true) != (-1)) return 0;
270 else if(strfind(pname,"Hugh_Jackman",true) != (-1)) return 0;
271 else if(strfind(pname,"Charles_Kenton",true) != (-1)) return 0;
272 else if(strfind(pname,"Harry_Potter",true) != (-1)) return 0;
273 else if(strfind(pname,"Chris_Hemsworth",true) != (-1)) return 0;
274 else if(strfind(pname,"Penis",true) != (-1)) return 0;
275 else if(strfind(pname,"_Dick",true) != (-1)) return 0;
276 else if(strfind(pname,"Vagina",true) != (-1)) return 0;
277 else if(strfind(pname,"Cock",true) != (-1)) return 0;
278 else if(strfind(pname,"Rectum",true) != (-1)) return 0;
279 else if(strfind(pname,"Sperm",true) != (-1)) return 0;
280 else if(strfind(pname,"Rektum",true) != (-1)) return 0;
281 else if(strfind(pname,"Pistol",true) != (-1)) return 0;
282 else if(strfind(pname,"AK47",true) != (-1)) return 0;
283 else if(strfind(pname,"Shotgun",true) != (-1)) return 0;
284 else if(strfind(pname,"Cum",true) != (-1)) return 0;
285 else if(strfind(pname,"Hitler",true) != (-1)) return 0;
286 else if(strfind(pname,"Jesus",true) != (-1)) return 0;
287 else if(strfind(pname,"God",true) != (-1)) return 0;
288 else if(strfind(pname,"Shotgun",true) != (-1)) return 0;
289 else if(strfind(pname,"Desert_Eagle",true) != (-1)) return 0;
290 else if(strfind(pname,"fucker",true) != (-1)) return 0;
291 else if(strfind(pname,"Retard",true) != (-1)) return 0;
292 else if(strfind(pname,"Tarded",true) != (-1)) return 0;
293 else if(strfind(pname,"fanny",true) != (-1)) return 0;
294 else if(strfind(pname,"Daniel_Hardy",true) != (-1)) return 0;
295 else if(strfind(pname,"abcdefghijklmnopqrstuvwxyz",true) != (-1)) return 0;
296 new maxname = strlen(pname);
297 for(new i=0; i<maxname; i++)
298 {
299 if(pname[i] == '_') underline ++;
300 }
301 if(underline != 1) return 0;
302 pname[0] = toupper(pname[0]);
303 for(new x=1; x<maxname; x++)
304 {
305 if(pname[x] == '_') pname[x+1] = toupper(pname[x+1]);
306 else if(pname[x] != '_' && pname[x-1] != '_') pname[x] = tolower(pname[x]);
307 }
308 SetPlayerName(playerid, "New_Name");
309 SetPlayerName(playerid, pname);
310 return 1;
311}
312// new - veicoli
313new engine,lights,alarm,doors,bonnet,boot,objective;
314new LuciVeicolo[MAX_VEHICLES];
315new EngineStatus[MAX_VEHICLES];
316
317
318
319
320main() {}
321
322
323public OnGameModeInit()
324{
325 DisableInteriorEnterExits();
326
327 new MySQLOpt: option_id = mysql_init_options();
328
329 mysql_set_option(option_id, AUTO_RECONNECT, true); // it automatically reconnects when loosing connection to mysql server
330
331 g_SQL = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, option_id); // AUTO_RECONNECT is enabled for this connection handle only
332 if (g_SQL == MYSQL_INVALID_HANDLE || mysql_errno(g_SQL) != 0)
333 {
334 print("MySQL connection failed. Server is shutting down.");
335 SendRconCommand("exit"); // close the server if there is no connection
336 return 1;
337 }
338 new infomysql[128];
339
340 print("[MySQL] - Connessione con successo al MySQL.");
341 format(infomysql, sizeof(infomysql), "[MySQL] - MySQL connesso all'host '%s'", MYSQL_HOST);
342 print(infomysql);
343 format(infomysql, sizeof(infomysql), "[MySQL] - Utente collegato '%s'", MYSQL_USER);
344 print(infomysql);
345 format(infomysql, sizeof(infomysql), "[MySQL] - Password utilizzata '%s'", MYSQL_PASSWORD);
346 print(infomysql);
347 format(infomysql, sizeof(infomysql), "[MySQL] - Connesso al database '%s' con successo", MYSQL_DATABASE);
348 print(infomysql);
349
350 //==========================================================
351 // objects
352 PulaPorta3 = CreateObject(2930, 230.62199, 169.8, 1004.7, 0.0, 0.0, 90.0, 100); // object (chinaTgate) (1)
353 PulaPorta2 = CreateObject(2930, 228.2998, 152.09961, 1004.7, 0.0, 0.0, 0.0, 100); // object (chinaTgate) (2)
354// PulaPorta3 = CreateObject(2930, 228.2998, 162.10059, 1004.7, 0.0, 0.0, 0.0, 100); // object (chinaTgate) (3)
355
356
357
358
359
360
361 //=========================================================================
362 // pickup per entrare negli interior
363 PoliceEnterInterior = CreatePickup(1239, 1, -1605.6217,711.8565,13.8672, 0);
364 PoliceExitInterior = CreatePickup(1239, 1, 238.8014,139.3253,1003.0234, 3);
365
366
367 //-------------------------------------------------------------------------
368 // TextDraws
369 // TextDraw admin in duty
370 AdminInDuty = TextDrawCreate(102.606338, 313.833496, "ADMIN ON");
371 TextDrawLetterSize(AdminInDuty, 0.506222, 1.518333);
372 TextDrawAlignment(AdminInDuty, 3);
373 TextDrawColor(AdminInDuty, -1);
374 TextDrawUseBox(AdminInDuty, true);
375 TextDrawBoxColor(AdminInDuty, 255);
376 TextDrawSetShadow(AdminInDuty, 0);
377 TextDrawSetOutline(AdminInDuty, 0);
378 TextDrawBackgroundColor(AdminInDuty, 41215);
379 TextDrawFont(AdminInDuty, 1);
380 TextDrawSetProportional(AdminInDuty, 1);
381 // info del veicolo
382 BoxVeicolo = TextDrawCreate(641.062988, 318.833312, "usebox");
383 TextDrawLetterSize(BoxVeicolo, 0.000000, 14.007410);
384 TextDrawTextSize(BoxVeicolo, 447.311859, 0.000000);
385 TextDrawAlignment(BoxVeicolo, 1);
386 TextDrawColor(BoxVeicolo, 0);
387 TextDrawUseBox(BoxVeicolo, true);
388 TextDrawBoxColor(BoxVeicolo, 102);
389 TextDrawSetShadow(BoxVeicolo, 0);
390 TextDrawSetOutline(BoxVeicolo, 0);
391 TextDrawFont(BoxVeicolo, 0);
392
393 TitoloBoxInfoVeicolo = TextDrawCreate(505.065521, 305.083740, "Info veicolo");
394 TextDrawLetterSize(TitoloBoxInfoVeicolo, 0.449999, 1.600000);
395 TextDrawAlignment(TitoloBoxInfoVeicolo, 1);
396 TextDrawColor(TitoloBoxInfoVeicolo, -1);
397 TextDrawSetShadow(TitoloBoxInfoVeicolo, 0);
398 TextDrawSetOutline(TitoloBoxInfoVeicolo, 1);
399 TextDrawBackgroundColor(TitoloBoxInfoVeicolo, 51);
400 TextDrawFont(TitoloBoxInfoVeicolo, 1);
401 TextDrawSetProportional(TitoloBoxInfoVeicolo, 1);
402
403 TitoloMotoreVita = TextDrawCreate(457.276733, 354.666687, "Motore:");
404 TextDrawLetterSize(TitoloMotoreVita, 0.343176, 1.442501);
405 TextDrawAlignment(TitoloMotoreVita, 1);
406 TextDrawColor(TitoloMotoreVita, -1);
407 TextDrawSetShadow(TitoloMotoreVita, 0);
408 TextDrawSetOutline(TitoloMotoreVita, 1);
409 TextDrawBackgroundColor(TitoloMotoreVita, 51);
410 TextDrawFont(TitoloMotoreVita, 1);
411 TextDrawSetProportional(TitoloMotoreVita, 1);
412
413 InfoMotoreOnOff = TextDrawCreate(506.471435, 352.916687, " ");
414 TextDrawLetterSize(InfoMotoreOnOff, 0.449999, 1.600000);
415 TextDrawAlignment(InfoMotoreOnOff, 1);
416 TextDrawColor(InfoMotoreOnOff, -1);
417 TextDrawSetShadow(InfoMotoreOnOff, 0);
418 TextDrawSetOutline(InfoMotoreOnOff, 1);
419 TextDrawBackgroundColor(InfoMotoreOnOff, 51);
420 TextDrawFont(InfoMotoreOnOff, 1);
421 TextDrawSetProportional(InfoMotoreOnOff, 1);
422
423 TitoloStatoMotore = TextDrawCreate(457.276672, 337.750061, "Stato motore:");
424 TextDrawLetterSize(TitoloStatoMotore, 0.288359, 1.745833);
425 TextDrawAlignment(TitoloStatoMotore, 1);
426 TextDrawColor(TitoloStatoMotore, -1);
427 TextDrawSetShadow(TitoloStatoMotore, 0);
428 TextDrawSetOutline(TitoloStatoMotore, 1);
429 TextDrawBackgroundColor(TitoloStatoMotore, 51);
430 TextDrawFont(TitoloStatoMotore, 1);
431 TextDrawSetProportional(TitoloStatoMotore, 1);
432
433 FloatVitaMotore = TextDrawCreate(532.240173, 338.916687, " ");
434 TextDrawLetterSize(FloatVitaMotore, 0.449999, 1.600000);
435 TextDrawAlignment(FloatVitaMotore, 1);
436 TextDrawColor(FloatVitaMotore, -1);
437 TextDrawSetShadow(FloatVitaMotore, 0);
438 TextDrawSetOutline(FloatVitaMotore, 1);
439 TextDrawBackgroundColor(FloatVitaMotore, 51);
440 TextDrawFont(FloatVitaMotore, 1);
441 TextDrawSetProportional(FloatVitaMotore, 1);
442
443 CodiceNomeVeicolo = TextDrawCreate(507.877075, 315.000000, "nomeveicolo");
444 TextDrawLetterSize(CodiceNomeVeicolo, 0.449999, 1.600000);
445 TextDrawAlignment(CodiceNomeVeicolo, 1);
446 TextDrawColor(CodiceNomeVeicolo, -1);
447 TextDrawSetShadow(CodiceNomeVeicolo, 0);
448 TextDrawSetOutline(CodiceNomeVeicolo, 1);
449 TextDrawBackgroundColor(CodiceNomeVeicolo, 51);
450 TextDrawFont(CodiceNomeVeicolo, 1);
451 TextDrawSetProportional(CodiceNomeVeicolo, 1);
452
453 TitoloVelocita = TextDrawCreate(457.745239, 378.583312, "velocita':");
454 TextDrawLetterSize(TitoloVelocita, 0.372694, 1.804166);
455 TextDrawAlignment(TitoloVelocita, 1);
456 TextDrawColor(TitoloVelocita, -1);
457 TextDrawUseBox(TitoloVelocita, true);
458 TextDrawBoxColor(TitoloVelocita, 0);
459 TextDrawSetShadow(TitoloVelocita, 0);
460 TextDrawSetOutline(TitoloVelocita, 1);
461 TextDrawBackgroundColor(TitoloVelocita, 51);
462 TextDrawFont(TitoloVelocita, 1);
463 TextDrawSetProportional(TitoloVelocita, 1);
464
465 NumeroVelocitaVeh = TextDrawCreate(518.184509, 380.333190, "000");
466 TextDrawLetterSize(NumeroVelocitaVeh, 0.410175, 1.395833);
467 TextDrawAlignment(NumeroVelocitaVeh, 1);
468 TextDrawColor(NumeroVelocitaVeh, -1);
469 TextDrawSetShadow(NumeroVelocitaVeh, 0);
470 TextDrawSetOutline(NumeroVelocitaVeh, 1);
471 TextDrawBackgroundColor(NumeroVelocitaVeh, 51);
472 TextDrawFont(NumeroVelocitaVeh, 1);
473 TextDrawSetProportional(NumeroVelocitaVeh, 1);
474 //--------------------------------------------------------------------------
475 // text draw mostro carta d'identitÃ
476 // box
477 doc_boxcartadidentita = TextDrawCreate(454.122985, 115.250000, "usebox");
478 TextDrawLetterSize(doc_boxcartadidentita, 0.000000, 26.840744);
479 TextDrawTextSize(doc_boxcartadidentita, 178.380676, 0.000000);
480 TextDrawAlignment(doc_boxcartadidentita, 1);
481 TextDrawColor(doc_boxcartadidentita, 0);
482 TextDrawUseBox(doc_boxcartadidentita, true);
483 TextDrawBoxColor(doc_boxcartadidentita, 102);
484 TextDrawSetShadow(doc_boxcartadidentita, 0);
485 TextDrawSetOutline(doc_boxcartadidentita, 0);
486 TextDrawFont(doc_boxcartadidentita, 0);
487 //
488 doc_cartadidentitatitolo = TextDrawCreate(265.183074, 113.750038, "Carta d'identita'");
489 TextDrawLetterSize(doc_cartadidentitatitolo, 0.449999, 1.600000);
490 TextDrawAlignment(doc_cartadidentitatitolo, 1);
491 TextDrawColor(doc_cartadidentitatitolo, -1);
492 TextDrawSetShadow(doc_cartadidentitatitolo, 0);
493 TextDrawSetOutline(doc_cartadidentitatitolo, 1);
494 TextDrawBackgroundColor(doc_cartadidentitatitolo, 51);
495 TextDrawFont(doc_cartadidentitatitolo, 1);
496 TextDrawSetProportional(doc_cartadidentitatitolo, 1);
497 //
498 doc_nomecognomeplayer = TextDrawCreate(188.642745, 161.000000, "Nome e cognome:");
499 TextDrawLetterSize(doc_nomecognomeplayer, 0.330000, 1.450000);
500 TextDrawAlignment(doc_nomecognomeplayer, 1);
501 TextDrawColor(doc_nomecognomeplayer, -1);
502 TextDrawSetShadow(doc_nomecognomeplayer, 0);
503 TextDrawSetOutline(doc_nomecognomeplayer, 1);
504 TextDrawBackgroundColor(doc_nomecognomeplayer, 51);
505 TextDrawFont(doc_nomecognomeplayer, 1);
506 TextDrawSetProportional(doc_nomecognomeplayer, 1);
507 //
508 doc_codicenome = TextDrawCreate(296.573852, 161.000030, "inserirecodicenome");
509 TextDrawLetterSize(doc_codicenome, 0.330000, 1.450000);
510 TextDrawAlignment(doc_codicenome, 1);
511 TextDrawColor(doc_codicenome, -1);
512 TextDrawSetShadow(doc_codicenome, 0);
513 TextDrawSetOutline(doc_codicenome, 1);
514 TextDrawBackgroundColor(doc_codicenome, 51);
515 TextDrawFont(doc_codicenome, 1);
516 TextDrawSetProportional(doc_codicenome, 1);
517 //
518 doc_etaplayer = TextDrawCreate(190.000000, 183.166687, "Eta':");
519 TextDrawLetterSize(doc_etaplayer, 0.330000, 1.450000);
520 TextDrawAlignment(doc_etaplayer, 1);
521 TextDrawColor(doc_etaplayer, -1);
522 TextDrawSetShadow(doc_etaplayer, 0);
523 TextDrawSetOutline(doc_etaplayer, 1);
524 TextDrawBackgroundColor(doc_etaplayer, 51);
525 TextDrawFont(doc_etaplayer, 1);
526 TextDrawSetProportional(doc_etaplayer, 1);
527 //
528 doc_codiceeta = TextDrawCreate(218.330902, 184.333328, "inserirecodiceeta");
529 TextDrawLetterSize(doc_codiceeta, 0.330000, 1.450000);
530 TextDrawAlignment(doc_codiceeta, 1);
531 TextDrawColor(doc_codiceeta, -1);
532 TextDrawSetShadow(doc_codiceeta, 0);
533 TextDrawSetOutline(doc_codiceeta, 1);
534 TextDrawBackgroundColor(doc_codiceeta, 51);
535 TextDrawFont(doc_codiceeta, 1);
536 TextDrawSetProportional(doc_codiceeta, 1);
537 //
538 doc_casaplayer = TextDrawCreate(190.688140, 213.500000, "Residente in:");
539 TextDrawLetterSize(doc_casaplayer, 0.330000, 1.450000);
540 TextDrawAlignment(doc_casaplayer, 1);
541 TextDrawColor(doc_casaplayer, -1);
542 TextDrawSetShadow(doc_casaplayer, 0);
543 TextDrawSetOutline(doc_casaplayer, 1);
544 TextDrawBackgroundColor(doc_casaplayer, 51);
545 TextDrawFont(doc_casaplayer, 1);
546 TextDrawSetProportional(doc_casaplayer, 1);
547 //
548 doc_codicecasaplayer = TextDrawCreate(273.147918, 214.666671, "inserirecodiceviacasa");
549 TextDrawLetterSize(doc_codicecasaplayer, 0.330000, 1.450000);
550 TextDrawAlignment(doc_codicecasaplayer, 1);
551 TextDrawColor(doc_codicecasaplayer, -1);
552 TextDrawSetShadow(doc_codicecasaplayer, 0);
553 TextDrawSetOutline(doc_codicecasaplayer, 1);
554 TextDrawBackgroundColor(doc_codicecasaplayer, 51);
555 TextDrawFont(doc_codicecasaplayer, 1);
556 TextDrawSetProportional(doc_codicecasaplayer, 1);
557 //
558 doc_lavoroplayer = TextDrawCreate(191.625183, 241.500000, "Lavoro:");
559 TextDrawLetterSize(doc_lavoroplayer, 0.330000, 1.450000);
560 TextDrawAlignment(doc_lavoroplayer, 1);
561 TextDrawColor(doc_lavoroplayer, -1);
562 TextDrawSetShadow(doc_lavoroplayer, 0);
563 TextDrawSetOutline(doc_lavoroplayer, 1);
564 TextDrawBackgroundColor(doc_lavoroplayer, 51);
565 TextDrawFont(doc_lavoroplayer, 1);
566 TextDrawSetProportional(doc_lavoroplayer, 1);
567 //
568 doc_codicelavorofazione = TextDrawCreate(241.756958, 243.250000, "inserirecodicelavoro");
569 TextDrawLetterSize(doc_codicelavorofazione, 0.330000, 1.450000);
570 TextDrawAlignment(doc_codicelavorofazione, 1);
571 TextDrawColor(doc_codicelavorofazione, -1);
572 TextDrawSetShadow(doc_codicelavorofazione, 0);
573 TextDrawSetOutline(doc_codicelavorofazione, 1);
574 TextDrawBackgroundColor(doc_codicelavorofazione, 51);
575 TextDrawFont(doc_codicelavorofazione, 1);
576 TextDrawSetProportional(doc_codicelavorofazione, 1);
577 //
578 doc_nomesindaco = TextDrawCreate(343.426025, 312.083343, "Firma del sindacoù");
579 TextDrawLetterSize(doc_nomesindaco, 0.330000, 1.450000);
580 TextDrawAlignment(doc_nomesindaco, 1);
581 TextDrawColor(doc_nomesindaco, -1);
582 TextDrawSetShadow(doc_nomesindaco, 0);
583 TextDrawSetOutline(doc_nomesindaco, 1);
584 TextDrawBackgroundColor(doc_nomesindaco, 51);
585 TextDrawFont(doc_nomesindaco, 1);
586 TextDrawSetProportional(doc_nomesindaco, 1);
587 //
588 doc_codicenomesindaco = TextDrawCreate(343.894592, 338.333312, "codicenomesindaco");
589 TextDrawLetterSize(doc_codicenomesindaco, 0.330000, 1.450000);
590 TextDrawAlignment(doc_codicenomesindaco, 1);
591 TextDrawColor(doc_codicenomesindaco, -1);
592 TextDrawSetShadow(doc_codicenomesindaco, 0);
593 TextDrawSetOutline(doc_codicenomesindaco, 1);
594 TextDrawBackgroundColor(doc_codicenomesindaco, 51);
595 TextDrawFont(doc_codicenomesindaco, 1);
596 TextDrawSetProportional(doc_codicenomesindaco, 1);
597
598
599
600
601
602
603 //------------------------------------
604 SetTimer("Speedometer", 50, true); //change 100 to what pleases you,but i'd say it's better to keep it like that.
605
606 // setting veicoli
607
608 for(new c=0;c<MAX_VEHICLES;c++)
609 {
610 EngineStatus[c] = 0;
611 GetVehicleParamsEx(c,engine,lights,alarm,doors,bonnet,boot,objective);
612 SetVehicleParamsEx(c,0,0,alarm,doors,bonnet,boot,objective);
613 LuciVeicolo[c] = 0;
614 }
615
616
617 // if the table has been created, the "SetupPlayerTable" function does not have any purpose so you may remove it completely
618 SetupPlayerTable();
619 return 1;
620}
621
622CMD:polizia(playerid, params[])
623{
624 SetPlayerInterior(playerid, 3);
625 SetPlayerPos(playerid, 236.89999389648, 141.19999694824, 1003);
626 return 1;
627}
628
629
630// quando un giocatore passa su un pickup
631public OnPlayerPickUpPickup(playerid, pickupid)
632{
633 if(pickupid == PoliceEnterInterior)
634 {
635// SendClientMessage(playerid, 0xAFAFAFFF, "Digita /entra per entrare");
636 return 1;
637 }
638 if(pickupid == PoliceExitInterior)
639 {
640// SendClientMessage(playerid, 0xAFAFAFFF, "Digita /esci per uscire");
641 return 1;
642 }
643
644
645 return 1;
646}
647
648
649
650// stocks
651
652
653
654
655
656// protocollo rimpiazzamento stringhe
657stock strreplace(string[], find, replace)
658{
659 for(new i=0; string[i]; i++)
660 {
661 if(string[i] == find)
662 {
663 string[i] = replace;
664 }
665 }
666}
667// protocollo di sostituzione della "_" in server
668stock GetName(playerid)
669{
670 new name[24];
671 GetPlayerName(playerid, name, sizeof(name));
672 strreplace(name, '_', ' ');
673
674 Player[playerid][RPName] = name;
675 return name;
676}
677// detector di range per i messaggi (in IC)
678stock ProxDetector(Float:radi, playerid, string[],color)
679{
680 new Float:x,Float:y,Float:z;
681 GetPlayerPos(playerid,x,y,z);
682 foreach(Player,i)
683 {
684 if(IsPlayerInRangeOfPoint(i,radi,x,y,z))
685 {
686 SendClientMessage(i,color,string);
687 }
688 }
689}
690
691public OnGameModeExit()
692{
693 // save all player data before closing connection
694 for (new i = 0, j = GetPlayerPoolSize(); i <= j; i++) // GetPlayerPoolSize function was added in 0.3.7 version and gets the highest playerid currently in use on the server
695 {
696 if (IsPlayerConnected(i))
697 {
698 // reason is set to 1 for normal 'Quit'
699 OnPlayerDisconnect(i, 1);
700 }
701 }
702
703 mysql_close(g_SQL);
704 return 1;
705}
706
707// quando l'utente si connette al server
708public OnPlayerConnect(playerid)
709{
710 if(!RPnamecheck(playerid))
711 {
712 SetTimerEx("KickTimerNameRP", 3000, 0, "d", playerid);
713 SetPlayerPos(playerid, 982.1890, -1624.2583, 14.9526);
714 SetPlayerFacingAngle(playerid, 90);
715 new string[128], pname[MAX_PLAYER_NAME];
716 GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
717 format(string, sizeof(string), "{FF0000}[INFO] Devi inserire un nome {00FF00}RP per entrare nel server");
718 SendClientMessage(playerid, COLOR_SYSTEM_ERROR, string);
719 format(string, sizeof(string), "{AFAFAF}Il nome {FF0000}%s non è valido.{AFAFAF} (devi usare tipo {00FF00}Nome_Cognome{AFAFAF})", Player[playerid][Name]);
720 SendClientMessage(playerid, COLOR_SYSTEM_ERROR, string);
721 }
722 else if(RPnamecheck(playerid))
723 {
724 g_MysqlRaceCheck[playerid]++;
725 // reset player data
726 static const empty_player[E_PLAYERS];
727 Player[playerid] = empty_player;
728
729 GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME);
730
731 // send a query to recieve all the stored player data from the table
732 new query[103];
733 mysql_format(g_SQL, query, sizeof query, "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name]);
734 mysql_tquery(g_SQL, query, "OnPlayerDataLoaded", "dd", playerid, g_MysqlRaceCheck[playerid]);
735
736 SPEEDOS[playerid] = TextDrawCreate(10.0,200.0," ");
737 TextDrawShowForPlayer(playerid,SPEEDOS[playerid]);
738 HEALTH[playerid] = TextDrawCreate(10.0,180.0," ");
739 TextDrawShowForPlayer(playerid,HEALTH[playerid]);
740
741
742 }
743 return 1;
744}
745
746public OnPlayerDisconnect(playerid, reason)
747{ // quando un player esce dal server
748 g_MysqlRaceCheck[playerid]++;
749
750 UpdatePlayerData(playerid, reason);
751 UpdatePlayerWeapons(playerid);
752
753 // if the player was kicked (either wrong password or taking too long) during the login part, remove the data from the memory
754 if (cache_is_valid(Player[playerid][Cache_ID]))
755 {
756 cache_delete(Player[playerid][Cache_ID]);
757 Player[playerid][Cache_ID] = MYSQL_INVALID_CACHE;
758 }
759
760 // if the player was kicked before the time expires (30 seconds), kill the timer
761 if (Player[playerid][LoginTimer])
762 {
763 KillTimer(Player[playerid][LoginTimer]);
764 Player[playerid][LoginTimer] = 0;
765 }
766
767 // sets "IsLoggedIn" to false when the player disconnects, it prevents from saving the player data twice when "gmx" is used
768 Player[playerid][IsLoggedIn] = false;
769 return 1;
770}
771
772public OnPlayerSpawn(playerid)
773{
774 // spawn the player to their last saved position
775 SetPlayerInterior(playerid, Player[playerid][Interior]);
776 SetPlayerPos(playerid, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos]);
777 SetPlayerFacingAngle(playerid, Player[playerid][A_Pos]);
778
779 SetCameraBehindPlayer(playerid);
780 return 1;
781}
782
783public OnPlayerDeath(playerid, killerid, reason)
784{
785 UpdatePlayerDeaths(playerid);
786 UpdatePlayerKills(killerid);
787 return 1;
788}
789
790//---------
791// quando un giocatore entra in un veicolo
792public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
793{
794 new vid = GetPlayerVehicleID(playerid);
795 GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
796 if(engine == 1)
797 {
798 TextDrawSetString(InfoMotoreOnOff, "on");
799 return 1;
800 }
801 else if(engine == 0)
802 {
803 TextDrawSetString(InfoMotoreOnOff, "off");
804 return 1;
805 }
806 return 1;
807}
808
809// quando un giocatore esce da un veicolo
810public OnPlayerExitVehicle(playerid, vehicleid)
811{
812 return 1;
813}
814
815
816
817public OnPlayerText(playerid, text[])
818{
819 new string[256];
820 new
821 messaggioIC[128];
822 format(messaggioIC, sizeof(messaggioIC), "%s dice: %s", GetName(playerid), text);
823 ProxDetector(30.0, playerid, messaggioIC, -1);
824
825 if(strcmp(text, "sa", true) == 0)
826 {
827 format(string, sizeof(string), "%s saluta con una stretta di mano e un abbraccio.", Player[playerid][RPName]);
828 format(text, 0, "");
829 ProxDetector(30.0, playerid, string, COLOR_PURPLE);
830// ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
831 SetPlayerChatBubble(playerid, text, COLOR_WHITE, 30.0, 7000);
832 ApplyAnimation(playerid,"GANGS","hndshkfa_swt",4.0,0,0,0,0,0); //shake
833 return 0;
834 }
835
836 return 0;
837}
838
839
840public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
841{
842 if (PRESSED(KEY_SUBMISSION))
843 {
844 if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
845 {
846 new str[60], vid = GetPlayerVehicleID(playerid);
847 GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
848 if(engine == 0)
849 {
850 new string[64];
851 format(string, sizeof(string), "%s gira la chiave ed accende il motore", Player[playerid][RPName]);
852 ProxDetector(15, playerid, string, COLOR_PURPLE);
853 //------------------
854 SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[MOTORE]: Il motore di questa vettura è spento");
855 format(str, sizeof(str), "[Veicolo] Hai acceso il motore");
856 SendClientMessage(playerid, COLOR_SYSTEM_INFO, str);
857 GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
858 SetVehicleParamsEx(vid,1,1,alarm,doors,bonnet,boot,objective);
859 TextDrawSetString(InfoMotoreOnOff, " ");
860 TextDrawSetString(InfoMotoreOnOff, "on");
861 return 1;
862 }
863 else
864 {
865 new string[64];
866 format(string, sizeof(string), "%s gira la chiave e spegne il motore", Player[playerid][RPName]);
867 ProxDetector(15, playerid, string, COLOR_PURPLE);
868 //-------------------------
869 TextDrawSetString(InfoMotoreOnOff, " ");
870 TextDrawSetString(InfoMotoreOnOff, "off");
871 format(str, sizeof(str), "[Veicolo] Hai spento il motore");
872 SendClientMessage(playerid, COLOR_SYSTEM_INFO, str);
873 GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
874 SetVehicleParamsEx(vid,0,0,alarm,doors,bonnet,boot,objective);
875 return 1;
876 }
877 }
878 }
879 return 1;
880}
881
882
883
884
885public OnPlayerCommandText(playerid, cmdtext[])
886{
887/*
888 if (strcmp("/mycommand", cmdtext, true, 10) == 0)
889 {
890 // Do something here
891 return 1;
892 }*/
893 new stringerror[128];
894 format(stringerror, sizeof(stringerror), "{FF0000}[ERRORE] Il comando %s non esiste.{AFAFAF} usa /comandi", cmdtext);
895 return SendClientMessage(playerid, -1, stringerror);
896}
897
898
899
900
901//-------------------------------------------
902// dialoghi
903public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
904{
905
906 new const SECURITY_QUESTIONS[][MAX_SECURITY_QUESTION_SIZE] =
907 {
908 "What was your childhood nickname?",
909 "What is the name of your favorite childhood friend?",
910 "In what city or town did your mother and father meet?",
911 "What is the middle name of your oldest child?",
912 "What is your favorite team?",
913 "What is your favorite movie?",
914 "What is the first name of the boy or girl that you first kissed?",
915 "What was the make and model of your first car?",
916 "What was the name of the hospital where you were born?",
917 "Who is your childhood sports hero?",
918 "In what town was your first job?",
919 "What was the name of the company where you had your first job?",
920 "What school did you attend for sixth grade?",
921 "What was the last name of your third grade teacher?"
922 };
923
924 switch (dialogid)
925 {
926 case DIALOG_UNUSED: return 1; // Useful for dialogs that contain only information and we do nothing depending on whether they responded or not
927
928 case D_CAMBIA_INIZIO:
929 {
930 new string[64];
931 if(!response)
932 {
933 return 1;
934 }
935
936 if (strcmp(inputtext, Player[playerid][e_USER_SECURITY_ANSWER]) == 0)
937 {
938 format(string, sizeof(string), "{FF0000}[SUCCESSO]: Ora puoi cambiare le tue informazioni");
939 SendClientMessage(playerid, -1, string);
940 return 1;
941 }
942
943 else if(strlen(inputtext) != Player[playerid][e_USER_SECURITY_ANSWER])
944 {
945 format(string, sizeof(string), "{FF0000}[ERRORE]: La risposta di sicurezza: %s non è corretta", inputtext);
946 SendClientMessage(playerid, -1, string);
947 return 1;
948 }
949 /*
950 else if(!strlen(inputtext))
951 {
952 format(string, sizeof(string), "{FF0000}[ERRORE]: Devi inserire la risposta");
953 SendClientMessage(playerid, -1, string);
954 return 1;
955 }*/
956 return 1;
957 }
958/*
959
960 e_USER_SECURITY_QUESTION[MAX_SECURITY_QUESTION_SIZE],
961 e_USER_SECURITY_ANSWER[64],
962
963*/
964
965
966
967 case DIALOG_LOGIN:
968 {
969 if (!response)
970 {
971 Kick(playerid);
972 return 1;
973 }
974
975 new hashed_pass[65];
976 SHA256_PassHash(inputtext, Player[playerid][Salt], hashed_pass, 65);
977
978 if (strcmp(hashed_pass, Player[playerid][Password]) == 0)
979 {
980 //Player che si logga con successo
981 ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "Login con successo.", "Okay", "");
982 GetName(playerid);
983 cache_set_active(Player[playerid][Cache_ID]);
984 AssignPlayerData(playerid);
985 cache_delete(Player[playerid][Cache_ID]);
986 Player[playerid][Cache_ID] = MYSQL_INVALID_CACHE;
987 KillTimer(Player[playerid][LoginTimer]);
988 Player[playerid][LoginTimer] = 0;
989 Player[playerid][IsLoggedIn] = true;
990 new
991 utente[MAX_PLAYER_NAME],
992 string[256];
993 GetPlayerName(playerid, utente, sizeof(utente));
994 format(string, sizeof(string), "%s ha loggato nel server", utente);
995 print(string);
996 // Luogo di spawn dove spawna il player dopo il login
997// SetSpawnInfo(playerid, NO_TEAM, 0, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], 0, 0, 0, 0, 0, 0);
998 SetSpawnInfo(playerid, NO_TEAM, 0, DEFAULT_POS_X, DEFAULT_POS_Y, DEFAULT_POS_Z, DEFAULT_POS_A, 0, 0, 0, 0, 0, 0);
999 SpawnPlayer(playerid);
1000 }
1001 else
1002 {
1003 Player[playerid][LoginAttempts]++;
1004
1005 if (Player[playerid][LoginAttempts] >= 3)
1006 {
1007 ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "Hai superato i tentativi di accesso (3 tentativi).", "Okay", "");
1008 DelayedKick(playerid);
1009 }
1010 else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{FF0000}Password errata!\n{AFAFAF}Inserisci la password per entrare:", "Login", "Annulla");
1011 }
1012 }
1013 // Dialog - registrazione 1/6 password
1014 case DIALOG_REGISTER:
1015 {
1016 if (!response)
1017 {
1018 Kick(playerid);
1019 return 1;
1020 }
1021
1022 if (strlen(inputtext) <= 5) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registrazione... [Step: 1/6]", "{FF0000}[ERRORE:]Hai inserito una password troppo corta, usa almeno 5 caratteri!\n{AFAFAF}Inserisci una password per registrarti:", "Continua", "Annulla");
1023
1024 // 16 random characters from 33 to 126 (in ASCII) for the salt
1025 for (new i = 0; i < 16; i++) Player[playerid][Salt][i] = random(94) + 33;
1026 SHA256_PassHash(inputtext, Player[playerid][Salt], Player[playerid][Password], 65);
1027 new query[221];
1028 mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`) VALUES ('%e', '%s', '%e')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt]);
1029// mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
1030 new string[128];
1031 format(string, sizeof(string), "{AFAFAF}[INFO:] Ricorda la tua password è: {f4b642}'%s'", inputtext);
1032 SendClientMessage(playerid, COLOR_SYSTEM_INFO, string);
1033 format(string, sizeof(string), "{AFAFAF}[INFO:] Puoi cambiarla in game con il comando {ff0000}/cambia -> PASSWORD");
1034 SendClientMessage(playerid, COLOR_SYSTEM_INFO, string);
1035 ShowPlayerDialog(playerid, DIALOG_REGISTER_AGE, DIALOG_STYLE_INPUT, "Registrazione... [Step: 2/6]", "Inserisci l'età che vuoi avere nel server\nNon influenzerà il gioco", "Continua", "Annulla");
1036 }
1037 // Dialog - registrazione 2/6 etÃ
1038 case DIALOG_REGISTER_AGE:
1039 {
1040 if (!response)
1041 {
1042 Kick(playerid);
1043 return 1;
1044 }
1045
1046 if (!strlen(inputtext))
1047 {
1048 ShowPlayerDialog(playerid, DIALOG_REGISTER_AGE, DIALOG_STYLE_INPUT, "Registrazione... età [Step: 2/6]", "{FF0000}[ERRORE:]Devi inserire l'età per continuare!\n{AFAFAF}Non influenzerà il gioco:", "Continua", "Annulla");
1049 return 1;
1050 }
1051 else if (strlen(inputtext))
1052 {
1053 if (!IsNumeric(inputtext))
1054 {
1055 ShowPlayerDialog(playerid, DIALOG_REGISTER_AGE, DIALOG_STYLE_INPUT, "Registrazione... età [Step: 2/6]", "{FF0000}[ERRORE:]Devi inserire un numero per l'età !\n{AFAFAF}Non influenzerà il gioco:", "Continua", "Annulla");
1056 return 1;
1057 }
1058 else if (IsNumeric(inputtext))
1059 {
1060 new eta = strval(inputtext);
1061 if(eta < 18 || eta > 75)
1062 {
1063 ShowPlayerDialog(playerid, DIALOG_REGISTER_AGE, DIALOG_STYLE_INPUT, "Registrazione... età [Step: 2/6]", "{FF0000}[ERRORE:]Devi inserire un'età compresa tra 18 e 75!\n{AFAFAF}Non influenzerà il gioco:", "Continua", "Annulla");
1064 }
1065 else
1066 {
1067 new query[221];
1068 Player[playerid][Age] = strval(inputtext);
1069 //format(query, sizeof(query), "UPDATE `players` SET `age` = %d WHERE `id` = %d LIMIT 1", strval(inputtext), Player[playerid][ID]);
1070 mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`) VALUES ('%e', '%s', '%e', '%d')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age]);
1071 new string[128];
1072 format(string, sizeof(string), "{AFAFAF}[INFO:] Hai %d anni.", strval(inputtext));
1073 SendClientMessage(playerid, COLOR_SYSTEM_INFO, string);
1074 ShowPlayerDialog(playerid, DIALOG_REGISTER_SEX, DIALOG_STYLE_LIST, "Seleziona il sesso", "{FF6666}Donna\n{0000cc}Uomo", "Continua", "");
1075 }
1076 }
1077 }
1078 }
1079 // Dialog - registrazione 3/6 sesso
1080 case DIALOG_REGISTER_SEX:
1081 {
1082 if (!response)
1083 {
1084 Kick(playerid);
1085 return 1;
1086 }
1087 switch(listitem)// Dialog: registrazione fase 3: sesso
1088 {
1089 case 0: // Registrazione sesso: selezionato: donna
1090 {
1091// Player[playerid][Sex] = 1; // 1 = donna
1092
1093 format(Player[playerid][Sex], 64, "Donna");
1094 new query[221];
1095 mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`, `sex`) VALUES ('%e', '%s', '%e', '%d', '%s')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age], Player[playerid][Sex]);
1096// format(query, sizeof(query), "UPDATE `players` SET `sex` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Sex], Player[playerid][ID]);
1097// mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
1098 new Messaggio[256];
1099 format(Messaggio, sizeof (Messaggio), "{AFAFAF}[INFO]: %s sei {FF6666}una donna", Player[playerid][Name]);
1100 SendClientMessage(playerid, COLOR_SYSTEM_INFO, Messaggio);
1101 ShowPlayerDialog(playerid, DIALOG_REGISTER_EMAIL, DIALOG_STYLE_INPUT, "Registrazione - email [4/7]", "{FFFFFF}Inserisci una mail per proteggere l'account\nServirà in caso volessi cambiare la password o la domanda di sicurezza e la risposta\n{AFAFAF}Quest'ultima verrà mostrata solo a te stesso, usa una mail a cui puoi accedere", "Continua", "Annula");
1102
1103 PlayerPlaySound(playerid, 1054, 0.0, 0.0, 0.0);
1104
1105 }
1106 case 1: // Registrazione sesso: selezionato: uomo
1107 {
1108// Player[playerid][Sex] = 2; // 2 = uomo
1109 format(Player[playerid][Sex], 64, "Uomo");
1110 new query[221];
1111 mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`, `sex`) VALUES ('%e', '%s', '%e', '%d', '%s')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age], Player[playerid][Sex]);
1112 //format(query, sizeof(query), "UPDATE `players` SET `sex` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Sex], Player[playerid][ID]);
1113// mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
1114 new Messaggio[256];
1115 format(Messaggio, sizeof (Messaggio), "[INFO]: %s sei {0000cc}un uomo", Player[playerid][Name]);
1116 SendClientMessage(playerid, COLOR_SYSTEM_INFO, Messaggio);
1117
1118 ShowPlayerDialog(playerid, DIALOG_REGISTER_EMAIL, DIALOG_STYLE_INPUT, "Registrazione - email [4/7]", "{FFFFFF}Inserisci una mail per proteggere l'account\nServirà in caso volessi cambiare la password o la domanda di sicurezza e la risposta\n{AFAFAF}Quest'ultima verrà mostrata solo a te stesso, usa una mail a cui puoi accedere", "Continua", "Annula");
1119 PlayerPlaySound(playerid, 1054, 0.0, 0.0, 0.0);
1120 //******
1121 }
1122 }
1123 }
1124 case DIALOG_REGISTER_EMAIL:
1125 {
1126 if (!response)
1127 {
1128 Kick(playerid);
1129 return 1;
1130 }
1131 else
1132 {
1133 if (IsEmailString(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER_EMAIL, DIALOG_STYLE_INPUT, "Registrazione... [Step: 4/6]", "{FF0000}[ERRORE:]Devi inserire una mail valida\n{AFAFAF}Servirà per proteggere il tuo acount e cambiare domanda e/o risposta di sicurezza:", "Continua", "Annulla");
1134// new query[221];
1135 new StringEmail[64];
1136
1137 format(StringEmail, sizeof(StringEmail), "[INFO]: La tua email sarà %s", inputtext);
1138 SendClientMessage(playerid, COLOR_SYSTEM_INFO, StringEmail);
1139 SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[INFO]: Puoi cambiarla con il comando /cambia -> email");
1140 format(Player[playerid][PlayerEmail], 128, inputtext);
1141
1142// mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`, `sex`, `email`) VALUES ('%e', '%s', '%e', '%d', '%d', '%s')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age], Player[playerid][Sex], Player[playerid][PlayerEmail]);
1143// mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
1144
1145 new list[2 + (sizeof(SECURITY_QUESTIONS) * MAX_SECURITY_QUESTION_SIZE)];
1146 for (new i; i < sizeof(SECURITY_QUESTIONS); i++)
1147 {
1148 strcat(list, SECURITY_QUESTIONS[i]);
1149 strcat(list, "\n");
1150 }
1151 ShowPlayerDialog(playerid, DIALOG_REGISTER_DOMANDASEC, DIALOG_STYLE_LIST, "Registrazione - Domanda di sicurezza", list, "Continua", "Annulla");
1152
1153 }
1154 }
1155 case DIALOG_REGISTER_DOMANDASEC:
1156 {
1157 if (!response)
1158 {
1159 Kick(playerid);
1160 return 1;
1161 }
1162 else
1163 {
1164 format(Player[playerid][e_USER_SECURITY_QUESTION], MAX_SECURITY_QUESTION_SIZE, SECURITY_QUESTIONS[listitem]);
1165 new query[1024]; //221
1166 mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`, `sex`, `email`, `domandasec`) VALUES ('%e', '%s', '%e', '%d', '%s', '%s', '%e')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age], Player[playerid][Sex], Player[playerid][PlayerEmail], Player[playerid][e_USER_SECURITY_QUESTION]);
1167 new string[128];
1168 format(string, sizeof(string), "{AFAFAF}Hai selezionato come domanda di sicurezza:\n%s\n{FFFFFF}Inserisci una risposta di sicurezza", Player[playerid][e_USER_SECURITY_QUESTION]);
1169 ShowPlayerDialog(playerid, DIALOG_REGISTER_RISPOSTASEC, DIALOG_STYLE_INPUT, "Registrazione - Domanda di sicurezza [6/6]", string, "Continua", "Annuila");
1170 }
1171 }
1172 case DIALOG_REGISTER_RISPOSTASEC:
1173 {
1174 if (!response)
1175 {
1176 Kick(playerid);
1177 return 1;
1178 }
1179 else
1180 {
1181 new string[128];
1182 format(string, sizeof(string), "{FF0000}Devi inserire una risposta alla domanda di sicurezza!\n{AFAFAF}Hai selezionato come domanda di sicurezza:\n%s\n{FFFFFF}Inserisci una risposta di sicurezza", Player[playerid][e_USER_SECURITY_QUESTION]);
1183
1184 if (strlen(inputtext) <= 2) return ShowPlayerDialog(playerid, DIALOG_REGISTER_RISPOSTASEC, DIALOG_STYLE_INPUT, "Registrazione - Domanda di sicurezza [6/6]", string, "Continua", "Annuila");
1185
1186 format(Player[playerid][e_USER_SECURITY_ANSWER], 128, inputtext);
1187 new query[1024];
1188 mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`, `sex`, `email`, `domandasec`, `rispostasec`) VALUES ('%e', '%s', '%e', '%d', '%s', '%s', '%e', '%s')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age], Player[playerid][Sex], Player[playerid][PlayerEmail], Player[playerid][e_USER_SECURITY_QUESTION], Player[playerid][e_USER_SECURITY_ANSWER]);
1189 mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
1190 }
1191 }
1192 case DIALOG_PROVA:
1193 {
1194 GivePlayerMoney(playerid, strval(inputtext));
1195 return 1;
1196 }
1197
1198
1199
1200 default: return 0; // dialog ID was not found, search in other scripts
1201 }
1202 return 1;
1203}
1204
1205//-----------------------------------------------------
1206
1207// controllo se una string è numerica
1208IsNumeric(const string[])
1209{
1210 for (new i = 0, j = strlen(string); i < j; i++)
1211 {
1212 if (string[i] > '9' || string[i] < '0') return 0;
1213 }
1214 return 1;
1215}
1216
1217// controllo se una string è numerica
1218IsEmailString(const string[])
1219{/*
1220 for (new i = 0, j = strlen(string); i < j; i++)
1221 {
1222 if (string[i] == '@') return 0;
1223 }*/
1224 if(strfind(string,"@",true) && strfind(string,".com",true) != (-1)) return 0;
1225 else if(strfind(string,"@",true) && strfind(string,".it",true) != (-1)) return 0;
1226 else if(strfind(string,"@",true) && strfind(string,".net",true) != (-1)) return 0;
1227 else if(strfind(string,"@",true) && strfind(string,".pec",true) != (-1)) return 0;
1228 else if(strfind(string,"@",true) && strfind(string,".org",true) != (-1)) return 0;
1229 return 1;
1230}
1231
1232
1233
1234//--------------------
1235// Tachimetro
1236/*
1237forward RefreshVehInfoStats(playerid);
1238public RefreshVehInfoStats(playerid)
1239{
1240 new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
1241 vehicleid = GetPlayerVehicleID(playerid);
1242 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
1243 if(engine == 0)
1244 {
1245 InfoMotoreOnOff = TextDrawCreate(506.471435, 352.916687, "off");
1246 }
1247 else if(engine == 1)
1248 {
1249 InfoMotoreOnOff = TextDrawCreate(506.471435, 352.916687, "on");
1250 }
1251 FloatVitaMotore = TextDrawCreate(532.240173, 338.916687, "floatmotorehealth");
1252 final_vehicle_health = floatround(floatround(vehicle_health - 250)/ 7.5); //This will make the health show at 100 when the vehicle is not damaged and at 0 when it is in fire.
1253 format(health_string,256,"Health %i", final_vehicle_health);
1254
1255
1256
1257
1258
1259 for(new c=0;c<MAX_VEHICLES;c++)
1260 {
1261 EngineStatus[c] = 0;
1262 GetVehicleParamsEx(c,engine,lights,alarm,doors,bonnet,boot,objective);
1263 SetVehicleParamsEx(c,0,0,alarm,doors,bonnet,boot,objective);
1264 LuciVeicolo[c] = 0;
1265 }
1266
1267
1268
1269
1270 return 1;
1271}
1272*/
1273
1274
1275
1276forward Speedometer(playerid);
1277public Speedometer(playerid)
1278{
1279 new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
1280 vehicleid = GetPlayerVehicleID(playerid);
1281 new Float:vehicle_health,final_vehicle_health,health_string[256];
1282 if(vehicleid != 0)
1283 {
1284 GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
1285 final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*250.666667; // 250.666667 = kmph // 199,4166672= mph
1286 final_speed_int = floatround(final_speed,floatround_round);
1287 format(speed_string,256,"%i Km/h",final_speed_int);
1288 TextDrawSetString(SPEEDOS[playerid], speed_string);
1289 GetVehicleHealth(vehicleid,vehicle_health);
1290 final_vehicle_health = floatround(floatround(vehicle_health - 250)/ 7.5); //This will make the health show at 100 when the vehicle is not damaged and at 0 when it is in fire.
1291 format(health_string,256,"%i%", final_vehicle_health);
1292 TextDrawSetString(HEALTH[playerid], health_string);
1293
1294
1295 TextDrawSetString(FloatVitaMotore, health_string);
1296 TextDrawSetString(NumeroVelocitaVeh, speed_string);
1297
1298 TextDrawShowForPlayer(playerid, BoxVeicolo);
1299 TextDrawShowForPlayer(playerid, TitoloBoxInfoVeicolo);
1300 TextDrawShowForPlayer(playerid, TitoloMotoreVita);
1301 TextDrawShowForPlayer(playerid, InfoMotoreOnOff);
1302 TextDrawShowForPlayer(playerid, TitoloStatoMotore);
1303 TextDrawShowForPlayer(playerid, FloatVitaMotore);
1304 TextDrawShowForPlayer(playerid, CodiceNomeVeicolo);
1305 TextDrawShowForPlayer(playerid, TitoloVelocita);
1306 TextDrawShowForPlayer(playerid, NumeroVelocitaVeh);
1307
1308
1309 new vid = GetPlayerVehicleID(playerid);
1310 GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
1311 if(engine == 1)
1312 {
1313 TextDrawSetString(InfoMotoreOnOff, "on");
1314 return 1;
1315 }
1316 else if(engine == 0)
1317 {
1318 TextDrawSetString(InfoMotoreOnOff, "off");
1319 return 1;
1320 }
1321
1322
1323
1324 }
1325 else
1326 {
1327 TextDrawHideForPlayer(playerid, BoxVeicolo);
1328 TextDrawHideForPlayer(playerid, TitoloBoxInfoVeicolo);
1329 TextDrawHideForPlayer(playerid, TitoloMotoreVita);
1330 TextDrawHideForPlayer(playerid, InfoMotoreOnOff);
1331 TextDrawHideForPlayer(playerid, TitoloStatoMotore);
1332 TextDrawHideForPlayer(playerid, FloatVitaMotore);
1333 TextDrawHideForPlayer(playerid, CodiceNomeVeicolo);
1334 TextDrawHideForPlayer(playerid, TitoloVelocita);
1335 TextDrawHideForPlayer(playerid, NumeroVelocitaVeh);
1336
1337 TextDrawHideForPlayer(playerid, SPEEDOS[playerid]);
1338 TextDrawHideForPlayer(playerid, HEALTH[playerid]);
1339
1340// TextDrawSetString(SPEEDOS[playerid], " ");
1341// TextDrawSetString(HEALTH[playerid], " ");
1342 }
1343 return 1;
1344}
1345
1346
1347
1348
1349
1350forward OnPlayerDataLoaded(playerid, race_check);
1351public OnPlayerDataLoaded(playerid, race_check)
1352{
1353 /* race condition check:
1354 player A connects -> SELECT query is fired -> this query takes very long
1355 while the query is still processing, player A with playerid 2 disconnects
1356 player B joins now with playerid 2 -> our laggy SELECT query is finally finished, but for the wrong player
1357 what do we do against it?
1358 we create a connection count for each playerid and increase it everytime the playerid connects or disconnects
1359 we also pass the current value of the connection count to our OnPlayerDataLoaded callback
1360 then we check if current connection count is the same as connection count we passed to the callback
1361 if yes, everything is okay, if not, we just kick the player
1362 */
1363 if (race_check != g_MysqlRaceCheck[playerid]) return Kick(playerid);
1364
1365 new string[115];
1366 if(cache_num_rows() > 0)// Giocatore registrato sul server
1367 {
1368 cache_get_value(0, "password", Player[playerid][Password], 65);
1369 cache_get_value(0, "salt", Player[playerid][Salt], 17);
1370 Player[playerid][Cache_ID] = cache_save();
1371
1372 format(string, sizeof string, "%s risulta registrato sul server.\nInserisci la password per entrare:", Player[playerid][Name]);
1373 ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Annulla");
1374 Player[playerid][LoginTimer] = SetTimerEx("OnLoginTimeout", SECONDS_TO_LOGIN * 1000, false, "d", playerid);
1375 }
1376 else // Giocatore non registrato sul server
1377 {
1378 format(string, sizeof string, "Benvenuto %s,\nPer iniziare a registrarti su %s, inserisci una password", Player[playerid][Name], nomeserver);
1379 ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registrazione [1/6]", string, "Continua", "Annulla");
1380 }
1381 return 1;
1382}
1383
1384forward OnLoginTimeout(playerid);
1385public OnLoginTimeout(playerid)
1386{
1387 // reset the variable that stores the timerid
1388 Player[playerid][LoginTimer] = 0;
1389
1390 ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "Sei stato kickato dal server per aver impiegato troppo tempo nel loggarti.", "Okay", "");
1391 DelayedKick(playerid);
1392 return 1;
1393}
1394
1395/*
1396forward pulaporta3(playerid);
1397public pulaporta3(playerid)
1398{
1399 MoveObject(PulaPorta3, 228.2998, 162.10059, 1004.7, 5.0);
1400}
1401*/
1402forward pulap2(playerid);
1403public pulap2(playerid)
1404{
1405 MoveObject(PulaPorta2, 228.2998, 152.09961, 1004.7, 5.0);
1406}
1407
1408forward pulap3(playerid);
1409public pulap3(playerid)
1410{
1411 MoveObject(PulaPorta3, 230.62199, 169.8, 1004.7, 5.0);
1412}
1413
1414
1415forward mostracartadidentitaame(playerid);
1416public mostracartadidentitaame(playerid)
1417{
1418 TextDrawHideForPlayer(playerid, doc_boxcartadidentita);
1419 TextDrawHideForPlayer(playerid, doc_cartadidentitatitolo);
1420 TextDrawHideForPlayer(playerid, doc_nomecognomeplayer);
1421 TextDrawHideForPlayer(playerid, doc_codicenome);
1422 TextDrawHideForPlayer(playerid, doc_etaplayer);
1423 TextDrawHideForPlayer(playerid, doc_codiceeta);
1424 TextDrawHideForPlayer(playerid, doc_casaplayer);
1425 TextDrawHideForPlayer(playerid, doc_codicecasaplayer);
1426 TextDrawHideForPlayer(playerid, doc_lavoroplayer);
1427 TextDrawHideForPlayer(playerid, doc_codicelavorofazione);
1428 TextDrawHideForPlayer(playerid, doc_nomesindaco);
1429 TextDrawHideForPlayer(playerid, doc_codicenomesindaco);
1430 return 1;
1431}
1432
1433
1434forward mostracartadidentita(TargetPlayerDOC);
1435public mostracartadidentita(TargetPlayerDOC)
1436{
1437 TextDrawHideForPlayer(TargetPlayerDOC, doc_boxcartadidentita);
1438 TextDrawHideForPlayer(TargetPlayerDOC, doc_cartadidentitatitolo);
1439 TextDrawHideForPlayer(TargetPlayerDOC, doc_nomecognomeplayer);
1440 TextDrawHideForPlayer(TargetPlayerDOC, doc_codicenome);
1441 TextDrawHideForPlayer(TargetPlayerDOC, doc_etaplayer);
1442 TextDrawHideForPlayer(TargetPlayerDOC, doc_codiceeta);
1443 TextDrawHideForPlayer(TargetPlayerDOC, doc_casaplayer);
1444 TextDrawHideForPlayer(TargetPlayerDOC, doc_codicecasaplayer);
1445 TextDrawHideForPlayer(TargetPlayerDOC, doc_lavoroplayer);
1446 TextDrawHideForPlayer(TargetPlayerDOC, doc_codicelavorofazione);
1447 TextDrawHideForPlayer(TargetPlayerDOC, doc_nomesindaco);
1448 TextDrawHideForPlayer(TargetPlayerDOC, doc_codicenomesindaco);
1449 return 1;
1450}
1451
1452// timer kick nome non rp
1453forward KickTimerNameRP(playerid);
1454public KickTimerNameRP(playerid)
1455{
1456 Kick(playerid);
1457}
1458
1459
1460
1461//-----------------------------------------------------
1462// stocks
1463
1464// Stock per mandare un messaggio agli admin
1465stock SendMessageToAdmins(text[])
1466{
1467 for(new i = 0; i < MAX_PLAYERS; i++)
1468 {
1469 if(Player[i][Admin] >= 1)
1470 {
1471 SendClientMessage(i, COLOR_SYSTEM_ADMIN, text);
1472 }
1473 }
1474}
1475// Stock chat staff
1476stock ChatStaffMember(text[])
1477{
1478 for(new i = 0; i < MAX_PLAYERS; i++)
1479 {
1480 if(Player[i][Admin] >= 1)
1481 {
1482 SendClientMessage(i, COLOR_SYSTEM_ADMIN, text);
1483 }
1484 }
1485}
1486
1487
1488
1489
1490forward OnPlayerRegister(playerid);
1491public OnPlayerRegister(playerid)
1492{
1493 // retrieves the ID generated for an AUTO_INCREMENT column by the sent query
1494 Player[playerid][ID] = cache_insert_id();
1495
1496 ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Registration", "Account successfully registered, you have been automatically logged in.", "Okay", "");
1497
1498 Player[playerid][IsLoggedIn] = true;
1499
1500 format(Player[playerid][PatenteA], 64, "Si");
1501 format(Player[playerid][PatenteB], 64, "Si");
1502 format(Player[playerid][PatenteC], 64, "Si");
1503 format(Player[playerid][PatenteD], 64, "Si");
1504 format(Player[playerid][PortoDarmi], 64, "No");
1505 Player[playerid][Warns] = 0;
1506
1507 GivePlayerMoney(playerid, 500);
1508
1509
1510 Player[playerid][X_Pos] = DEFAULT_POS_X;
1511 Player[playerid][Y_Pos] = DEFAULT_POS_Y;
1512 Player[playerid][Z_Pos] = DEFAULT_POS_Z;
1513 Player[playerid][A_Pos] = DEFAULT_POS_A;
1514 Player[playerid][Interior] = DEFAULT_POS_INTERIOR;
1515
1516 SetSpawnInfo(playerid, NO_TEAM, 0, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], 0, 0, 0, 0, 0, 0);
1517 SetPlayerInterior(playerid, DEFAULT_POS_INTERIOR);
1518 SpawnPlayer(playerid);
1519 return 1;
1520}
1521
1522forward _KickPlayerDelayed(playerid);
1523public _KickPlayerDelayed(playerid)
1524{
1525 Kick(playerid);
1526 return 1;
1527}
1528
1529
1530//-----------------------------------------------------
1531// login player
1532AssignPlayerData(playerid)
1533{ // quando il player effettua il login
1534 // ID
1535 cache_get_value_int(0, "id", Player[playerid][ID]);
1536 // Kill fatte
1537 cache_get_value_int(0, "kills", Player[playerid][Kills]);
1538 // Patente A
1539 cache_get_value_name(0, "patentea", Player[playerid][PatenteA], 64);
1540 // Patente B
1541 cache_get_value_name(0, "patenteb", Player[playerid][PatenteB], 64);
1542 // Patente C
1543 cache_get_value_name(0, "patentec", Player[playerid][PatenteC], 64);
1544 // Patente D
1545 cache_get_value_name(0, "patented", Player[playerid][PatenteD], 64);
1546 // Porto D'armi
1547 cache_get_value_name(0, "portodarmi", Player[playerid][PortoDarmi], 64);
1548 // Soldi
1549 cache_get_value_int(0, "soldi", Player[playerid][Soldi]);
1550 // Numero di morti
1551 cache_get_value_int(0, "deaths", Player[playerid][Deaths]);
1552 // Livello admin
1553 cache_get_value_int(0, "admin", Player[playerid][Admin]);
1554 // Se in servizio admin
1555 cache_get_value_int(0, "aduty", Player[playerid][ADuty]);
1556 // Sesso
1557 cache_get_value_name(0, "sex", Player[playerid][Sex], 64);
1558 // EtÃ
1559 cache_get_value_int(0, "age", Player[playerid][Age]);
1560 // Numero di warns
1561 cache_get_value_int(0, "warns", Player[playerid][Warns]);
1562 // Ultima posizione 'X'
1563 cache_get_value_float(0, "x", Player[playerid][X_Pos]);
1564 // Ultima posizione 'Y'
1565 cache_get_value_float(0, "y", Player[playerid][Y_Pos]);
1566 // Ultima posizione 'Z'
1567 cache_get_value_float(0, "z", Player[playerid][Z_Pos]);
1568 // Ultima posizione 'Angolo visuale'
1569 cache_get_value_float(0, "angle", Player[playerid][A_Pos]);
1570 // Vita
1571 cache_get_value_float(0, "vita", Player[playerid][Vita]);
1572 // Armatura
1573 cache_get_value_float(0, "armatura", Player[playerid][Armatura]);
1574 // Ultima posizione 'Interior'
1575 cache_get_value_int(0, "interior", Player[playerid][Interior]);
1576 // Domanda di sicurezza scelta
1577 cache_get_value_name(0, "domandasec", Player[playerid][e_USER_SECURITY_QUESTION], MAX_SECURITY_QUESTION_SIZE);
1578 // Risposta alla domanda di sicurezza
1579 cache_get_value_name(0, "rispostasec", Player[playerid][e_USER_SECURITY_ANSWER], 128);
1580 // Email
1581 cache_get_value_name(0, "email", Player[playerid][PlayerEmail], 128);
1582 // Id fazione partecipante
1583 cache_get_value_name_int(0, "FactionID", Player[playerid][FactionID]);
1584 // Rank nella fazione partecipante
1585 cache_get_value_name_int(0, "FactionRank", Player[playerid][FactionRank]);
1586
1587 //================
1588 GivePlayerSavedWeapon(playerid);
1589// GivePlayerWeapon(playerid, Player[playerid][WeapID], Player[playerid][WeapAmmo]);
1590 // setting statistiche
1591 GivePlayerMoney(playerid, Player[playerid][Soldi]);
1592 SetPlayerHealth(playerid, Player[playerid][Vita]);
1593 SetPlayerArmour(playerid, Player[playerid][Armatura]);
1594
1595
1596
1597
1598
1599 return 1;
1600}
1601
1602DelayedKick(playerid, time = 500)
1603{
1604 SetTimerEx("_KickPlayerDelayed", time, false, "d", playerid);
1605 return 1;
1606}
1607
1608SetupPlayerTable()
1609{
1610 mysql_tquery(g_SQL, "CREATE TABLE IF NOT EXISTS `players` (`id` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(24) NOT NULL,`password` char(64) NOT NULL,`salt` char(16) NOT NULL,`kills` mediumint(8) NOT NULL DEFAULT '0',`deaths` mediumint(8) NOT NULL DEFAULT '0',`x` float NOT NULL DEFAULT '0',`y` float NOT NULL DEFAULT '0',`z` float NOT NULL DEFAULT '0',`angle` float NOT NULL DEFAULT '0',`interior` tinyint(3) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`))");
1611 return 1;
1612}
1613
1614// aggiornamento dati giocatore quando si disconnette
1615UpdatePlayerData(playerid, reason)
1616{
1617 if (Player[playerid][IsLoggedIn] == false) return 0;
1618
1619 // if the client crashed, it's not possible to get the player's position in OnPlayerDisconnect callback
1620 // so we will use the last saved position (in case of a player who registered and crashed/kicked, the position will be the default spawn point)
1621 if (reason == 1)
1622 {
1623 GetPlayerPos(playerid, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos]);
1624 GetPlayerFacingAngle(playerid, Player[playerid][A_Pos]);
1625 }
1626
1627 new query[1024];
1628// mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `x` = %f, soldi = `%d`, portodarmi = `%s`, `y` = %f, `z` = %f, `angle` = %f, `interior` = %d WHERE `id` = %d LIMIT 1", Player[playerid][X_Pos], GetPlayerMoney(playerid), Player[playerid][PortoDarmi], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], GetPlayerInterior(playerid), Player[playerid][ID]);
1629 mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `soldi` = %d WHERE `id` = %d LIMIT 1", GetPlayerMoney(playerid), Player[playerid][ID]);
1630// mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `age`) VALUES ('%e', '%s', '%e', '%d')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt], Player[playerid][Age]);
1631 mysql_tquery(g_SQL, query);
1632
1633
1634
1635 return 1;
1636}
1637
1638UpdatePlayerWeapons(playerid)
1639{
1640 new
1641 weaponid,
1642 munizioni;
1643
1644 for(new i; i < 13; i++) // looping through all weapon slots (0 - 12)
1645 {
1646 GetPlayerWeaponData(playerid, i, weaponid, munizioni); // get weaponid and ammo
1647
1648 if(!weaponid) continue; // don't insert if there's no weapon in this slot
1649 new query[145];
1650 mysql_format(g_SQL, query, sizeof query, "INSERT INTO armi VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE munizioni = %d;", Player[playerid][ID], weaponid, munizioni, munizioni);
1651 mysql_tquery(g_SQL, query);
1652 }
1653
1654 return 1;
1655}
1656/*
1657GivePlayerSavedWeapon(playerid)
1658{
1659 new query[145], Cache: weapon;
1660 mysql_format(g_SQL, query, sizeof query, "SELECT `idarma`, `munizioni` FROM `armi` WHERE `ID` = %d ORDER BY `idarma`", Player[playerid][ID]);
1661 weapon = mysql_query(g_SQL, query);
1662 new rows = cache_num_rows();
1663 if(rows)
1664 {
1665 new weaponid, ammo;
1666
1667 cache_get_value_name_int(0, "idarma", weaponid);
1668 cache_get_value_name_int(0, "munizioni", ammo);
1669
1670 GivePlayerWeapon(playerid, weaponid, ammo);
1671
1672
1673 mysql_tquery(g_SQL, query);
1674 }
1675 cache_delete(weapon);
1676}
1677*/
1678
1679GivePlayerSavedWeapon(playerid)
1680{
1681 new query[256];
1682 new armap, munizionip;
1683 mysql_format(g_SQL, query, sizeof(query), "SELECT `idarma`, `munizioni` FROM `armi` WHERE `ID`=%d ORDER BY `idarma` ASC", armap, munizionip, pID[playerid]);
1684 cache_get_value_int(0, "idarma", Player[playerid][WeapID]);
1685 cache_get_value_int(0, "munizioni", Player[playerid][WeapAmmo]);
1686 GivePlayerWeapon(playerid, Player[playerid][WeapID], Player[playerid][WeapAmmo]);
1687 mysql_tquery(g_SQL, query);
1688 return 1;
1689}
1690
1691
1692
1693UpdatePlayerDeaths(playerid)
1694{
1695 if (Player[playerid][IsLoggedIn] == false) return 0;
1696
1697 Player[playerid][Deaths]++;
1698
1699 new query[70];
1700 mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `deaths` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Deaths], Player[playerid][ID]);
1701 mysql_tquery(g_SQL, query);
1702 return 1;
1703}
1704
1705UpdatePlayerKills(killerid)
1706{
1707 // we must check before if the killer wasn't valid (connected) player to avoid run time error 4
1708 if (killerid == INVALID_PLAYER_ID) return 0;
1709 if (Player[killerid][IsLoggedIn] == false) return 0;
1710
1711 Player[killerid][Kills]++;
1712
1713 new query[70];
1714 mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `kills` = %d WHERE `id` = %d LIMIT 1", Player[killerid][Kills], Player[killerid][ID]);
1715 mysql_tquery(g_SQL, query);
1716 return 1;
1717}
1718//-----------------------------------------------------------------------
1719// comandi - zcmd
1720
1721CMD:apri(playerid, params[])
1722{
1723 new
1724 CheckInterior,
1725 CheckFaction;
1726 CheckInterior = GetPlayerInterior(playerid);
1727 CheckFaction = Player[playerid][FactionID];
1728
1729 //==========================================================================================
1730 // fazione polizia
1731 // Prima porta pula
1732 if(IsPlayerInRangeOfPoint(playerid, 4.0, 230.62199, 169.8, 1004.7) && CheckInterior == 3 && CheckFaction == 1)
1733 { // porta deitro al bancone (vinico le scale)
1734 timerP[playerid] = SetTimerEx("pulap3", 2000, false, "i", playerid);
1735 MoveObject(PulaPorta3, 228.922, 169.8, 1004.7, 5.0);
1736 return 1;
1737 }
1738 if(IsPlayerInRangeOfPoint(playerid, 4.0, 228.2998, 152.09961, 1004.7) && CheckInterior == 3 && CheckFaction == 1)
1739 {
1740 timerP[playerid] = SetTimerEx("pulap2", 2000, false, "i", playerid);
1741 MoveObject(PulaPorta2, 228.3, 150.39999, 1004.7, 5.0);
1742 return 1;
1743 }/*
1744 if(IsPlayerInRangeOfPoint(playerid, 2, 228.2998, 162.10059, 1004.7) && checkinterior == 3 )
1745 {
1746 SetTimer("pulaporta3", 1500, false);
1747 MoveObject(PulaPorta3, 228.3, 160.3, 1004.7, 5.0);
1748 return 1;
1749 }*/
1750 return 1;
1751}
1752/*
1753 PulaPorta1 = CreateObject(2930, 230.62199, 169.8, 1004.7, 0.0, 0.0, 90.0, 100); // object (chinaTgate) (1)
1754 PulaPorta2 = CreateObject(2930, 228.2998, 152.09961, 1004.7, 0.0, 0.0, 0.0, 100); // object (chinaTgate) (2)
1755 PulaPorta3 = CreateObject(2930, 228.2998, 162.10059, 1004.7, 0.0, 0.0, 0.0, 100); // object (chinaTgate) (3)
1756
1757*/
1758
1759
1760
1761
1762CMD:entra(playerid, params[])
1763{
1764 new checkinterior = GetPlayerInterior(playerid);
1765 // Fuori dalla caserma di polizia (per entrare)
1766 if(IsPlayerInRangeOfPoint(playerid,2, -1605.6217,711.8565,13.8672) && checkinterior == 0 )
1767 {
1768 SetPlayerInterior(playerid, 3);
1769 SetPlayerPos(playerid, 238.8014,139.3253,1003.0234);
1770 return 1;
1771 }
1772 return 1;
1773}
1774
1775CMD:esci(playerid, params[])
1776{
1777 new checkinterior = GetPlayerInterior(playerid);
1778 // Dentro la caserma di polizia (per uscire)
1779 if(IsPlayerInRangeOfPoint(playerid, 2, 238.8014,139.3253,1003.0234) && checkinterior == 3 )
1780 {
1781 SetPlayerInterior(playerid, 0);
1782 SetPlayerPos(playerid, -1605.6217,711.8565,13.8672);
1783 return 1;
1784 }
1785 return 1;
1786}
1787
1788/*
1789 e_USER_SECURITY_QUESTION[MAX_SECURITY_QUESTION_SIZE],
1790 e_USER_SECURITY_ANSWER[64],
1791 */
1792CMD:cambia(playerid, params[])
1793{ // comando per cambiare password, email, ecc
1794 new
1795 titolo[64],
1796 info[64];
1797 format(titolo, sizeof(titolo), "Inserisci la risposta di sicurezza alla domanda");
1798 format(info, sizeof(info), "{00FF00}%s",Player[playerid][e_USER_SECURITY_QUESTION]);
1799 SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[ATTENZIONE]: In questa sezione puoi cambiare password ecc del tuo pg");
1800 ShowPlayerDialog(playerid, D_CAMBIA_INIZIO, DIALOG_STYLE_INPUT, titolo, info, "Continua", "Esci");
1801 return 1;
1802}
1803
1804
1805
1806CMD:mostracd(playerid, params[])
1807{
1808 new
1809 TargetPlayerDOC,
1810 TargetPlayerDOCName[MAX_PLAYER_NAME],
1811 PlayerName[MAX_PLAYER_NAME];
1812
1813 GetPlayerName(TargetPlayerDOC, TargetPlayerDOCName, sizeof(TargetPlayerDOCName));
1814 GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
1815
1816 if(sscanf(params, "u", TargetPlayerDOC))
1817 {
1818 SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[COMANDO]: Uso /m(ostra)cd [id/nome]");
1819 return 1;
1820 }
1821 if(!IsPlayerConnected(TargetPlayerDOC))
1822 { // Messaggio d'errore se: giocatore non trovato/connesso
1823 SendClientMessage(playerid, COLOR_SYSTEM_ERROR,
1824 "[ERRORE:] Il giocatore selezionato non è connesso o hai sbagliato ID/nome");
1825 return 1;
1826 }
1827 else if(TargetPlayerDOC != playerid)
1828 {
1829 TextDrawSetString(doc_codicenome, Player[playerid][RPName]);
1830 TextDrawSetString(doc_codiceeta, Player[playerid][Age]);
1831
1832
1833 TextDrawShowForPlayer(TargetPlayerDOC, doc_boxcartadidentita);
1834 TextDrawShowForPlayer(TargetPlayerDOC, doc_cartadidentitatitolo);
1835 TextDrawShowForPlayer(TargetPlayerDOC, doc_nomecognomeplayer);
1836 TextDrawShowForPlayer(TargetPlayerDOC, doc_codicenome);
1837 TextDrawShowForPlayer(TargetPlayerDOC, doc_etaplayer);
1838 TextDrawShowForPlayer(TargetPlayerDOC, doc_codiceeta);
1839 TextDrawShowForPlayer(TargetPlayerDOC, doc_casaplayer);
1840 TextDrawShowForPlayer(TargetPlayerDOC, doc_codicecasaplayer);
1841 TextDrawShowForPlayer(TargetPlayerDOC, doc_lavoroplayer);
1842 TextDrawShowForPlayer(TargetPlayerDOC, doc_codicelavorofazione);
1843 TextDrawShowForPlayer(TargetPlayerDOC, doc_nomesindaco);
1844 TextDrawShowForPlayer(TargetPlayerDOC, doc_codicenomesindaco);
1845 SetTimer("mostracartadidentita", 50, false);
1846 return 1;
1847 }
1848 else if(TargetPlayerDOC == playerid)
1849 {
1850 TextDrawSetString(doc_codicenome, Player[playerid][RPName]);
1851 TextDrawSetString(doc_codiceeta, Player[playerid][Age]);
1852
1853 TextDrawShowForPlayer(playerid, doc_boxcartadidentita);
1854 TextDrawShowForPlayer(playerid, doc_cartadidentitatitolo);
1855 TextDrawShowForPlayer(playerid, doc_nomecognomeplayer);
1856 TextDrawShowForPlayer(playerid, doc_codicenome);
1857 TextDrawShowForPlayer(playerid, doc_etaplayer);
1858 TextDrawShowForPlayer(playerid, doc_codiceeta);
1859 TextDrawShowForPlayer(playerid, doc_casaplayer);
1860 TextDrawShowForPlayer(playerid, doc_codicecasaplayer);
1861 TextDrawShowForPlayer(playerid, doc_lavoroplayer);
1862 TextDrawShowForPlayer(playerid, doc_codicelavorofazione);
1863 TextDrawShowForPlayer(playerid, doc_nomesindaco);
1864 TextDrawShowForPlayer(playerid, doc_codicenomesindaco);
1865 SetTimer("mostracartadidentitaame", 50, false);
1866// SetTimerEx("mostracartadidentitaame", 5000, 1, "d", playerid);
1867 return 1;
1868 }
1869 return 1;
1870}
1871
1872CMD:specoff(playerid, params[])
1873{
1874 if(Player[playerid][Admin] >= 1)
1875 {
1876 new string[128];
1877 if(Player[playerid][AdminSpec] == 1)
1878 {
1879 format(string, sizeof(string), "{AFAFAF}[SPEC]: Non stai più vedendo {FF0000}%s", Player[playerid][AdminWhoSpec]);
1880 SendClientMessage(playerid, -1, string);
1881 Player[playerid][AdminWhoSpec] = 0;
1882 TogglePlayerControllable(playerid,true);
1883 Player[playerid][AdminSpec] = 0;
1884 return 1;
1885 }
1886 else
1887 {
1888 SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "[ERRORE]: Non stai spectando nessuno");
1889 return 1;
1890 }
1891 }
1892 else
1893 {
1894 SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "[ERRORE]: Non sei autorizzato ad usare questo comando.");
1895 return 1;
1896 }
1897}
1898
1899CMD:specplayer(playerid, params[])
1900{
1901 if(Player[playerid][Admin] >= 1)
1902 {
1903 new
1904 TargetPlayer,
1905 TargetPName[MAX_PLAYER_NAME],
1906 string[128];
1907 if(Player[playerid][ADuty] == 1)
1908 {
1909 GetPlayerName(TargetPlayer, TargetPName, sizeof(TargetPName));
1910 if(Player[playerid][AdminSpec] == 0)
1911 {
1912 if(sscanf(params, "u", TargetPlayer))
1913 {
1914 SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[COMANDO]: Uso /specplayer [id/nome]");
1915 return 1;
1916 }
1917 if(IsPlayerInAnyVehicle(TargetPlayer))
1918 {
1919 PlayerSpectateVehicle(playerid, GetPlayerVehicleID(TargetPlayer));
1920 format(string, sizeof(string), "[SPEC]: Stai guardato %s", TargetPName);
1921 SendClientMessage(playerid, COLOR_SYSTEM_INFO, string);
1922 Player[playerid][AdminSpec] = 1;
1923 format(Player[playerid][AdminWhoSpec], 64, TargetPName);
1924 TogglePlayerControllable(playerid,false);
1925 return 1;
1926 }
1927 else
1928 {
1929 TogglePlayerControllable(playerid,false);
1930 PlayerSpectatePlayer(playerid, TargetPlayer);
1931 format(string, sizeof(string), "[SPEC]: Stai guardato %s", TargetPName);
1932 SendClientMessage(playerid, COLOR_SYSTEM_INFO, string);
1933 Player[playerid][AdminSpec] = 1;
1934 format(Player[playerid][AdminWhoSpec], 64, TargetPName);
1935 return 1;
1936 }
1937 }
1938 else
1939 {
1940 SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[ATTENZIONE]: Stai già spectando qualcuno.");
1941 return 1;
1942 }
1943 }
1944 else if(Player[playerid][ADuty] == 0)
1945 {
1946 format(string, sizeof(string), "{AFAFAF}[INFO]: Devi essere in servizio per usare questo comando {00FF00}(/aduty)");
1947 SendClientMessage(playerid, -1, string);
1948 return 1;
1949 }
1950 }
1951 else
1952 {
1953 SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "[ERRORE]: Non sei autorizzato ad usare questo comando.");
1954 return 1;
1955 }
1956 return 1;
1957}
1958
1959
1960
1961
1962// chat ic - /me
1963CMD:me(playerid, params[])
1964{
1965 new
1966 string[128],
1967 azione[100];
1968 if(sscanf(params, "s[100]", azione))
1969 {
1970 SendClientMessage(playerid, -1, "[COMANDO]: /me [azione]");
1971 return 1;
1972 }
1973 else
1974 {
1975 format(string, sizeof(string), "* %s %s", Player[playerid][RPName], azione);
1976 ProxDetector(30, playerid, string, COLOR_PURPLE);
1977 }
1978 return 1;
1979}
1980
1981CMD:b(playerid, params[])
1982{
1983 new
1984 string[128],
1985 azione[100];
1986 if(sscanf(params, "s[100]", azione))
1987 {
1988 SendClientMessage(playerid, -1, "[COMANDO]: /b [chat ooc]");
1989 return 1;
1990 }
1991 else
1992 {
1993 format(string, sizeof(string), "(( %s: %s ))", Player[playerid][RPName], azione);
1994 ProxDetector(30, playerid, string, COLOR_PURPLE);
1995 }
1996 return 1;
1997}
1998
1999CMD:grida(playerid, params[])
2000{
2001 new
2002 string[128],
2003 shout[100];
2004 if(sscanf(params, "s[100]", shout))
2005 {
2006 SendClientMessage(playerid, -1, "[COMANDO]: /(g)rida [messaggio]");
2007 return 1;
2008 }
2009 else
2010 {
2011 format(string, sizeof(string), "{ffff00}%s grida: %s!!",GetName(playerid),shout);
2012 ProxDetector(50.0, playerid, string, -1);
2013 }
2014 return 1;
2015}
2016CMD:g(playerid, params[]) return cmd_grida(playerid, params);
2017
2018CMD:adminchat(playerid, params[])
2019{
2020 if(Player[playerid][Admin] >= 1)
2021 {// Se è un membro dellos taff
2022 // se int è uguale a 0 (non in servizio) cambia l'int in 1 - entra in servizio
2023 new
2024 Messaggio[128],
2025 NomeUtente[MAX_PLAYER_NAME];
2026 GetPlayerName(playerid, NomeUtente, MAX_PLAYER_NAME);
2027
2028 if (sscanf(params, "s[128]", Messaggio))
2029 {
2030 return SendClientMessage(playerid, COLOR_INFO, "[INFO]: /adminchat (Messaggio)");
2031 }
2032 format(Messaggio, sizeof(Messaggio), "[ADMIN CHAT] %s(%d): %s", NomeUtente, playerid, Messaggio);
2033 ChatStaffMember(Messaggio);
2034
2035 }
2036 else if(Player[playerid][Admin] < 1)
2037 {// se no è uno dello staff
2038 new string[128];
2039 format(string, sizeof(string), "[ERRORE]: Mi dispiace %s non sei autorizzato ad usare questo comando", Player[playerid][Name]);
2040 SendClientMessage(playerid, COLOR_SYSTEM_ERROR, string);
2041 return 1;
2042 }
2043 return 1;
2044}
2045
2046COMMAND:admina(playerid, params[])
2047{
2048 if(Player[playerid][Admin] >= 1)
2049 {
2050 if(Player[playerid][ADuty] == 1)
2051 {
2052 new
2053 option[128],
2054 item[128],
2055 amount[128],
2056 Messaggio[128];
2057 new TargetPlayerID;
2058 new GivingAmmount;
2059 new AdminName[MAX_PLAYER_NAME],
2060 TargetPlayerName[MAX_PLAYER_NAME];
2061 // Nome dell'admin
2062 GetPlayerName(playerid, AdminName, MAX_PLAYER_NAME);
2063 // Nome del giocatore selezionato
2064 GetPlayerName(TargetPlayerID, TargetPlayerName, MAX_PLAYER_NAME);
2065 //----
2066 sscanf(params, "s[128]s[128]s[128]", option, item, amount);
2067 if (isnull(option))
2068 {
2069 SendClientMessage(playerid, COLOR_WHITE, "[INFO]: Uso comando /admina [Opzione]");
2070 SendClientMessage(playerid, COLOR_WHITE, "Opzioni: Dai | Set");
2071 return 1;
2072 }
2073 if (!strcmp(option, "dai") || !strcmp(option, "Dai"))
2074 { // Comando: /admin give [opzione]
2075 if (isnull(item))
2076 {
2077 SendClientMessage(playerid, COLOR_WHITE, "[INFO]: Uso comando /admin give [Opzione]");
2078 SendClientMessage(playerid, COLOR_WHITE, "Opzioni: Soldi | Arma");
2079 return 1;
2080 }
2081 if (!strcmp(item, "soldi") || strcmp(item, "Soldi"))
2082 { // Comando: /admin give soldi [Quantità ]
2083 if(sscanf(amount,"ui", TargetPlayerID, GivingAmmount))
2084 {
2085 SendClientMessage(playerid, COLOR_SYSTEM_ERROR ,
2086 "[INFO]: Uso comando /admina dai soldi [ID/NOME][QUANTITA']");
2087 return 1;
2088 }
2089 if(!IsPlayerConnected(TargetPlayerID))
2090 { // Messaggio d'errore se: giocatore non trovato/connesso
2091 SendClientMessage(playerid, COLOR_SYSTEM_ERROR,
2092 "[ERRORE:] Il giocatore selezionato non è connesso o hai sbagliato ID/nome");
2093 return 1;
2094 }
2095 else
2096 { // se il giocatore è connesso
2097 if(GivingAmmount >= 1)
2098 {
2099 GivePlayerMoney(TargetPlayerID, GivingAmmount);
2100 // MEssaggio all'utente selezionato
2101 format(Messaggio, sizeof (Messaggio), "[ADMIN]: %s ti ha givvato %i$", AdminName, GivingAmmount );
2102 SendClientMessage(TargetPlayerID, 0x33FF33AA, Messaggio);
2103 // Messaggio all'ADMIN
2104 format(Messaggio, sizeof (Messaggio), "[INFO]: Hai givvato %i$ all'utente %s", GivingAmmount, TargetPlayerName );
2105 SendClientMessage(playerid, 0x33FF33AA, Messaggio);
2106 return 1;
2107 }
2108 else if(GivingAmmount < 0)
2109 {
2110 new StringSoldi[64];
2111 format(StringSoldi, sizeof(StringSoldi), "{FF0000}[ERRORE]: {AFAFAF} Non puoi givvare $i, per togliere soldi usa /admina togli soldi", GivingAmmount);
2112 SendClientMessage(playerid, -1, StringSoldi);
2113 return 1;
2114 }
2115 }
2116 }//-------------
2117 else if (!strcmp(item, "armatura") || (!strcmp(item, "Armatura")))
2118 {
2119 if(sscanf(amount,"u", TargetPlayerID))
2120 {
2121 SendClientMessage(playerid, COLOR_SYSTEM_ERROR , "[INFO]: Uso comando /admina set armatura [ID/NOME]");
2122 return 1;
2123 }
2124 if(!IsPlayerConnected(TargetPlayerID))
2125 { // Messaggio d'errore se: giocatore non trovato/connesso
2126 SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "[ERRORE:] Il giocatore selezionato non è connesso o hai sbagliato ID/nome");
2127 return 1;
2128 }
2129 else
2130 { // Comando effettuato con successo
2131 SetPlayerArmour(TargetPlayerID, 100);
2132 // MEssaggio all'utente selezionato
2133 format(Messaggio, sizeof (Messaggio), "[ADMIN]: %s ti ha settato l'armatura al 100%", AdminName );
2134 SendClientMessage(TargetPlayerID, 0x33FF33AA, Messaggio);
2135 // Messaggio all'ADMIN
2136 format(Messaggio, sizeof (Messaggio), "[INFO]: Hai settato l'armatura all'utente %s", TargetPlayerName );
2137 SendClientMessage(playerid, 0x33FF33AA, Messaggio);
2138 return 1;
2139 }
2140 }
2141 else if (!strcmp(item, "money"))
2142 {
2143 // Code for the money...
2144 }
2145 }
2146 else if (!strcmp(option, "set"))
2147 {
2148 if (isnull(item))
2149 {
2150 SendClientMessage(playerid, COLOR_WHITE, "[INFO]: uso comando /admina set [Opzione]");
2151 SendClientMessage(playerid, COLOR_WHITE, "Opzioni: Gun, Drugs, Money");
2152 return 1;
2153 }
2154 if (!strcmp(item, "armatura") || (!strcmp(item, "Armatura")))
2155 {
2156 if(sscanf(amount,"u", TargetPlayerID))
2157 {
2158 SendClientMessage(playerid, COLOR_SYSTEM_ERROR , "[INFO]: Uso comando /admina set armatura [ID/NOME]");
2159 return 1;
2160 }
2161 if(!IsPlayerConnected(TargetPlayerID))
2162 { // Messaggio d'errore se: giocatore non trovato/connesso
2163 SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "[ERRORE:] Il giocatore selezionato non è connesso o hai sbagliato ID/nome");
2164 return 1;
2165 }
2166 else
2167 { // Comando effettuato con successo
2168 SetPlayerArmour(TargetPlayerID, 100);
2169 // MEssaggio all'utente selezionato
2170 format(Messaggio, sizeof (Messaggio), "[ADMIN]: %s ti ha settato l'armatura al 100%", AdminName );
2171 SendClientMessage(TargetPlayerID, 0x33FF33AA, Messaggio);
2172 // Messaggio all'ADMIN
2173 format(Messaggio, sizeof (Messaggio), "[INFO]: Hai settato l'armatura all'utente %s", TargetPlayerName );
2174 SendClientMessage(playerid, 0x33FF33AA, Messaggio);
2175 return 1;
2176 }
2177 }
2178 else if (!strcmp(item, "drugs"))
2179 {
2180 // Code for the drugs...
2181 }
2182 else if (!strcmp(item, "money"))
2183 {
2184 // Code for the money...
2185 }
2186 }
2187 }
2188 else
2189 {
2190 SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "[ERRORE]: Devi essere in servizio (/aduty)");
2191 return 1;
2192 }
2193 }
2194 else
2195 {
2196 SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[ERRORE]: Non sei autorizzato ad usare questo comando");
2197 return 1;
2198 }
2199 return 1;
2200}
2201// admin give fine
2202
2203
2204CMD:report(playerid, params[]) {
2205 new id; // id player reportato
2206 new reason[128]; // Ragione del report
2207 if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[SERVER] - USAGE: /report [ID] [REASON]");
2208 new string[150], // stringa messaggio report
2209 sender[MAX_PLAYER_NAME], // Nome di chi manda il report
2210 receiver[MAX_PLAYER_NAME]; // Chi riceve il report
2211
2212 GetPlayerName(playerid, sender, sizeof(sender));
2213 GetPlayerName(id, receiver, sizeof(receiver));
2214
2215 format(string, sizeof(string), "[ADMIN]: %s(%d) ha reportato %s(%d)", sender, playerid, receiver, id);
2216 SendMessageToAdmins(string);
2217
2218 format(string, sizeof(string), "[ADMIN]: Motivo: %s", reason);
2219 SendMessageToAdmins(string);
2220
2221 SendClientMessage(playerid, COLOR_SYSTEM_SUCCESS, "[INFO]: Il tuo report è stato inviato.");
2222 return 1;
2223}
2224
2225CMD:stats(playerid, params[])
2226{
2227
2228 new StatsString[1024];
2229 format(StatsString, sizeof(StatsString), "[STATISTICHE] - Ecco le tue informazioni %s", Player[playerid][Name]);
2230 SendClientMessage(playerid, COLOR_SYSTEM_INFO, StatsString);
2231
2232 format(StatsString, sizeof(StatsString),
2233 "[License] - Patente A: %s | Patente B: %s | Patente C: %s | Patente D: %s | Porto d'armi: %s",
2234 Player[playerid][PatenteA], Player[playerid][PatenteB], Player[playerid][PatenteC], Player[playerid][PatenteD], Player[playerid][PortoDarmi]);
2235 SendClientMessage(playerid, COLOR_SYSTEM_INFO, StatsString);
2236 format(StatsString, sizeof(StatsString), "[VARIE] - Soldi %d | Livello: %d | Warns %d",
2237 GetPlayerMoney(playerid), GetPlayerScore(playerid), Player[playerid][Warns] );
2238 SendClientMessage(playerid, COLOR_SYSTEM_INFO, StatsString);
2239
2240 return 1;
2241}
2242
2243
2244CMD:aiuto(playerid, params[])
2245{
2246 new
2247 MessaggioAiuto[128],
2248 NomeUtente[MAX_PLAYER_NAME];
2249 GetPlayerName(playerid, NomeUtente, MAX_PLAYER_NAME);
2250
2251 if (sscanf(params, "s[128]", MessaggioAiuto))
2252 {
2253 return SendClientMessage(playerid, COLOR_INFO, "[INFO]: /aiuto (Messaggio di aiuto)");
2254 }
2255 format(MessaggioAiuto, sizeof(MessaggioAiuto), "[AIUTO]: %s(%d): %s", Player[playerid][PatenteA], playerid, MessaggioAiuto); // NomeUtente
2256 SendMessageToAdmins(MessaggioAiuto);
2257 SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[INFO]: Il tuo messaggio è stato mandato");
2258 return 1;
2259}
2260
2261CMD:a(playerid, params[])
2262{
2263 if(Player[playerid][Admin] >= 1)
2264 {
2265 new
2266 AdminName[MAX_PLAYER_NAME],
2267 MessaggioAdmin[128];
2268
2269 if(sscanf(params, "s[128]", MessaggioAdmin))
2270 {
2271 SendClientMessage(playerid, COLOR_SYSTEM_INFO, "[COMANDO]: /a [messaggio]");
2272 return 1;
2273 }
2274 GetPlayerName(playerid, AdminName, sizeof(AdminName));
2275 format(MessaggioAdmin, sizeof(MessaggioAdmin), "[ADMIN]: %s: %s", Player[playerid][RPName], MessaggioAdmin);
2276 SendClientMessageToAll(COLOR_SYSTEM_ADMIN, MessaggioAdmin);
2277 return 1;
2278 }
2279 else if(Player[playerid][Admin] < 1)
2280 {
2281 SendClientMessage(playerid, COLOR_SYSTEM_ERROR, "[ERRORE]: Non sei autorizzato ad usare questo comando");
2282 return 1;
2283 }
2284 return 1;
2285}
2286
2287CMD:aduty(playerid, params[])
2288{
2289 if(Player[playerid][Admin] >= 1)
2290 {// Se è un membro dellos taff
2291 // se int è uguale a 0 (non in servizio) cambia l'int in 1 - entra in servizio
2292 if(Player[playerid][ADuty] == 0)
2293 {// entra in servizio
2294 TextDrawShowForPlayer(playerid,AdminInDuty);
2295 SetPlayerArmour(playerid, 10000);
2296 SetPlayerHealth(playerid, 10000);
2297 new ADutyString[64];
2298 format(ADutyString, sizeof(ADutyString), "[ADMIN]: L'admin %s è in servizio", Player[playerid][Name]);
2299 SendClientMessageToAll(COLOR_SYSTEM_ADMIN, ADutyString);
2300 Player[playerid][ADuty] = 1;
2301 return 1;
2302 }
2303 // se int è uguale a 1 (in servizio) cambia l'int in 0 - esce dal servizio
2304 if(Player[playerid][ADuty] == 1)
2305 {// esce dal servizio
2306 TextDrawHideForPlayer(playerid,AdminInDuty);
2307 SetPlayerArmour(playerid, Player[playerid][Armatura]);
2308 SetPlayerHealth(playerid, Player[playerid][Vita]);
2309 new ADutyString[64];
2310 format(ADutyString, sizeof(ADutyString), "[ADMIN]: L'admin %s non è più in servizio", Player[playerid][Name]);
2311 SendClientMessageToAll(COLOR_SYSTEM_ADMIN, ADutyString);
2312 Player[playerid][ADuty] = 0;
2313 return 1;
2314 }
2315 }
2316 else if(Player[playerid][Admin] < 1)
2317 {// se no è uno dello staff
2318 new string[128];
2319 format(string, sizeof(string), "[ERRORE]: Mi dispiace %s non sei autorizzato ad usare questo comando", Player[playerid][Name]);
2320 SendClientMessage(playerid, COLOR_SYSTEM_ERROR, string);
2321 return 1;
2322 }
2323 return 1;
2324}
2325
2326CMD:suicidio(playerid, params[])
2327{
2328 SetPlayerHealth(playerid, 0);
2329 return 1;
2330}
2331
2332public OnPlayerRequestClass(playerid,classid)
2333{ // quando un giocatore si registra/logga
2334// SetPlayerPos(playerid, 982.1890, -1624.2583, 14.9526); // posizione dafault las venturas
2335 SetPlayerPos(playerid, -1965.3541, 158.4787, 27.6940);
2336 SetPlayerFacingAngle(playerid, 90.0000);
2337 return 1;
2338}
2339
2340public OnPlayerClickPlayer(playerid, clickedplayerid, source)
2341{
2342 return 1;
2343}