Guest User

Untitled

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