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