Guest User

Untitled

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