Guest User

Untitled

a guest
Mar 10th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.95 KB | None | 0 0
  1. //Includes
  2. #include <a_samp>
  3. #include <ocmd>
  4. #include <sscanf2>
  5. #include <a_mysql>
  6. #include <foreach>
  7.  
  8. //define
  9. #define DIALOG_MEGAPHONE_MENU (10201)
  10. #define COLOR_WHITE 0xFFFFFFFF
  11. #define COLOR_LIGHTBLUE 0x0080FFFF
  12. #define VERSION ("0.3.7")
  13. #define SCM SendClientMessage
  14.  
  15. new Message[1000];
  16.  
  17. //Colori
  18. #define COLOR_RED 0xFF0000FF
  19. #define COLOR_WHITE 0xFFFFFFFF
  20. #define COLOR_BLUE 0x009BFFFF
  21. #define COLOR_YELLOW 0xEBFF00FF
  22. #define COLOR_CHAT 0xFEFEFEFF
  23. #define COLOR_FADE1 0xE6E6E6FF
  24. #define COLOR_FADE2 0xD1CFD1FF
  25. #define COLOR_FADE3 0xBEC1BEFF
  26. #define COLOR_FADE4 0x919397FF
  27.  
  28. //Dialoghi
  29. #define DIALOG_TELEPORT 1
  30. #define DIALOG_REGISTER 2
  31. #define DIALOG_LOGIN 3
  32. #define DIALOG_AUTOHAUS 4
  33.  
  34. //MySQL
  35. #define db_host "127.0.0.1"
  36. #define db_user "samp"
  37. #define db_pass "mysqlpasswort"
  38. #define db_db "samp"
  39.  
  40. //Stocks
  41. stock ProxDetector(Float:radi, playerid, string[], color)
  42. {
  43. new Float:x,Float:y,Float:z;
  44. GetPlayerPos(playerid,x,y,z);
  45. foreach(Player,i)
  46. {
  47. if(IsPlayerInRangeOfPoint(i,radi,x,y,z))
  48. {
  49. SCM(i,color,string);
  50. }
  51. }
  52. }
  53.  
  54. stock split(const strsrc[], strdest[][], delimiter)
  55. {
  56. new i, li;
  57. new aNum;
  58. new len;
  59. while(i <= strlen(strsrc))
  60. {
  61. if(strsrc[i] == delimiter || i == strlen(strsrc))
  62. {
  63. len = strmid(strdest[aNum], strsrc, li, i, 128);
  64. strdest[aNum][len] = 0;
  65. li = i+1;
  66. aNum++;
  67. }
  68. i++;
  69. }
  70. return 1;
  71. }
  72.  
  73. stock PlaySoundEx(soundid, Float:x, Float:y, Float:z, Float:range)
  74. {
  75. foreach(new i : Player)
  76. {
  77. if(!IsPlayerConnected(i)) continue;
  78. if(!IsPlayerInRangeOfPoint(i, range, x, y, z)) continue;
  79. PlayerPlaySound(i, soundid, 0, 0, 0);
  80. }
  81. }
  82. //Limits
  83. #define CHAT_RADIUS 40
  84. #define CHAT_FADES 5
  85.  
  86. // New
  87. new MegaphoneSounds[][] =
  88. {
  89. {"9605,Alza le mani. Sei Circondato!"},
  90. {"9612,Sappiamo che sei li dentro!"},
  91. {"10200,Ehi tu! Siamo la Polizia. Fermati!"},
  92. {"15800,Questo è il Los Santos Department; Resta dove sei!"},
  93. {"15801,Fermati! Oppure apriamo il fuoco"},
  94. {"15802,Via! Via! Via!},
  95. {"34402,Polizia! Non muoverti!"},
  96. {"34403,Esci dall'auto con le mani in alto!"},
  97. {"15825,LSPD. Fermati... sei pazzo? Ci ucciderai tutti"},
  98. };
  99.  
  100. //enums
  101. enum playerInfo{
  102. eingeloggt,
  103. level,
  104. db_id,
  105. alevel,
  106. fraktion,
  107. rang,
  108. spawnchange
  109. }
  110.  
  111. enum hausEnum{
  112. Float:h_x,
  113. Float:h_y,
  114. Float:h_z,
  115. Float:ih_x,
  116. Float:ih_y,
  117. Float:ih_z,
  118. h_interior,
  119. h_besitzer[MAX_PLAYER_NAME],
  120. h_preis,
  121. h_id,
  122. h_pickup,
  123. Text3D:h_text
  124. }
  125.  
  126. enum buildingsEnum{
  127. Float:b_x,
  128. Float:b_y,
  129. Float:b_z,
  130. Float:b_ix,
  131. Float:b_iy,
  132. Float:b_iz,
  133. b_interior,
  134. b_shopname[15]
  135. }
  136.  
  137. enum carEnum{
  138. id_x,
  139. model,
  140. besitzer,
  141. Float:c_x,
  142. Float:c_y,
  143. Float:c_z,
  144. Float:c_r,
  145. db_id
  146. }
  147.  
  148. enum autohausEnum{
  149. Float:s_x,
  150. Float:s_y,
  151. Float:s_z,
  152. Float:s_r
  153. }
  154.  
  155. enum autohauscarEnum{
  156. model,
  157. Float:c_x,
  158. Float:c_y,
  159. Float:c_z,
  160. Float:c_r,
  161. c_preis,
  162. ah_id,
  163. id_x
  164. }
  165.  
  166. enum fraktEnum{
  167. f_name[128],
  168. Float:f_x,
  169. Float:f_y,
  170. Float:f_z,
  171. Float:f_r,
  172. f_inter,
  173. f_world,
  174. f_color
  175. }
  176.  
  177. //Variabili
  178. new dbhandle;
  179. new sInfo[MAX_PLAYERS][playerInfo];
  180. new fInfo[][fraktEnum] = {
  181. {"Civili", 0.0, 0.0, 0.0, 0.0, 0, 0, COLOR_WHITE},
  182. {"LSPD", 295.2865,-55.4151,2.7772,293.463, 0, 0, COLOR_BLUE},
  183. {"Taxi", 0.0, 0.0, 0.0, 0.0, 0, 0, COLOR_YELLOW}
  184.  
  185. };
  186. new bInfo[][buildingsEnum] = {
  187. {243.0825,-178.3224,1.5822,285.3642,-41.5576,1001.5156,1,"AMMUN1"},//Ammunation
  188. {212.1142,-202.1886,1.5781,372.4523,-133.5244,1001.4922,5,"FDPIZA"}//Pizza
  189. };
  190. new cInfo[50][carEnum];
  191. new ahInfo[][autohausEnum] = {
  192. {125.7242,-170.1469,1.2838,177.7335},//id: 0 1. autobus
  193. {189.8910,-263.3446,1.2829,180.6895}//id: 1 2. autobus
  194. };
  195. new ahCars[][autohauscarEnum] = {
  196. {560,118.5637,-153.0834,1.2834,186.6475,50000,0},
  197. {411,106.3420,-158.7720,1.7527,257.3197,80000,0},
  198. {400,204.8894,-265.4756,1.2866,354.1406,10000,1}
  199. };
  200. new hInfo[100][hausEnum];
  201. new sekunden_timer;
  202.  
  203. new autosOhneMotor[] = {509,510,481};
  204.  
  205. new Text:uhrzeitLabel;
  206.  
  207.  
  208. //Forwards
  209. forward OnUserCheck(playerid);
  210. forward OnPasswordResponse(playerid);
  211. forward carSavedToDB(carid);
  212. forward OnPlayerCarsLoad(playerid);
  213. forward OnHausesLoad();
  214. forward sekunde();
  215. forward unfreezePlayer(playerid);
  216. forward OnHausCreated(id);
  217.  
  218. main()
  219. {
  220.  
  221. }
  222.  
  223. public OnGameModeInit()
  224. {
  225. SetGameModeText("script");
  226. AddPlayerClass(1,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);
  227. AddPlayerClass(2,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);
  228. AddPlayerClass(3,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);
  229.  
  230. DisableInteriorEnterExits();
  231. ManualVehicleEngineAndLights();
  232.  
  233. //MySQL
  234. dbhandle = mysql_connect(db_host,db_user,db_db,db_pass);
  235.  
  236. //Edificio
  237. for(new i=0; i<sizeof(bInfo); i++)
  238. {
  239. CreatePickup(1239,1,bInfo[i][b_x],bInfo[i][b_y],bInfo[i][b_z]);
  240. Create3DTextLabel("Per entrare /entra",COLOR_RED,bInfo[i][b_x],bInfo[i][b_y],bInfo[i][b_z],10,0,1);
  241. }
  242.  
  243. //Auto creabili
  244. AddStaticVehicle(560,214.1196,-141.3710,1.3052,1.6804,-1,-1); //Sultan
  245.  
  246. //Concessionario Patente Auto
  247. for(new i=0; i<sizeof(ahCars); i++)
  248. {
  249. ahCars[i][id_x]=AddStaticVehicle(ahCars[i][model],ahCars[i][c_x],ahCars[i][c_y],ahCars[i][c_z],ahCars[i][c_r],-1,-1);
  250. }
  251.  
  252. //Case di Licenza
  253. new query[128];
  254. format(query, sizeof(query), "Seleziona * casa");
  255. mysql_function_query(dbhandle, query, true, "OnHausesLoad", "");
  256.  
  257. //Timer
  258. sekunden_timer = SetTimer("sekunde",1000,true);
  259.  
  260. //Textdraws
  261. uhrzeitLabel = TextDrawCreate(557.000000, 12.000000, "00:00");
  262. TextDrawBackgroundColor(uhrzeitLabel, 255);
  263. TextDrawFont(uhrzeitLabel, 3);
  264. TextDrawLetterSize(uhrzeitLabel, 0.580000, 2.399999);
  265. TextDrawColor(uhrzeitLabel, -1);
  266. TextDrawSetOutline(uhrzeitLabel, 1);
  267. TextDrawSetProportional(uhrzeitLabel, 1);
  268.  
  269. return 1;
  270. }
  271.  
  272. public OnHausesLoad()
  273. {
  274. new num_fields,num_rows;
  275. cache_get_data(num_rows,num_fields,dbhandle);
  276. if(!num_rows)return 1;
  277. for(new i=0; i<num_rows; i++)
  278. {
  279. new id=getFreeHausID();
  280. hInfo[id][h_x]=cache_get_field_content_float(i, "h_x", dbhandle);
  281. hInfo[id][h_y]=cache_get_field_content_float(i, "h_y", dbhandle);
  282. hInfo[id][h_z]=cache_get_field_content_float(i, "h_z", dbhandle);
  283. hInfo[id][ih_x]=cache_get_field_content_float(i, "ih_x", dbhandle);
  284. hInfo[id][ih_y]=cache_get_field_content_float(i, "ih_y", dbhandle);
  285. hInfo[id][ih_z]=cache_get_field_content_float(i, "ih_z", dbhandle);
  286. hInfo[id][h_interior]=cache_get_field_content_int(i, "h_interior", dbhandle);
  287. new tmp_name[MAX_PLAYER_NAME];
  288. cache_get_field_content(i, "besitzer", tmp_name, dbhandle);
  289. strmid(hInfo[id][h_besitzer], tmp_name, 0, sizeof(tmp_name), sizeof(tmp_name));
  290. hInfo[id][h_id]=cache_get_field_content_int(i, "id", dbhandle);
  291. hInfo[id][h_preis]=cache_get_field_content_int(i, "h_preis", dbhandle);
  292. updateHaus(id);
  293. }
  294. return 1;
  295. }
  296.  
  297. updateHaus(id)
  298. {
  299. new string[128];
  300. if(hInfo[id][h_pickup])
  301. {
  302. DestroyPickup(hInfo[id][h_pickup]);
  303. }
  304. if(hInfo[id][h_text])
  305. {
  306. Delete3DTextLabel(hInfo[id][h_text]);
  307. }
  308. if(!strlen(hInfo[id][h_besitzer]))
  309. {
  310. hInfo[id][h_pickup]=CreatePickup(1273, 1, hInfo[id][h_x], hInfo[id][h_y], hInfo[id][h_z], -1);
  311. format(string,sizeof(string), "In Vendita\nCosto: %i$\n/hauskaufen", hInfo[id][h_preis]);
  312. hInfo[id][h_text]=Create3DTextLabel(string, COLOR_RED, hInfo[id][h_x], hInfo[id][h_y], hInfo[id][h_z], 10, 0, 1);
  313. }
  314. else
  315. {
  316. hInfo[id][h_pickup]=CreatePickup(1239, 1, hInfo[id][h_x], hInfo[id][h_y], hInfo[id][h_z], -1);
  317. format(string,sizeof(string), "Proprietario: %s\n/entra", hInfo[id][h_besitzer]);
  318. hInfo[id][h_text]=Create3DTextLabel(string, COLOR_BLUE, hInfo[id][h_x], hInfo[id][h_y], hInfo[id][h_z], 10, 0, 1);
  319. }
  320. return 1;
  321. }
  322.  
  323.  
  324. public OnGameModeExit()
  325. {
  326. mysql_close(dbhandle);
  327. return 1;
  328. }
  329.  
  330. public sekunde()
  331. {
  332. new string[128];
  333. for(new i=0; i<MAX_PLAYERS; i++)
  334. {
  335. if(!IsPlayerConnected(i))continue;
  336. if(!IsPlayerInAnyVehicle(i))continue;
  337. format(string,sizeof(string),"%ikm/h", getPlayerSpeed(i));
  338. GameTextForPlayer(i, string, 1000, 3);
  339. }
  340.  
  341. new hour, minute, second;
  342. gettime(hour, minute, second);
  343. format(string,sizeof(string),"%02d:%02d",hour, minute);
  344. TextDrawSetString(uhrzeitLabel, string);
  345. return 1;
  346. }
  347.  
  348. public OnPlayerRequestClass(playerid, classid)
  349. {
  350. SetPlayerPos(playerid,199.0846,-150.0331,1.5781);
  351. SetPlayerCameraPos(playerid, 199.2307,-143.8328,1.5781);
  352. SetPlayerCameraLookAt(playerid, 199.0846,-150.0331,1.5781);
  353. SetPlayerFacingAngle(playerid,359.1443);
  354. return 1;
  355. }
  356.  
  357. public OnUserCheck(playerid)
  358. {
  359. new num_rows,num_fields;
  360. cache_get_data(num_rows,num_fields,dbhandle);
  361. if(num_rows==0)
  362. {
  363. //Registrazione
  364. ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrazione","Inserisci una password desiderata:","Ok","Esci");
  365. }
  366. else
  367. {
  368. //Login
  369. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Logga","Si prega di inserire la propria password:","Ok","Esci");
  370. }
  371. return 1;
  372. }
  373.  
  374. public OnFilterScriptInit()
  375. {
  376. printf(" "); printf(" "); printf(" ");
  377.  
  378. print("Megafono Script");
  379. print("Script è stato caricato.");
  380. printf("Versione Script : %s");
  381.  
  382. printf(" "); printf(" "); printf(" ");
  383. return 1;
  384. }
  385.  
  386. public OnPlayerConnect(playerid)
  387. {
  388. new nachricht[128];
  389. format(nachricht,sizeof(nachricht),"Ti sei connesso con ID %i.",playerid);
  390. SendClientMessage(playerid,COLOR_RED,nachricht);
  391.  
  392. //Login/Register
  393. new name[MAX_PLAYER_NAME],query[128];
  394. GetPlayerName(playerid,name,sizeof(name));
  395. format(query,sizeof(query),"Seleziona il giocatore='%s'",name);
  396. mysql_function_query(dbhandle,query,true,"OnUserCheck","i",playerid);
  397.  
  398. //Textdraw
  399. TextDrawShowForPlayer(playerid, uhrzeitLabel);
  400.  
  401. //Lettore colore
  402. SetPlayerColor(playerid, COLOR_WHITE);
  403. return 1;
  404. }
  405.  
  406. savePlayer(playerid)
  407. {
  408. if(sInfo[playerid][eingeloggt]==0)return 1;
  409. //Speichern level,money
  410. new query[256];
  411. format(query,sizeof(query),"UPDATE giocatore SET livello='%i',money='%i',alevel='%i',frazione='%i,rango='%i',cambiaspawn='%i' dove id='%i'",sInfo[playerid][level],
  412. GetPlayerMoney(playerid),sInfo[playerid][alevel],sInfo[playerid][fraktion],sInfo[playerid][rang],sInfo[playerid][spawnchange],sInfo,sInfo[playerid][db_id]);
  413. mysql_function_query(dbhandle,query,false,"","");
  414. return 1;
  415. }
  416.  
  417. resetPlayer(playerid)
  418. {
  419. for(new i=0; i<sizeof(sInfo[]); i++)
  420. {
  421. sInfo[playerid][playerInfo:i]=0;
  422. }
  423. return 1;
  424. }
  425.  
  426. public OnPlayerDisconnect(playerid, reason)
  427. {
  428. for(new i=0; i<sizeof(cInfo); i++)
  429. {
  430. if(cInfo[i][id_x]==0)continue;
  431. if(cInfo[i][besitzer]!=sInfo[playerid][db_id])continue;
  432. GetVehiclePos(cInfo[i][id_x],cInfo[i][c_x],cInfo[i][c_y],cInfo[i][c_z]);
  433. GetVehicleZAngle(cInfo[i][id_x],cInfo[i][c_r]);
  434. new query[256];
  435. format(query,sizeof(query),"UPDATE auto setta x='%f',y='%f',z='%f',r='%f' all' id='%i'",cInfo[i][c_x],cInfo[i][c_y],cInfo[i][c_z],cInfo[i][c_r],cInfo[i][db_id]);
  436. mysql_function_query(dbhandle,query,false,"","");
  437. DestroyVehicle(cInfo[i][id_x]);
  438. cInfo[i][id_x]=0;
  439. }
  440. savePlayer(playerid);
  441. resetPlayer(playerid);
  442. return 1;
  443. }
  444.  
  445. isPlayerInFrakt(playerid, f_id){
  446. if(sInfo[playerid][fraktion]==f_id)return 1;
  447. return 0;
  448. }
  449.  
  450. public OnPlayerSpawn(playerid)
  451. {
  452. if(sInfo[playerid][spawnchange]==0)
  453. {
  454. for(new i=0; i<sizeof(hInfo); i++)
  455. {
  456. if(!hInfo[i][h_id])continue;
  457. if(!strlen(hInfo[i][h_besitzer]))continue;
  458. if(strcmp(hInfo[i][h_besitzer], getPlayerName(playerid), true))continue;
  459. if(hInfo[i][ih_x] != 0.0)
  460. {
  461. //Spawnato in casa
  462. SetPlayerPos(playerid, hInfo[i][ih_x], hInfo[i][ih_y], hInfo[i][ih_z]);
  463. SetPlayerInterior(playerid, hInfo[i][h_interior]);
  464. SetPlayerVirtualWorld(playerid, i);
  465. }
  466. else
  467. {
  468. //Spawnato fuori casa
  469. SetPlayerPos(playerid, hInfo[i][h_x], hInfo[i][h_y], hInfo[i][h_z]);
  470. SetPlayerInterior(playerid, 0);
  471. SetPlayerVirtualWorld(playerid, 0);
  472. }
  473.  
  474. }
  475. }
  476. if(!isPlayerInFrakt(playerid, 0)){
  477. if(sInfo[playerid][spawnchange]==1)
  478. {
  479. new fID;
  480. fID = sInfo[playerid][fraktion];
  481. SetPlayerPos(playerid, fInfo[fID][f_x],fInfo[fID][f_y],fInfo[fID][f_z]);
  482. SetPlayerFacingAngle(playerid, fInfo[fID][f_r]);
  483. SetPlayerInterior(playerid, fInfo[fID][f_inter]);
  484. SetPlayerVirtualWorld(playerid, fInfo[fID][f_world]);
  485. SetPlayerColor(playerid, fInfo[fID][f_color]);
  486. }
  487. }
  488. return 1;
  489. }
  490.  
  491. public OnPlayerDeath(playerid, killerid, reason)
  492. {
  493. return 1;
  494. }
  495.  
  496. public OnVehicleSpawn(vehicleid)
  497. {
  498. return 1;
  499. }
  500.  
  501. public OnVehicleDeath(vehicleid, killerid)
  502. {
  503. return 1;
  504. }
  505.  
  506. public OnPlayerText(playerid, text[])
  507. {
  508. new Float:x, Float:y, Float:z;
  509. GetPlayerPos(playerid, x, y, z);
  510.  
  511. new string[128];
  512. format(string,sizeof(string), "%s sagt: %s",
  513. getPlayerName(playerid), text);
  514.  
  515. new chat_color;
  516.  
  517. for(new i=0; i<MAX_PLAYERS; i++)
  518. {
  519. if(!IsPlayerConnected(i))continue;
  520. if(!IsPlayerInRangeOfPoint(i, CHAT_RADIUS, x, y, z))continue;
  521. new Float:distance = GetPlayerDistanceFromPoint(i, x, y, z);
  522. if(distance < CHAT_RADIUS / CHAT_FADES)
  523. {
  524. chat_color = COLOR_CHAT;
  525. }
  526. else if(distance < CHAT_RADIUS / CHAT_FADES * 2)
  527. {
  528. chat_color = COLOR_FADE1;
  529. }
  530. else if(distance < CHAT_RADIUS / CHAT_FADES * 3)
  531. {
  532. chat_color = COLOR_FADE2;
  533. }
  534. else if(distance < CHAT_RADIUS / CHAT_FADES * 4)
  535. {
  536. chat_color = COLOR_FADE3;
  537. }
  538. else if(distance <= CHAT_RADIUS / CHAT_FADES * 5)
  539. {
  540. chat_color = COLOR_FADE4;
  541. }
  542. SendClientMessage(i, chat_color, string);
  543. }
  544. return 0;
  545. }
  546.  
  547. getPlayerSpeed(playerid)
  548. {
  549. new Float:x, Float:y, Float:z, Float:rtn;
  550. if(IsPlayerInAnyVehicle(playerid))
  551. {
  552. GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
  553. }
  554. else
  555. {
  556. GetPlayerVelocity(playerid, x, y, z);
  557. }
  558. //rtn = radice(x*x + y*y + z*z);
  559. rtn = floatsqroot(x*x + y*y + z*z);
  560. return floatround(rtn * 100 * 1.61);
  561. }
  562.  
  563. public carSavedToDB(carid)
  564. {
  565. cInfo[carid][db_id]=cache_insert_id(dbhandle);
  566. return 1;
  567. }
  568.  
  569.  
  570. saveCarToDB(playerid,carid)
  571. {
  572. new query[128];
  573. format(query,sizeof(query),"Inserisci auto (proprietario,modello,x,y,z,r) valore ('%i','%i','%f','%f','%f','%f')",sInfo[playerid][db_id],cInfo[carid][model],cInfo[carid][c_x],cInfo[carid][c_y],cInfo[carid][c_z],cInfo[carid][c_r]);
  574. mysql_function_query(dbhandle,query,true,"carSavedToDB","i",carid);
  575. return 1;
  576. }
  577.  
  578. createPlayerCar(playerid,modelid,Float:x,Float:y,Float:z,Float:r)
  579. {
  580. for(new i=0; i<sizeof(cInfo); i++)
  581. {
  582. if(cInfo[i][id_x]!=0)continue;
  583. cInfo[i][besitzer]=sInfo[playerid][db_id];
  584. cInfo[i][c_x]=x;
  585. cInfo[i][c_y]=y;
  586. cInfo[i][c_z]=z;
  587. cInfo[i][c_r]=r;
  588. cInfo[i][model]=modelid;
  589. cInfo[i][id_x] = CreateVehicle(modelid,x,y,z,r,-1,-1,-1);
  590. new string[128];
  591. format(string,sizeof(string),"Auto cInfo[%i] è stato creato.",i);
  592. SendClientMessageToAll(COLOR_RED,string);
  593. saveCarToDB(playerid,i);
  594. return 1;
  595. }
  596. return 1;
  597. }
  598.  
  599. public unfreezePlayer(playerid)
  600. {
  601. TogglePlayerControllable(playerid,true);
  602. return 1;
  603. }
  604.  
  605. getPlayerName(playerid)
  606. {
  607. new name[MAX_PLAYER_NAME];
  608. GetPlayerName(playerid, name, sizeof(name));
  609. return name;
  610. }
  611.  
  612. hatPlayerHaus(playerid)
  613. {
  614. new name[MAX_PLAYER_NAME];
  615. GetPlayerName(playerid, name, sizeof(name));
  616. for(new i=0; i<sizeof(hInfo); i++)
  617. {
  618. if(!hInfo[i][h_id])continue;
  619. if(!strlen(hInfo[i][h_besitzer]))continue;
  620. if(!strcmp(name, hInfo[i][h_besitzer], true))return 1;
  621. }
  622. return 0;
  623. }
  624.  
  625. saveHaus(id)
  626. {
  627. new query[128];
  628. format(query, sizeof(query), "UPDATE Casa privata='%s', h_prezzo='%i' dove id='%i'", hInfo[id][h_besitzer], hInfo[id][h_preis], hInfo[id][h_id]);
  629. mysql_function_query(dbhandle, query, false, "", "");
  630. return 1;
  631. }
  632.  
  633.  
  634. public OnHausCreated(id)
  635. {
  636. hInfo[id][h_id]=cache_insert_id();
  637. }
  638.  
  639. //Comandi
  640.  
  641. ocmd:settaprezzo(playerid, params[])
  642. {
  643. if(!isAdmin(playerid, 3))return
  644. SendClientMessage(playerid, COLOR_RED, "Hai un rank admin basso.");
  645. new tmp_preis;
  646. if(sscanf(params, "i", tmp_preis))return
  647. SendClientMessage(playerid, COLOR_RED, "INFO: /settaprezzo [prezzo]");
  648. for(new i=0; i<sizeof(hInfo); i++)
  649. {
  650. if(!hInfo[i][h_id])continue;
  651. if(!IsPlayerInRangeOfPoint(playerid, 5,
  652. hInfo[i][h_x], hInfo[i][h_y], hInfo[i][h_z]))continue;
  653. hInfo[i][h_preis] = tmp_preis;
  654. saveHaus(i);
  655. updateHaus(i);
  656. return 1;
  657. }
  658. return 1;
  659. }
  660.  
  661. ocmd:toglicasa(playerid, params[])
  662. {
  663. if(!isAdmin(playerid, 3))return
  664. SendClientMessage(playerid, COLOR_RED, "Hai un rank admin basso.");
  665. for(new i=0; i<sizeof(hInfo); i++)
  666. {
  667. if(!hInfo[i][h_id])continue;
  668. if(!IsPlayerInRangeOfPoint(playerid, 5,
  669. hInfo[i][h_x], hInfo[i][h_y], hInfo[i][h_z]))continue;
  670. new query[128];
  671. format(query,sizeof(query),
  672. "Casa tolta all' id='%i'", hInfo[i][h_id]);
  673. mysql_function_query(dbhandle, query, false, "", "");
  674. hInfo[i][h_x]=0.0;
  675. hInfo[i][h_y]=0.0;
  676. hInfo[i][h_z]=0.0;
  677. hInfo[i][ih_x]=0.0;
  678. hInfo[i][ih_y]=0.0;
  679. hInfo[i][ih_z]=0.0;
  680. hInfo[i][h_id]=0;
  681. hInfo[i][h_preis]=0;
  682. hInfo[i][h_interior]=0;
  683. if(hInfo[i][h_pickup])
  684. {
  685. DestroyPickup(hInfo[i][h_pickup]);
  686. }
  687. if(hInfo[i][h_text])
  688. {
  689. Delete3DTextLabel(hInfo[i][h_text]);
  690. }
  691. return 1;
  692. }
  693. return 1;
  694. }
  695.  
  696. ocmd:creacasa(playerid, params[])
  697. {
  698. if(!isAdmin(playerid, 3))return
  699. SendClientMessage(playerid, COLOR_RED, "Hai un rank admin basso.");
  700. new Float:xc, Float:yc, Float:zc;
  701. GetPlayerPos(playerid, xc, yc, zc);
  702.  
  703. new id=getFreeHausID();
  704. hInfo[id][h_x]=xc;
  705. hInfo[id][h_y]=yc;
  706. hInfo[id][h_z]=zc;
  707. hInfo[id][ih_x]=0.0;
  708. hInfo[id][ih_y]=0.0;
  709. hInfo[id][ih_z]=0.0;
  710. hInfo[id][h_interior]=0;
  711. strmid(hInfo[id][h_besitzer], "", 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME);
  712. hInfo[id][h_preis]=1;
  713. updateHaus(id);
  714. //Aggiungere soldi alla banca
  715. new query[256];
  716. format(query, sizeof(query),
  717. "Inserisci casa (h_x, h_y, h_z, ih_x, ih_y, ih_z, h_interior, h_prezzo) valore ('%f', '%f', '%f', '0.0', '0.0', '0.0', '0', '1')",
  718. xc, yc, zc);
  719. mysql_function_query(dbhandle, query, true, "OnHausCreated", "i", id);
  720. return 1;
  721. }
  722.  
  723. ocmd:vendicasa(playerid, params[])
  724. {
  725. new name[MAX_PLAYER_NAME];
  726. GetPlayerName(playerid, name, sizeof(name));
  727. for(new i=0; i<sizeof(hInfo); i++)
  728. {
  729. if(!hInfo[i][h_id])continue;
  730. if(!IsPlayerInRangeOfPoint(playerid, 5,
  731. hInfo[i][h_x], hInfo[i][h_y], hInfo[i][h_z]))continue;
  732. if(!strlen(hInfo[i][h_besitzer]))continue;
  733. if(!strcmp(hInfo[i][h_besitzer], name, true))
  734. {
  735. hInfo[i][h_preis]=hInfo[i][h_preis]/2;
  736. GivePlayerMoney(playerid, hInfo[i][h_preis]);
  737. strmid(hInfo[i][h_besitzer], "", 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME);
  738. updateHaus(i);
  739. saveHaus(i);
  740. return 1;
  741. }
  742. }
  743. return 1;
  744. }
  745.  
  746. ocmd:compracasa(playerid, params[])
  747. {
  748. if(hatPlayerHaus(playerid))return
  749. SendClientMessage(playerid, COLOR_RED, "Hai già una casa.");
  750. for(new i=0; i<sizeof(hInfo); i++)
  751. {
  752. if(!hInfo[i][h_id])continue;
  753. if(!IsPlayerInRangeOfPoint(playerid, 5,
  754. hInfo[i][h_x], hInfo[i][h_y], hInfo[i][h_z]))continue;
  755. if(!strlen(hInfo[i][h_besitzer]))
  756. {
  757. if(GetPlayerMoney(playerid)<hInfo[i][h_preis])return
  758. SendClientMessage(playerid, COLOR_RED, "Non hai abbastanza soldi.");
  759. GivePlayerMoney(playerid, -hInfo[i][h_preis]);
  760. strmid(hInfo[i][h_besitzer], getPlayerName(playerid), 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME);
  761. updateHaus(i);
  762. saveHaus(i);
  763. return 1;
  764. }
  765. return SendClientMessage(playerid, COLOR_RED,
  766. "La casa non è in vendita.");
  767. }
  768. return 1;
  769. }
  770.  
  771. ocmd:f(playerid,params[])
  772. {
  773. if(isPlayerInFrakt(playerid, 0))return SendClientMessage(
  774. playerid, COLOR_RED, "Non sei in nessuna fazione.");
  775. new string[128];
  776. if(sscanf(params, "s[128]", string))return SendClientMessage(
  777. playerid, COLOR_RED, "INFO: /f [messaggio]");
  778. new fID = sInfo[playerid][fraktion];
  779. format(string,sizeof(string), "**(( %s: %s ))**", getPlayerName(playerid), string);
  780. for(new i=0; i<MAX_PLAYERS; i++)
  781. {
  782. if(!IsPlayerConnected(i))continue;
  783. if(!isPlayerInFrakt(i, fID))continue;
  784. SendClientMessage(i, COLOR_BLUE, string);
  785. }
  786. return 1;
  787. }
  788.  
  789. ocmd:invita(playerid,params[])
  790. {
  791. if(isPlayerInFrakt(playerid, 0))return SendClientMessage(
  792. playerid, COLOR_RED, "Non sei in nessuna fazione.");
  793. if(sInfo[playerid][rang] < 6)return SendClientMessage(
  794. playerid, COLOR_RED, "Il tuo rango è troppo basso.");
  795. new pID, fID;
  796. fID = sInfo[playerid][fraktion];
  797. if(sscanf(params, "u", pID))return SendClientMessage(
  798. playerid, COLOR_RED, "INFO: /invita [playerid]");
  799. if(!isPlayerInFrakt(pID, 0))return SendClientMessage(
  800. playerid, COLOR_RED, "Il giocatore non è un civile.");
  801. new string[128];
  802. format(string,sizeof(string), "%s ti ha invitato alla %s fazione.",
  803. getPlayerName(playerid), fInfo[fID][f_name]);
  804. SendClientMessage(pID, COLOR_YELLOW, string);
  805. SendClientMessage(pID, COLOR_YELLOW,
  806. "Hai ricevuto un invito fai /accetta.");
  807. SetPVarInt(pID, "inv_fraktid", fID);
  808. SetPVarInt(pID, "inv_inviter", playerid);
  809. return 1;
  810. }
  811.  
  812. ocmd:togliinvito(playerid,params[])
  813. {
  814. if(isPlayerInFrakt(playerid, 0))return SendClientMessage(
  815. playerid, COLOR_RED, "Non sei in nessuna fazione.");
  816. if(sInfo[playerid][rang] < 6)return SendClientMessage(
  817. playerid, COLOR_RED, "Il tuo rango è troppo basso.");
  818. new pID;
  819. if(sscanf(params, "u", pID))return SendClientMessage(
  820. playerid, COLOR_RED, "INFO: /togliinvito [playerid]");
  821. if(!isPlayerInFrakt(pID, sInfo[playerid][fraktion]))return SendClientMessage(
  822. playerid, COLOR_RED, "Il giocatore non è nella fazione.");
  823. sInfo[pID][fraktion] = 0;
  824. sInfo[pID][rang] = 0;
  825. new string[128];
  826. format(string,sizeof(string),"Sei stato cacciato %s dalla fazione.",
  827. getPlayerName(playerid));
  828. SendClientMessage(pID, COLOR_RED, string);
  829. format(string,sizeof(string),"Hai buttato %s fuori dalla fazione.",
  830. getPlayerName(pID));
  831. SendClientMessage(playerid, COLOR_YELLOW, string);
  832. return 1;
  833. }
  834.  
  835.  
  836.  
  837. ocmd:accetta(playerid, params[])
  838. {
  839. new item[64];
  840. if(sscanf(params,"s[64]",item))return SendClientMessage(
  841. playerid, COLOR_RED, "INFO: /accetta [invito]");
  842. if(!strcmp(item, "invita", false))
  843. {
  844. if(GetPVarInt(playerid, "inv_fraktid") == 0)return SendClientMessage(
  845. playerid, COLOR_RED, "Sei stato invitato nella fazione.");
  846. new fID = GetPVarInt(playerid, "inv_fraktid");
  847. sInfo[playerid][fraktion] = fID;
  848. sInfo[playerid][rang] = 1;
  849. new string[128];
  850. format(string,sizeof(string), "Ti sei unito alla %s fazione.",
  851. fInfo[fID][f_name]);
  852. SendClientMessage(playerid, COLOR_YELLOW, string);
  853. format(string,sizeof(string), "%s sei entrato nella fazione.",
  854. getPlayerName(playerid));
  855. SendClientMessage(GetPVarInt(playerid, "inv_inviter"), COLOR_RED,
  856. string);
  857. SetPVarInt(playerid, "inv_fraktid", 0);
  858. return 1;
  859. }
  860. return 1;
  861. }
  862.  
  863. ocmd:cambiaspawn(playerid, params[])
  864. {
  865. if(isPlayerInFrakt(playerid, 0))return SendClientMessage(
  866. playerid, COLOR_RED, "Non sei in nessuna fazione.");
  867. if(sInfo[playerid][spawnchange]==0)
  868. {
  869. sInfo[playerid][spawnchange]=1;
  870. }
  871. if(sInfo[playerid][spawnchange]==1)
  872. {
  873. sInfo[playerid][spawnchange]=0;
  874. }
  875. SendClientMessage(playerid,COLOR_YELLOW, "Spawn cambiato.");
  876. return 1;
  877. }
  878.  
  879. ocmd:settaleader(playerid, params[])
  880. {
  881. if(!isAdmin(playerid, 3))return SendClientMessage(playerid,
  882. COLOR_RED, "Il tuo rank admin è troppo basso.");
  883. new pID, fID;
  884. if(sscanf(params,"ui",pID,fID))return SendClientMessage(playerid,
  885. COLOR_RED, "INFO: /settaleader [playerid] [livello]");
  886. if(fID >= sizeof(fInfo))return SendClientMessage(playerid,
  887. COLOR_RED, "Il giocatore non esiste.");
  888. sInfo[pID][fraktion] = fID;
  889. sInfo[pID][rang] = 6;
  890. new string[128];
  891. format(string,sizeof(string),
  892. "%s ha settato leader del %s gruppo",
  893. getPlayerName(playerid), fInfo[fID][f_name]);
  894. SendClientMessage(pID, COLOR_YELLOW, string);
  895. SendClientMessage(playerid, COLOR_RED, "Hai messo il giocatore leader.");
  896. return 1;
  897. }
  898.  
  899. ocmd:luci(playerid,params[])
  900. {
  901. if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)return
  902. SendClientMessage(playerid,COLOR_RED,"Non sei al posto di guida.");
  903.  
  904. new vID=GetPlayerVehicleID(playerid),
  905. tmp_engine,
  906. tmp_lights,
  907. tmp_alarm,
  908. tmp_doors,
  909. tmp_bonnet,
  910. tmp_boot,
  911. tmp_objective;
  912. //Spegnere il motore
  913. GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
  914. if(tmp_lights==1){
  915. tmp_lights = 0;
  916. }else{
  917. tmp_lights = 1;
  918. }
  919. SetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
  920. return 1;
  921. }
  922.  
  923. ocmd:motore(playerid,params[])
  924. {
  925. if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER)return
  926. SendClientMessage(playerid,COLOR_RED,"Non sei al posto di guida.");
  927.  
  928. new vID=GetPlayerVehicleID(playerid),
  929. tmp_engine,
  930. tmp_lights,
  931. tmp_alarm,
  932. tmp_doors,
  933. tmp_bonnet,
  934. tmp_boot,
  935. tmp_objective;
  936. //Spegnere il motore
  937. GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
  938. if(tmp_engine==1){
  939. tmp_engine = 0;
  940. }else{
  941. tmp_engine = 1;
  942. }
  943. SetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
  944. return 1;
  945. }
  946.  
  947. ocmd:freeza(playerid,params[])
  948. {
  949. TogglePlayerControllable(playerid,false);
  950. SetTimerEx("unfreezePlayer",3000,false,"i",playerid);
  951. return 1;
  952. }
  953.  
  954. ocmd:goto(playerid,params[])
  955. {
  956. new ID;
  957. if(sscanf(params, "u", ID)) SendClientMessage(playerid, 0xFF0000FF, "Usa: /goto [playerid]");
  958. else if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, 0xFF0000FF, "Questo giocatore non è in game");
  959. else
  960. {
  961. new Float:x, Float:y, Float:z;
  962. GetPlayerPos(ID, x, y, z);
  963. SetPlayerPos(playerid, x+1, y+1, z);
  964. }
  965. return 1;
  966. }
  967. ocmd:stoppatimer(playerid,params[])
  968. {
  969. KillTimer(sekunden_timer);
  970. return 1;
  971. }
  972.  
  973. ocmd:eliminaveicolo(playerid,params[])
  974. {
  975. if(!isAdmin(playerid,2))return SendClientMessage(playerid,COLOR_RED,"Il tuo rank admin è basso.");
  976. if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,COLOR_RED,"Sei nella macchina.");
  977. DestroyVehicle(GetPlayerVehicleID(playerid));
  978. return 1;
  979. }
  980.  
  981. ocmd:creaveicolo(playerid,params[])
  982. {
  983. if(!isAdmin(playerid,2))return SendClientMessage(playerid,COLOR_RED,"Il tuo rank admin è basso.");
  984. new mID,pID;
  985. if(sscanf(params,"ui",pID,mID))return SendClientMessage(playerid,COLOR_RED,"INFO: /creaveicolo [playerid] [modello]");
  986. if(mID<400||mID>611)return SendClientMessage(playerid,COLOR_RED,"Modello invalido.");
  987. new Float:xc,Float:yc,Float:zc,Float:rc;
  988. GetPlayerPos(pID,xc,yc,zc);
  989. GetPlayerFacingAngle(pID,rc);
  990. createPlayerCar(pID,mID,xc,yc,zc,rc);
  991. return 1;
  992. }
  993.  
  994. ocmd:esci(playerid,params[])
  995. {
  996. for(new i=0; i<sizeof(bInfo); i++)
  997. {
  998. if(GetPlayerVirtualWorld(playerid)!=i)continue;
  999. if(!IsPlayerInRangeOfPoint(playerid,2,bInfo[i][b_ix],bInfo[i][b_iy],bInfo[i][b_iz]))continue;
  1000. SetPlayerPos(playerid,bInfo[i][b_x],bInfo[i][b_y],bInfo[i][b_z]);
  1001. SetPlayerInterior(playerid,0);
  1002. SetPlayerVirtualWorld(playerid,0);
  1003. return 1;
  1004. }
  1005. for(new i=0; i<sizeof(hInfo); i++)
  1006. {
  1007. if(GetPlayerVirtualWorld(playerid)!=i)continue;
  1008. if(!IsPlayerInRangeOfPoint(playerid,2,hInfo[i][ih_x],hInfo[i][ih_y],hInfo[i][ih_z]))continue;
  1009. SetPlayerPos(playerid, hInfo[i][h_x], hInfo[i][h_y], hInfo[i][h_z]);
  1010. SetPlayerInterior(playerid, 0);
  1011. SetPlayerVirtualWorld(playerid, 0);
  1012. return 1;
  1013. }
  1014. return 1;
  1015. }
  1016.  
  1017. ocmd:megafono(playerid, params[])
  1018. {
  1019. if(!sscanf(params, "s[250]", params))
  1020. {
  1021. format(Message, sizeof(Message), "*MEGAFONO* %s", params);
  1022. ProxDetector(15.0, playerid, Message, 0xFF0000FF);
  1023. return 1;
  1024. }
  1025.  
  1026. new str1[2500], c1 = 0;
  1027. for(new w1 = 0; w1 < sizeof(MegaphoneSounds); w1++)
  1028. {
  1029. new tmp1[2][128];
  1030. split(MegaphoneSounds[w1], tmp1, ',');
  1031. if(c1 == 0) format(str1, sizeof(str1), "{FFFFFF}%s\n", tmp1[1]);
  1032. if(c1 > 0) format(str1, sizeof(str1), "%s{FFFFFF}%s\n", str1, tmp1[1]);
  1033. c1++;
  1034. }
  1035. ShowPlayerDialog(playerid, DIALOG_MEGAPHONE_MENU, DIALOG_STYLE_LIST, "Menu Megafono", str1, "Inizia", "Annulla");
  1036. return 1;
  1037. }
  1038.  
  1039. ocmd:entra(playerid,params[])
  1040. {
  1041. for(new i=0; i<sizeof(bInfo); i++)
  1042. {
  1043. if(!IsPlayerInRangeOfPoint(playerid,2,bInfo[i][b_x],bInfo[i][b_y],bInfo[i][b_z]))continue;
  1044. SetPlayerPos(playerid,bInfo[i][b_ix],bInfo[i][b_iy],bInfo[i][b_iz]);
  1045. SetPlayerInterior(playerid,bInfo[i][b_interior]);
  1046. SetPlayerVirtualWorld(playerid,i);
  1047. SetPlayerShopName(playerid,bInfo[i][b_shopname]);
  1048. return 1;
  1049. }
  1050. for(new i=0; i<sizeof(hInfo); i++)
  1051. {
  1052. if(!hInfo[i][h_id])continue;
  1053. if(hInfo[i][ih_x]==0.0)continue;
  1054. if(!IsPlayerInRangeOfPoint(playerid,2,hInfo[i][h_x],hInfo[i][h_y],hInfo[i][h_z]))continue;
  1055. SetPlayerPos(playerid,hInfo[i][ih_x],hInfo[i][ih_y],hInfo[i][ih_z]);
  1056. SetPlayerInterior(playerid,hInfo[i][h_interior]);
  1057. SetPlayerVirtualWorld(playerid,i);
  1058. return 1;
  1059. }
  1060. return 1;
  1061. }
  1062.  
  1063. ocmd:pm(playerid,params[])
  1064. {
  1065. new pID,text[128];
  1066. if(sscanf(params,"us[128]",pID,text))return SendClientMessage(playerid,COLOR_RED,"INFO: /pn [playerid] [testo]");
  1067. SendClientMessage(pID,COLOR_RED,text);
  1068. return 1;
  1069. }
  1070.  
  1071. ocmd:settadmin(playerid,params[])
  1072. {
  1073. if(!isAdmin(playerid,3))return SendClientMessage(playerid,COLOR_RED,"Sei un rank admin basso.");
  1074. new pID,a_level;
  1075. if(sscanf(params,"ui",pID,a_level))return SendClientMessage(playerid,COLOR_RED,"INFO: /settadmin [playerid] [livelloadmin]");
  1076. sInfo[pID][alevel]=a_level;
  1077. savePlayer(pID);
  1078. SendClientMessage(pID,COLOR_RED,"Il tuo rank admin è stato cambiato.");
  1079. SendClientMessage(playerid,COLOR_RED,"Ha cambiato il rank.");
  1080. return 1;
  1081. }
  1082.  
  1083. isAdmin(playerid,a_level)
  1084. {
  1085. if(sInfo[playerid][alevel]>=a_level)return 1;
  1086. return 0;
  1087. }
  1088.  
  1089. ocmd:restarta(playerid,params[])
  1090. {
  1091. if(!isAdmin(playerid,3))return SendClientMessage(playerid,COLOR_RED,"Sei un rank admin basso.");
  1092. SendRconCommand("gmx");
  1093. return 1;
  1094. }
  1095.  
  1096. ocmd:test(playerid,params[])
  1097. {
  1098. SendClientMessage(playerid,COLOR_RED,"Hai fatto il /test.");
  1099. return 1;
  1100. }
  1101.  
  1102.  
  1103. public OnPlayerCommandText(playerid, cmdtext[])
  1104. {
  1105. return 0;
  1106. }
  1107.  
  1108. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  1109. {
  1110. return 1;
  1111. }
  1112.  
  1113. public OnPlayerExitVehicle(playerid, vehicleid)
  1114. {
  1115. return 1;
  1116. }
  1117.  
  1118. public OnPlayerStateChange(playerid, newstate, oldstate)
  1119. {
  1120. if(newstate==PLAYER_STATE_DRIVER)
  1121. {
  1122. new vID=GetPlayerVehicleID(playerid);
  1123. new vModel=GetVehicleModel(vID);
  1124.  
  1125. for(new i=0; i<sizeof(autosOhneMotor); i++)
  1126. {
  1127. if(autosOhneMotor[i]!=vModel)continue;
  1128. new tmp_engine,
  1129. tmp_lights,
  1130. tmp_alarm,
  1131. tmp_doors,
  1132. tmp_bonnet,
  1133. tmp_boot,
  1134. tmp_objective;
  1135. //Spegnere motore
  1136. GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
  1137. SetVehicleParamsEx(vID, 1, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
  1138. }
  1139.  
  1140. for(new i=0; i<sizeof(ahCars); i++)
  1141. {
  1142. if(ahCars[i][id_x]!=vID)continue;
  1143. //Vendita
  1144. SetPVarInt(playerid,"buyCarID",i);
  1145. new string[256];
  1146. format(string,sizeof(string),"Vuoi comprare l'auto %i$ per?",ahCars[i][c_preis]);
  1147. ShowPlayerDialog(playerid,DIALOG_AUTOHAUS,DIALOG_STYLE_MSGBOX,"Vendita auto",string,"Si","No");
  1148. break;
  1149. }
  1150. return 1;
  1151. }
  1152. return 1;
  1153. }
  1154.  
  1155. public OnPlayerEnterCheckpoint(playerid)
  1156. {
  1157. return 1;
  1158. }
  1159.  
  1160. public OnPlayerLeaveCheckpoint(playerid)
  1161. {
  1162. return 1;
  1163. }
  1164.  
  1165. public OnPlayerEnterRaceCheckpoint(playerid)
  1166. {
  1167. return 1;
  1168. }
  1169.  
  1170. public OnPlayerLeaveRaceCheckpoint(playerid)
  1171. {
  1172. return 1;
  1173. }
  1174.  
  1175. public OnRconCommand(cmd[])
  1176. {
  1177. return 1;
  1178. }
  1179.  
  1180. public OnPlayerRequestSpawn(playerid)
  1181. {
  1182. return 1;
  1183. }
  1184.  
  1185. public OnObjectMoved(objectid)
  1186. {
  1187. return 1;
  1188. }
  1189.  
  1190. public OnPlayerObjectMoved(playerid, objectid)
  1191. {
  1192. return 1;
  1193. }
  1194.  
  1195. public OnPlayerPickUpPickup(playerid, pickupid)
  1196. {
  1197. return 1;
  1198. }
  1199.  
  1200. public OnVehicleMod(playerid, vehicleid, componentid)
  1201. {
  1202. return 1;
  1203. }
  1204.  
  1205. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  1206. {
  1207. return 1;
  1208. }
  1209.  
  1210. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  1211. {
  1212. return 1;
  1213. }
  1214.  
  1215. public OnPlayerSelectedMenuRow(playerid, row)
  1216. {
  1217. return 1;
  1218. }
  1219.  
  1220. public OnPlayerExitedMenu(playerid)
  1221. {
  1222. return 1;
  1223. }
  1224.  
  1225. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  1226. {
  1227. return 1;
  1228. }
  1229.  
  1230. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  1231. {
  1232. if(newkeys & KEY_YES)
  1233. {
  1234. //Inserisci comando
  1235. ocmd_entra(playerid,"");
  1236. return 1;
  1237. }
  1238. if(newkeys & KEY_NO)
  1239. {
  1240. //Comando exit
  1241. ocmd_esci(playerid,"");
  1242. return 1;
  1243. }
  1244. if(newkeys & KEY_ACTION)
  1245. {
  1246. if(!IsPlayerInAnyVehicle(playerid))return 1;
  1247. if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 525)return 1;
  1248. //Veicoli
  1249. new vID = GetPlayerVehicleID(playerid);
  1250. if(IsTrailerAttachedToVehicle(vID))
  1251. {
  1252. //Veicolo
  1253. DetachTrailerFromVehicle(vID);
  1254. }
  1255. else
  1256. {
  1257. //Veicolo
  1258. new carID = INVALID_VEHICLE_ID;
  1259. new Float:abstand = 8;
  1260. new Float:xc, Float:yc, Float:zc;
  1261. GetVehiclePos(vID, xc, yc, zc);
  1262. for(new i=0; i<MAX_VEHICLES; i++)
  1263. {
  1264. if(!IsVehicleStreamedIn(i, playerid))continue;
  1265. if(i==vID)continue;
  1266. if(GetVehicleDistanceFromPoint(i, xc, yc, zc) < abstand)
  1267. {
  1268. abstand = GetVehicleDistanceFromPoint(i, xc, yc, zc);
  1269. carID = i;
  1270. }
  1271. }
  1272. if(carID != INVALID_VEHICLE_ID)
  1273. {
  1274. AttachTrailerToVehicle(carID, vID);
  1275. }
  1276. }
  1277.  
  1278. }
  1279. return 1;
  1280. }
  1281.  
  1282. public OnRconLoginAttempt(ip[], password[], success)
  1283. {
  1284. return 1;
  1285. }
  1286.  
  1287. public OnPlayerUpdate(playerid)
  1288. {
  1289. return 1;
  1290. }
  1291.  
  1292. public OnPlayerStreamIn(playerid, forplayerid)
  1293. {
  1294. return 1;
  1295. }
  1296.  
  1297. public OnPlayerStreamOut(playerid, forplayerid)
  1298. {
  1299. return 1;
  1300. }
  1301.  
  1302. public OnVehicleStreamIn(vehicleid, forplayerid)
  1303. {
  1304. return 1;
  1305. }
  1306.  
  1307. public OnVehicleStreamOut(vehicleid, forplayerid)
  1308. {
  1309. return 1;
  1310. }
  1311.  
  1312. SetPlayerMoney(playerid,money)
  1313. {
  1314. ResetPlayerMoney(playerid);
  1315. GivePlayerMoney(playerid,money);
  1316. return 1;
  1317. }
  1318.  
  1319. getFreeHausID()
  1320. {
  1321. for(new i=0; i<sizeof(hInfo); i++)
  1322. {
  1323. if(hInfo[i][h_id]==0)return i;
  1324. }
  1325. return 0;
  1326. }
  1327.  
  1328. getFreeCarID()
  1329. {
  1330. for(new i=0; i<sizeof(cInfo); i++)
  1331. {
  1332. if(cInfo[i][id_x]==0)return i;
  1333. }
  1334. return 0;
  1335. }
  1336.  
  1337. public OnPlayerCarsLoad(playerid)
  1338. {
  1339. new num_fields,num_rows;
  1340. cache_get_data(num_rows,num_fields,dbhandle);
  1341. if(!num_rows)return 1;
  1342. for(new i=0; i<num_rows; i++)
  1343. {
  1344. new id=getFreeCarID();
  1345. cInfo[id][model]=cache_get_field_content_int(i,"modello",dbhandle);
  1346. cInfo[id][besitzer]=cache_get_field_content_int(i,"proprietario",dbhandle);
  1347. cInfo[id][c_x]=cache_get_field_content_float(i,"x",dbhandle);
  1348. cInfo[id][c_y]=cache_get_field_content_float(i,"y",dbhandle);
  1349. cInfo[id][c_z]=cache_get_field_content_float(i,"z",dbhandle);
  1350. cInfo[id][c_r]=cache_get_field_content_float(i,"r",dbhandle);
  1351. cInfo[id][db_id]=cache_get_field_content_int(i,"id",dbhandle);
  1352. cInfo[id][id_x]=CreateVehicle(cInfo[id][model],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],-1,-1,-1);
  1353. }
  1354. return 1;
  1355. }
  1356.  
  1357. loadPlayerCars(playerid)
  1358. {
  1359. new query[128];
  1360. format(query,sizeof(query),"Seleziona * dalle auto del proprietario='%i'",sInfo[playerid][db_id]);
  1361. mysql_function_query(dbhandle,query,true,"OnPlayerCarsLoad","i",playerid);
  1362. return 1;
  1363. }
  1364.  
  1365. public OnPasswordResponse(playerid)
  1366. {
  1367. new num_fields,num_rows;
  1368. cache_get_data(num_rows,num_fields,dbhandle);
  1369. if(num_rows==1)
  1370. {
  1371. //Password
  1372. sInfo[playerid][eingeloggt] = 1;
  1373. sInfo[playerid][level] = cache_get_field_content_int(0,"level",dbhandle);
  1374. SetPlayerScore(playerid,sInfo[playerid][level]);
  1375. sInfo[playerid][db_id] = cache_get_field_content_int(0,"id",dbhandle);
  1376. SetPlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
  1377. sInfo[playerid][alevel] = cache_get_field_content_int(0,"alevel",dbhandle);
  1378. sInfo[playerid][fraktion] = cache_get_field_content_int(0,"fraktion",dbhandle);
  1379. sInfo[playerid][rang] = cache_get_field_content_int(0,"rang",dbhandle);
  1380. sInfo[playerid][spawnchange] = cache_get_field_content_int(0,"spawnchange",dbhandle);
  1381. loadPlayerCars(playerid);
  1382. }
  1383. else
  1384. {
  1385. //Password
  1386. SendClientMessage(playerid,COLOR_RED,"La password inserita è errata.");
  1387. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Logga","Si prega di inserire una propria password:","Ok","Esci");
  1388. }
  1389. return 1;
  1390. }
  1391.  
  1392. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  1393. {
  1394. if(dialogid==DIALOG_AUTOHAUS)
  1395. {
  1396. if(response)
  1397. {
  1398. //Vendita auto
  1399. new id=GetPVarInt(playerid,"buyCarID");
  1400. if(GetPlayerMoney(playerid)<ahCars[id][c_preis])
  1401. {
  1402. SendClientMessage(playerid,COLOR_RED,"Non hai abbastanza soldi.");
  1403. RemovePlayerFromVehicle(playerid);
  1404. return 1;
  1405. }
  1406. GivePlayerMoney(playerid,-ahCars[id][c_preis]);
  1407. createPlayerCar(playerid,ahCars[id][model],ahInfo[ahCars[id][ah_id]][s_x],ahInfo[ahCars[id][ah_id]][s_y],ahInfo[ahCars[id][ah_id]][s_z],ahInfo[ahCars[id][ah_id]][s_r]);
  1408. SendClientMessage(playerid,COLOR_RED,"Complimenti, hai acquistato l'auto");
  1409. RemovePlayerFromVehicle(playerid);
  1410. }
  1411. else
  1412. {
  1413. RemovePlayerFromVehicle(playerid);
  1414. SendClientMessage(playerid,COLOR_RED,"Allora non fare...");
  1415. }
  1416. return 1;
  1417. }
  1418. if(dialogid==DIALOG_LOGIN)
  1419. {
  1420. if(response)
  1421. {
  1422. new name[MAX_PLAYER_NAME],query[128],passwort[35];
  1423. GetPlayerName(playerid,name,sizeof(name));
  1424. if(strlen(inputtext)>0)
  1425. {
  1426. mysql_escape_string(inputtext,passwort,dbhandle);
  1427. format(query,sizeof(query),"Seleziona * il personaggio='%s' e password=MD5('%s')",name,passwort);
  1428. mysql_function_query(dbhandle,query,true,"OnPasswordResponse","i",playerid);
  1429. }
  1430. else
  1431. {
  1432. //Vietato accesso
  1433. SendClientMessage(playerid,COLOR_RED,"Si prega di inserire una propria password.");
  1434. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Logga","Si prega di inserire la password:","Ok","Esci");
  1435. }
  1436. }
  1437. else
  1438. {
  1439. Kick(playerid);
  1440. }
  1441. return 1;
  1442. }
  1443. if(dialogid==DIALOG_REGISTER)
  1444. {
  1445. if(response)
  1446. {
  1447. new name[MAX_PLAYER_NAME],query[128],passwort[35];
  1448. GetPlayerName(playerid,name,sizeof(name));
  1449. if(strlen(inputtext)>3)
  1450. {
  1451. //Registrazione
  1452. mysql_escape_string(inputtext,passwort,dbhandle);
  1453. format(query,sizeof(query),"Inserire nome (username,password) VALUES ('%s',MD5('%s')) ",name,passwort);
  1454. mysql_function_query(dbhandle,query,false,"","");
  1455. }
  1456. else
  1457. {
  1458. //Kleiner als 4 Zeichen
  1459. SendClientMessage(playerid,COLOR_RED,"La password deve essere lunga almeno 4 caratteri.");
  1460. ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrazione...","Inerisci la tua password:","Ok","Esci");
  1461. }
  1462. }
  1463. else
  1464. {
  1465. Kick(playerid);
  1466. }
  1467. return 1;
  1468. }
  1469. if(dialogid==DIALOG_TELEPORT)
  1470. {
  1471. if(response)
  1472. {
  1473. if(listitem==0)
  1474. {
  1475. //Spawn
  1476. SetPlayerPos(playerid,199.0846,-150.0331,1.5781);
  1477. }
  1478. if(listitem==1)
  1479. {
  1480. //Farm
  1481. SetPlayerPos(playerid,0.0,0.0,6.0);
  1482. }
  1483. }
  1484. else
  1485. {
  1486. SendClientMessage(playerid,COLOR_RED,"Operazione riuscita.");
  1487. }
  1488. return 1;
  1489. }
  1490. return 1;
  1491. }
  1492. {
  1493. if(dialogid == DIALOG_MEGAPHONE_MENU)
  1494. {
  1495. if(!response) return SCM(playerid, COLOR_WHITE, "Annulla");
  1496. new soundid, tw1 = 0;
  1497. for(new w1 = 0; w1 < sizeof(MegaphoneSounds); w1++)
  1498. {
  1499. if(tw1 != listitem)
  1500. {
  1501. tw1++;
  1502. continue;
  1503. }
  1504. new tmp1[2][128];
  1505. split(MegaphoneSounds[w1], tmp1, ',');
  1506. soundid = strval(tmp1[0]);
  1507. break;
  1508. }
  1509. new Float:pos[4];
  1510. GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  1511. PlaySoundEx(soundid, pos[0], pos[1], pos[2], 15);
  1512. return 1;
  1513. }
  1514. return 0;
  1515. }
  1516.  
  1517. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  1518. {
  1519. return 1;
  1520. }
Advertisement
Add Comment
Please, Sign In to add comment