Guest User

Untitled

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