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