Advertisement
Guest User

Untitled

a guest
Apr 11th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.62 KB | None | 0 0
  1. //Includes
  2. #include <a_samp>
  3. #include <sscanf2>
  4. #include <a_mysql>
  5. #include <zcmd>
  6.  
  7. //enums
  8. enum playerInfo{
  9. peingeloggt,
  10. plevel,
  11. pid,
  12. padmin
  13. }
  14.  
  15. //Globale Variablen
  16. new dbhandle;
  17. new sInfo[MAX_PLAYERS][playerInfo];
  18.  
  19. //Farben
  20. #define COLOR_RED 0xFF0000FF
  21. #define COLOR_GREY 0xBEBEBEFF
  22. #define COLOR_YELLOW 0xF5FF00FF
  23. //Dialoge
  24. #define DIALOG_TELEPORT 1
  25. #define DIALOG_REGISTER 2
  26. #define DIALOG_LOGIN 3
  27.  
  28. //MySQL
  29. #define db_host ""
  30. #define db_user ""
  31. #define db_pass ""
  32. #define db_db ""
  33.  
  34. //Textdraw´s
  35. new PlayerText:t_auswahl1;
  36. new PlayerText:t_auswahl2;
  37. new PlayerText:t_auswahl3;
  38. new PlayerText:t_auswahl4;
  39. new PlayerText:t_auswahl5;
  40.  
  41. //Forwards
  42. forward OnUserCheck(playerid);
  43. forward OnPasswordResponse(playerid);
  44.  
  45. main()
  46. {
  47.  
  48. }
  49.  
  50. public OnGameModeInit()
  51. {
  52. SetGameModeText("Cops and Robbers");
  53. AddPlayerClass(0,199.0846,-150.0331,1.5781,359.1443,0,0,0,0,0,0);
  54. DisableInteriorEnterExits();
  55. ManualVehicleEngineAndLights();
  56. //MySQL
  57. dbhandle = mysql_connect(db_host,db_user,db_db,db_pass);
  58. return 1;
  59. }
  60.  
  61. public OnGameModeExit()
  62. {
  63. mysql_close(dbhandle);
  64. return 1;
  65. }
  66.  
  67. public OnPlayerRequestClass(playerid, classid)
  68. {
  69. SetPlayerPos(playerid,199.0846,-150.0331,1.5781);
  70. SetPlayerCameraPos(playerid, 199.2307,-143.8328,1.5781);
  71. SetPlayerCameraLookAt(playerid, 199.0846,-150.0331,1.5781);
  72. SetPlayerFacingAngle(playerid,359.1443);
  73. return 1;
  74. }
  75.  
  76. public OnUserCheck(playerid)
  77. {
  78. new num_rows,num_fields;
  79. cache_get_data(num_rows,num_fields,dbhandle);
  80. if(num_rows==0)
  81. {
  82. //Registrierung
  83. ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrierung","Gib bitte dein gewünschtes Passwort an:","Okay","Abbrechen");
  84. }
  85. else
  86. {
  87. //Login
  88. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Okay","Abbrechen");
  89. }
  90. return 1;
  91. }
  92.  
  93. public OnPlayerConnect(playerid)
  94. {
  95. //Login/Register
  96. new name[MAX_PLAYER_NAME],query[128];
  97. GetPlayerName(playerid,name,sizeof(name));
  98. format(query,sizeof(query),"SELECT id FROM user WHERE username='%s'",name);
  99. mysql_function_query(dbhandle,query,true,"OnUserCheck","i",playerid);
  100. return 1;
  101. }
  102.  
  103. savePlayer(playerid)
  104. {
  105. if(sInfo[playerid][peingeloggt]==0)return 1;
  106. //Speichern level,money
  107. new query[128];
  108. format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',adminlevel='%i' WHERE id='%i'",sInfo[playerid][plevel],GetPlayerMoney(playerid),sInfo[playerid][padmin],sInfo[playerid][pid]);
  109. mysql_function_query(dbhandle,query,false,"","");
  110. return 1;
  111. }
  112.  
  113. resetPlayer(playerid)
  114. {
  115. for(new i=0;i<sizeof(sInfo[]); i++)
  116. {
  117. sInfo[playerid][playerInfo:i] = 0;
  118. }
  119. return 1;
  120. }
  121.  
  122. public OnPlayerDisconnect(playerid, reason)
  123. {
  124. savePlayer(playerid);
  125. resetPlayer(playerid);
  126. return 1;
  127. }
  128.  
  129. public OnPlayerSpawn(playerid)
  130. {
  131. return 1;
  132. }
  133.  
  134. public OnPlayerDeath(playerid, killerid, reason)
  135. {
  136. return 1;
  137. }
  138.  
  139. public OnVehicleSpawn(vehicleid)
  140. {
  141. return 1;
  142. }
  143.  
  144. public OnVehicleDeath(vehicleid, killerid)
  145. {
  146. return 1;
  147. }
  148.  
  149. public OnPlayerText(playerid, text[])
  150. {
  151. return 1;
  152. }
  153.  
  154.  
  155. public OnPlayerCommandText(playerid, cmdtext[])
  156. {
  157. return 0;
  158. }
  159.  
  160. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  161. {
  162. return 1;
  163. }
  164.  
  165. public OnPlayerExitVehicle(playerid, vehicleid)
  166. {
  167. return 1;
  168. }
  169.  
  170. public OnPlayerStateChange(playerid, newstate, oldstate)
  171. {
  172. return 1;
  173. }
  174.  
  175. public OnPlayerEnterCheckpoint(playerid)
  176. {
  177. return 1;
  178. }
  179.  
  180. public OnPlayerLeaveCheckpoint(playerid)
  181. {
  182. return 1;
  183. }
  184.  
  185. public OnPlayerEnterRaceCheckpoint(playerid)
  186. {
  187. return 1;
  188. }
  189.  
  190. public OnPlayerLeaveRaceCheckpoint(playerid)
  191. {
  192. return 1;
  193. }
  194.  
  195. public OnRconCommand(cmd[])
  196. {
  197. return 1;
  198. }
  199.  
  200. public OnPlayerRequestSpawn(playerid)
  201. {
  202. return 1;
  203. }
  204.  
  205. public OnObjectMoved(objectid)
  206. {
  207. return 1;
  208. }
  209.  
  210. public OnPlayerObjectMoved(playerid, objectid)
  211. {
  212. return 1;
  213. }
  214.  
  215. public OnPlayerPickUpPickup(playerid, pickupid)
  216. {
  217. return 1;
  218. }
  219.  
  220. public OnVehicleMod(playerid, vehicleid, componentid)
  221. {
  222. return 1;
  223. }
  224.  
  225. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  226. {
  227. return 1;
  228. }
  229.  
  230. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  231. {
  232. return 1;
  233. }
  234.  
  235. public OnPlayerSelectedMenuRow(playerid, row)
  236. {
  237. return 1;
  238. }
  239.  
  240. public OnPlayerExitedMenu(playerid)
  241. {
  242. return 1;
  243. }
  244.  
  245. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  246. {
  247. return 1;
  248. }
  249.  
  250. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  251. {
  252. if(newkeys & KEY_ANALOG_DOWN)
  253. {
  254. new t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object;
  255. new vID = GetPlayerVehicleID(playerid);
  256. if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY," Du bist nicht der Fahrer dest Fahrzeuges!");
  257. GetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
  258. if(t_engine == 1)
  259. {
  260. t_engine = 0;
  261. SendClientMessage(playerid,COLOR_YELLOW,"Motor ausgeschaltet!");
  262. }else{
  263. t_engine = 1;
  264. SendClientMessage(playerid,COLOR_YELLOW,"Motor angeschaltet!");
  265. }
  266. SetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
  267. return 1;
  268. }
  269. return 1;
  270. }
  271.  
  272. public OnRconLoginAttempt(ip[], password[], success)
  273. {
  274. return 1;
  275. }
  276.  
  277. public OnPlayerUpdate(playerid)
  278. {
  279. return 1;
  280. }
  281.  
  282. public OnPlayerStreamIn(playerid, forplayerid)
  283. {
  284. return 1;
  285. }
  286.  
  287. public OnPlayerStreamOut(playerid, forplayerid)
  288. {
  289. return 1;
  290. }
  291.  
  292. public OnVehicleStreamIn(vehicleid, forplayerid)
  293. {
  294. return 1;
  295. }
  296.  
  297. public OnVehicleStreamOut(vehicleid, forplayerid)
  298. {
  299. return 1;
  300. }
  301.  
  302. SetPlayerMoney(playerid,money)
  303. {
  304. ResetPlayerMoney(playerid);
  305. GivePlayerMoney(playerid,money);
  306. return 1;
  307. }
  308.  
  309. public OnPasswordResponse(playerid)
  310. {
  311. new num_fields,num_rows;
  312. cache_get_data(num_rows,num_fields,dbhandle);
  313. if(num_rows==1)
  314. {
  315. //Passwort richtig
  316. sInfo[playerid][peingeloggt] = 1;
  317. sInfo[playerid][plevel] = cache_get_field_content_int(0,"level",dbhandle);
  318. sInfo[playerid][padmin] = cache_get_field_content_int(0,"adminlevel",dbhandle);
  319. SetPlayerScore(playerid,sInfo[playerid][plevel]);
  320. sInfo[playerid][pid] = cache_get_field_content_int(0,"id",dbhandle);
  321. SetPlayerMoney(playerid,cache_get_field_content_int(0,"money",dbhandle));
  322. }
  323. else
  324. {
  325. //Passwort falsch
  326. SendClientMessage(playerid,COLOR_RED,"Das eingegebene Passwort ist falsch.");
  327. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Okay","Abbrechen");
  328. }
  329. return 1;
  330. }
  331.  
  332. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  333. {
  334. if(dialogid==DIALOG_LOGIN)
  335. {
  336. if(response)
  337. {
  338. new name[MAX_PLAYER_NAME],query[128],passwort[35];
  339. GetPlayerName(playerid,name,sizeof(name));
  340. if(strlen(inputtext)>0)
  341. {
  342. mysql_escape_string(inputtext,passwort,dbhandle);
  343. format(query,sizeof(query),"SELECT * FROM user WHERE username='%s' AND password='%s'",name,passwort);
  344. mysql_function_query(dbhandle,query,true,"OnPasswordResponse","i",playerid);
  345. }
  346. else
  347. {
  348. //Keine Eingabe
  349. SendClientMessage(playerid,COLOR_RED,"Gibt bitte dein Passwort ein.");
  350. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Gibt bitte dein Passwort ein:","Okay","Abbrechen");
  351. }
  352. }
  353. else
  354. {
  355. Kick(playerid);
  356. }
  357. return 1;
  358. }
  359. if(dialogid==DIALOG_REGISTER)
  360. {
  361. if(response)
  362. {
  363. new name[MAX_PLAYER_NAME],query[128],passwort[35];
  364. GetPlayerName(playerid,name,sizeof(name));
  365. if(strlen(inputtext)>3)
  366. {
  367. //Registrierungsfunktion
  368. mysql_escape_string(inputtext,passwort,dbhandle);
  369. format(query,sizeof(query),"INSERT INTO user (username,password) VALUES ('%s','%s') ",name,passwort);
  370. mysql_function_query(dbhandle,query,false,"","");
  371.  
  372. t_auswahl1 = CreatePlayerTextDraw(playerid,178.000000, 107.000000, "_");
  373. PlayerTextDrawBackgroundColor(playerid,t_auswahl1, 255);
  374. PlayerTextDrawFont(playerid,t_auswahl1, 1);
  375. PlayerTextDrawLetterSize(playerid,t_auswahl1, 0.100000, 20.699987);
  376. PlayerTextDrawColor(playerid,t_auswahl1, -1);
  377. PlayerTextDrawSetOutline(playerid,t_auswahl1, 0);
  378. PlayerTextDrawSetProportional(playerid,t_auswahl1, 1);
  379. PlayerTextDrawSetShadow(playerid,t_auswahl1, 1);
  380. PlayerTextDrawUseBox(playerid,t_auswahl1, 1);
  381. PlayerTextDrawBoxColor(playerid,t_auswahl1, 85);
  382. PlayerTextDrawTextSize(playerid,t_auswahl1, 451.000000, 1.000000);
  383. PlayerTextDrawSetSelectable(playerid,t_auswahl1, 0);
  384.  
  385. t_auswahl2 = CreatePlayerTextDraw(playerid,187.000000, 125.000000, "Kriminelle");
  386. PlayerTextDrawBackgroundColor(playerid,t_auswahl2, 255);
  387. PlayerTextDrawFont(playerid,t_auswahl2, 1);
  388. PlayerTextDrawLetterSize(playerid,t_auswahl2, 0.620000, 1.200000);
  389. PlayerTextDrawColor(playerid,t_auswahl2, -1);
  390. PlayerTextDrawSetOutline(playerid,t_auswahl2, 0);
  391. PlayerTextDrawSetProportional(playerid,t_auswahl2, 1);
  392. PlayerTextDrawSetShadow(playerid,t_auswahl2, 1);
  393. PlayerTextDrawSetSelectable(playerid,t_auswahl2, 1);
  394. SelectTextDraw(playerid, 0xFF4040AA);
  395.  
  396. t_auswahl3 = CreatePlayerTextDraw(playerid,363.000000, 125.000000, "Polizei");
  397. PlayerTextDrawBackgroundColor(playerid,t_auswahl3, 255);
  398. PlayerTextDrawFont(playerid,t_auswahl3, 1);
  399. PlayerTextDrawLetterSize(playerid,t_auswahl3, 0.620000, 1.200000);
  400. PlayerTextDrawColor(playerid,t_auswahl3, -1);
  401. PlayerTextDrawSetOutline(playerid,t_auswahl3, 0);
  402. PlayerTextDrawSetProportional(playerid,t_auswahl3, 1);
  403. PlayerTextDrawSetShadow(playerid,t_auswahl3, 1);
  404. PlayerTextDrawSetSelectable(playerid,t_auswahl3, 1);
  405. SelectTextDraw(playerid, 0xFFFA00FF);
  406.  
  407. t_auswahl4 = CreatePlayerTextDraw(playerid,204.000000, 151.000000, "_");
  408. PlayerTextDrawBackgroundColor(playerid,t_auswahl4, 255);
  409. PlayerTextDrawFont(playerid,t_auswahl4, 1);
  410. PlayerTextDrawLetterSize(playerid,t_auswahl4, 0.500000, 10.000000);
  411. PlayerTextDrawColor(playerid,t_auswahl4, -1);
  412. PlayerTextDrawSetOutline(playerid,t_auswahl4, 0);
  413. PlayerTextDrawSetProportional(playerid,t_auswahl4, 1);
  414. PlayerTextDrawSetShadow(playerid,t_auswahl4, 1);
  415. PlayerTextDrawUseBox(playerid,t_auswahl4, 1);
  416. PlayerTextDrawBoxColor(playerid,t_auswahl4, 90);
  417. PlayerTextDrawTextSize(playerid,t_auswahl4, 259.000000, 0.000000);
  418. PlayerTextDrawSetSelectable(playerid,t_auswahl4, 0);
  419. PlayerTextDrawSetPreviewModel(playerid, t_auswahl4, 107);
  420.  
  421. t_auswahl5 = CreatePlayerTextDraw(playerid,427.000000, 151.000000, "_");
  422. PlayerTextDrawBackgroundColor(playerid,t_auswahl5, 255);
  423. PlayerTextDrawFont(playerid,t_auswahl5, 1);
  424. PlayerTextDrawLetterSize(playerid,t_auswahl5, 2.010000, 10.000000);
  425. PlayerTextDrawColor(playerid,t_auswahl5, -1);
  426. PlayerTextDrawSetOutline(playerid,t_auswahl5, 0);
  427. PlayerTextDrawSetProportional(playerid,t_auswahl5, 1);
  428. PlayerTextDrawSetShadow(playerid,t_auswahl5, 1);
  429. PlayerTextDrawUseBox(playerid,t_auswahl5, 1);
  430. PlayerTextDrawBoxColor(playerid,t_auswahl5, 90);
  431. PlayerTextDrawTextSize(playerid,t_auswahl5, 363.000000, 0.000000);
  432. PlayerTextDrawSetSelectable(playerid,t_auswahl5, 0);
  433. PlayerTextDrawSetPreviewModel(playerid, t_auswahl5, 283);
  434.  
  435. PlayerTextDrawShow(playerid,t_auswahl1);
  436. PlayerTextDrawShow(playerid,t_auswahl2);
  437. PlayerTextDrawShow(playerid,t_auswahl3);
  438. PlayerTextDrawShow(playerid,t_auswahl4);
  439. PlayerTextDrawShow(playerid,t_auswahl5);
  440.  
  441. }
  442. else
  443. {
  444. //Kleiner als 4 Zeichen
  445. SendClientMessage(playerid,COLOR_RED,"Dein Passwort muss mindestens 4 Zeichen lang sein.");
  446. ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrierung","Gib bitte dein gewünschtes Passwort an:","Okay","Abbrechen");
  447. }
  448. }
  449. else
  450. {
  451. Kick(playerid);
  452. }
  453. return 1;
  454. }
  455.  
  456. return 1;
  457. }
  458.  
  459. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  460. {
  461. return 1;
  462. }
  463.  
  464. stock isAnAdmin(playerid,ARang)
  465. {
  466. if(sInfo[playerid][padmin] >= ARang) return 1;
  467. return 0;
  468. }
  469.  
  470. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  471. {
  472. if(playertextid == t_auswahl2)
  473. {
  474. CancelSelectTextDraw(playerid);
  475. PlayerTextDrawHide(playerid, t_auswahl1);
  476. PlayerTextDrawHide(playerid, t_auswahl2);
  477. PlayerTextDrawHide(playerid, t_auswahl3);
  478. PlayerTextDrawHide(playerid, t_auswahl4);
  479. PlayerTextDrawHide(playerid, t_auswahl5);
  480. SendClientMessage(playerid,COLOR_YELLOW,"Team Kriminell");
  481. return 1;
  482. }else if(playertextid == t_auswahl3)
  483. {
  484. CancelSelectTextDraw(playerid);
  485. PlayerTextDrawHide(playerid, t_auswahl1);
  486. PlayerTextDrawHide(playerid, t_auswahl2);
  487. PlayerTextDrawHide(playerid, t_auswahl3);
  488. PlayerTextDrawHide(playerid, t_auswahl4);
  489. PlayerTextDrawHide(playerid, t_auswahl5);
  490. SendClientMessage(playerid,COLOR_YELLOW,"Team Polizei");
  491. }
  492. return 1;
  493. }
  494. //BEFEHLE
  495. COMMAND:veh(playerid,params[])
  496. {
  497. new ModelID, color[2],Float:VehPos[4], vehicleid;
  498. if(GetPlayerState(playerid)!=PLAYER_STATE_ONFOOT) return SendClientMessage(playerid,0xB0AFB0FF,"Du bist nicht zu Fuss");
  499. if(sscanf(params, "ddd",ModelID,color[0],color[1])) return SendClientMessage(playerid,0xB0AFB0FF, "/veh [vehicleid] [color1] [color2]");
  500. if(ModelID < 400 || ModelID > 611) return SendClientMessage(playerid,0xB0AFB0FF, "Die Fahrzeug Id muss von 400 bis 611 sein");
  501. if(color[0] < 0 || color[0] > 126 || color[1] < 0 || color[1] > 126) return SendClientMessage(playerid,0xB0AFB0FF, "the colorid must be between 0 - 126");
  502. GetPlayerPos(playerid, VehPos[0],VehPos[1],VehPos[2]);
  503. GetPlayerFacingAngle(playerid, VehPos[3]);
  504. vehicleid = CreateVehicle(ModelID,VehPos[0],VehPos[1],VehPos[2],VehPos[3],color[0],color[1],-1);
  505. LinkVehicleToInterior(vehicleid,GetPlayerInterior(playerid));
  506. SetVehicleVirtualWorld(vehicleid,GetPlayerVirtualWorld(playerid));
  507. PutPlayerInVehicle(playerid, vehicleid, 0);
  508. return 1;
  509. }
  510. COMMAND:motor(playerid,params[])
  511. {
  512. new t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object;
  513. new vID = GetPlayerVehicleID(playerid);
  514. if(sInfo[playerid][peingeloggt] == 0) return SendClientMessage(playerid,COLOR_GREY," Du bist nicht eingeloggt!");
  515. if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY," Du bist nicht der Fahrer dest Fahrzeuges!");
  516. GetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
  517. if(t_engine == 1)
  518. {
  519. t_engine = 0;
  520. SendClientMessage(playerid,COLOR_YELLOW,"Motor ausgeschaltet!");
  521. }else{
  522. t_engine = 1;
  523. SendClientMessage(playerid,COLOR_YELLOW,"Motor angeschaltet!");
  524. }
  525. SetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
  526. return 1;
  527. }
  528. COMMAND:licht(playerid,params[])
  529. {
  530. new t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object;
  531. new vID = GetPlayerVehicleID(playerid);
  532. if(sInfo[playerid][peingeloggt] == 0) return SendClientMessage(playerid,COLOR_GREY," Du bist nicht eingeloggt!");
  533. if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY," Du bist nicht der Fahrer dest Fahrzeuges!");
  534. GetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
  535. if(t_lights == 1)
  536. {
  537. t_lights = 0;
  538. SendClientMessage(playerid,COLOR_YELLOW,"Licht ausgeschaltet!");
  539. }else{
  540. t_lights = 1;
  541. SendClientMessage(playerid,COLOR_YELLOW,"Licht angeschaltet!");
  542. }
  543. SetVehicleParamsEx(vID,t_engine,t_lights,t_alarm,t_doors,t_boonet,t_boot,t_object);
  544. return 1;
  545. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement