Advertisement
Guest User

erorcun

a guest
Oct 9th, 2009
1,814
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.39 KB | None | 0 0
  1. /*
  2. Seifistration System with login menu by Seif
  3. GUI modifications by erorcun
  4. */
  5. /*x---------------------------------Important-------------------------------------x*/
  6. //**INCLUDES**//
  7. #include <a_samp>
  8. //**PRAGMAS**//
  9.  
  10. //**MISC**//
  11.  
  12. /*x---------------------------------Defining-------------------------------------x*/
  13. //**COLORS*//
  14. #define GREEN 0x21DD00FF
  15. #define RED 0xE60000FF
  16. #define ADMIN_RED 0xFB0000FF
  17. #define YELLOW 0xFFFF00FF
  18. #define ORANGE 0xF97804FF
  19. #define LIGHTRED 0xFF8080FF
  20. #define LIGHTBLUE 0x00C2ECFF
  21. #define PURPLE 0xB360FDFF
  22. #define PLAYER_COLOR 0xFFFFFFFF
  23. #define BLUE 0x1229FAFF
  24. #define LIGHTGREEN 0x38FF06FF
  25. #define DARKPINK 0xE100E1FF
  26. #define DARKGREEN 0x008040FF
  27. #define ANNOUNCEMENT 0x6AF7E1FF
  28. #define COLOR_SYSTEM 0xEFEFF7AA
  29. #define GREY 0xCECECEFF
  30. #define PINK 0xD52DFFFF
  31. #define DARKGREY 0x626262FF
  32. #define AQUAGREEN 0x03D687FF
  33. #define NICESKY 0x99FFFFAA
  34. #define WHITE 0xFFFFFFFF
  35. ////**MISC**//
  36. #define ACCOUNTS_FOLDER "/sAccounts/%s.ini"
  37. #define FAILED_LOGIN_THRESHOLD 3
  38. #define SAVING_MONEY_SCORE_FIGHT_DRUNK 1
  39. #define SAVING_POS 1
  40. #define SAVING_WEAPON 1
  41. #define SAVING_ARMOUR 1
  42. #define SAVING_HEALTH 1
  43. //**VARIABLES**//
  44. enum aInfo
  45. {
  46. aPassword[128],
  47. aLogged,
  48. };
  49. enum aPos
  50. {
  51. aPosX, // To get the player's position from the ini file
  52. aPosY, // To get the player's position from the ini file
  53. aPosZ, // To get the player's position from the ini file
  54. aAngle, // To get the player's position from the ini file
  55. };
  56. new AccountInfo[MAX_PLAYERS][aInfo];
  57. new WeaponInfo[MAX_PLAYERS][12];
  58. new AmmoInfo[MAX_PLAYERS][12];
  59. new PositionInfo[MAX_PLAYERS][aPos];
  60. new register[MAX_PLAYERS];
  61. new login[MAX_PLAYERS];
  62. new failedlogin[MAX_PLAYERS] = 0;
  63. forward OnPlayerUpdate(playerid);
  64. new SAVE_MONEY_SCORE_FIGHT_DRUNK = SAVING_MONEY_SCORE_FIGHT_DRUNK, SAVE_POS = SAVING_POS, SAVE_WEAPON = SAVING_WEAPON, SAVE_ARMOUR = SAVING_ARMOUR, SAVE_HEALTH = SAVING_HEALTH;
  65. /*x---------------------------------CallBacks-------------------------------------x*/
  66. public OnGameModeInit()
  67. {
  68. SendRconCommand("reloadfs SeifistrationAdv");
  69. return 1;
  70. }
  71.  
  72. public OnPlayerConnect(playerid)
  73. {
  74. AccountInfo[playerid][aLogged] = 0;
  75. failedlogin[playerid] = 0;
  76. return 1;
  77. }
  78.  
  79. public OnPlayerDisconnect(playerid, reason)
  80. {
  81. OnPlayerUpdate(playerid);
  82. AccountInfo[playerid][aLogged] = 0;
  83. register[playerid] = 0;
  84. login[playerid] = 0;
  85. failedlogin[playerid] = 0;
  86. return 1;
  87. }
  88.  
  89. public OnPlayerSpawn(playerid)
  90. {
  91. new name[MAX_PLAYER_NAME];
  92. GetPlayerName(playerid, name, sizeof(name));
  93. new string[128];
  94. format(string, sizeof(string), ACCOUNTS_FOLDER, name);
  95. if (AccountInfo[playerid][aLogged] == 0)
  96. {
  97. if (!fexist(string))
  98. {
  99. new kayitmsg[256];
  100. format(kayitmsg,256,"Welcome to the server\n\n%s please open a new account\n\nEnter the new password:",name);
  101. ShowPlayerDialog(playerid,12345,DIALOG_STYLE_INPUT,"Register",kayitmsg,"Register","Quit");
  102. register[playerid] = 1;
  103. login[playerid] = 0;
  104. }
  105. else if (fexist(string))
  106. {
  107. new girismsg[256];
  108. format(girismsg,256,"Welcome to the server\n\nUser Name: %s\n\nEnter your password:",name);
  109. ShowPlayerDialog(playerid,12346,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
  110. register[playerid] = 0;
  111. login[playerid] = 1;
  112. }
  113. }
  114. return 1;
  115. }
  116.  
  117. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  118. {
  119. new Float:x, Float:y, Float:z, Float:angle, Float:armour, Float:health;
  120. if (response == 1)
  121. {
  122. if(dialogid == 12345)
  123. {
  124. if(strlen(inputtext))
  125. {
  126. Encrypt(inputtext);
  127. new player[MAX_PLAYER_NAME];
  128. GetPlayerName(playerid, player, 50);
  129. new string3[32];
  130. new playername3[MAX_PLAYER_NAME];
  131. GetPlayerName(playerid, playername3, sizeof(playername3));
  132. format(string3, sizeof(string3), ACCOUNTS_FOLDER, playername3);
  133. new ip[20];
  134. GetPlayerIp(playerid,ip,sizeof(ip));
  135. new File: hFile = fopen(string3, io_write);
  136. if (hFile)
  137. {
  138. strmid(AccountInfo[playerid][aPassword], inputtext, 0, strlen(inputtext), 255);
  139. new var[128];
  140. format(var, 128, "Password=%s\n", AccountInfo[playerid][aPassword]);fwrite(hFile, var);
  141. format(var, 128, "IP=%s\n",ip);fwrite(hFile, var);
  142. if(SAVE_MONEY_SCORE_FIGHT_DRUNK == 1)
  143. {
  144. format(var, 128, "Money=%d\n",GetPlayerMoney(playerid));fwrite(hFile, var);
  145. format(var, 128, "Score=%d\n",GetPlayerScore(playerid));fwrite(hFile, var);
  146. format(var, 128, "DrunkLevel=%d\n",GetPlayerDrunkLevel(playerid));fwrite(hFile, var);
  147. format(var, 128, "FightStyle=%d\n",GetPlayerFightingStyle(playerid));fwrite(hFile, var);
  148. }
  149. if(SAVE_POS == 1)
  150. {
  151. GetPlayerPos(playerid, x, y, z);
  152. GetPlayerFacingAngle(playerid, angle);
  153. format(var, 128, "PositionX=%f\n",x);fwrite(hFile, var);
  154. format(var, 128, "PositionY=%f\n",y);fwrite(hFile, var);
  155. format(var, 128, "PositionZ=%f\n",z);fwrite(hFile, var);
  156. format(var, 128, "Angle=%f\n",angle);fwrite(hFile, var);
  157. format(var, 128, "Interior=%d\n",GetPlayerInterior(playerid));fwrite(hFile, var);
  158. }
  159. if(SAVE_ARMOUR == 1)
  160. {
  161. GetPlayerArmour(playerid, armour);
  162. format(var, 128, "Armour=%f\n",armour);fwrite(hFile, var);
  163. }
  164. if(SAVE_HEALTH == 1)
  165. {
  166. GetPlayerHealth(playerid, health);
  167. format(var, 128, "Health=%f\n",health);fwrite(hFile, var);
  168. }
  169. if(SAVE_WEAPON == 1)
  170. {
  171. for(new slot = 0; slot != 12; slot++)
  172. {
  173. GetPlayerWeaponData(playerid, slot, WeaponInfo[playerid][slot], AmmoInfo[playerid][slot]);
  174. }
  175. for(new slot = 0; slot != 12; slot++)
  176. {
  177. format(var, 128, "Weapon%d=%d\n", slot, WeaponInfo[playerid][slot]);fwrite(hFile, var);
  178. format(var, 128, "Weapon%dAmmo=%d\n", slot, AmmoInfo[playerid][slot]);fwrite(hFile, var);
  179. }
  180. format(var, 128, "ArmedWeapon=%d\n",GetPlayerWeapon(playerid));fwrite(hFile, var);
  181. }
  182. fclose(hFile);
  183. printf("%s is signed up.",playername3);
  184. SendClientMessage(playerid, GREEN, "|- Have you registered. You can login now. -|");
  185. new girismsg[256];
  186. format(girismsg,256,"Welcome to the server\n\nUser Name: %s\n\nEnter your password:",playername3);
  187. ShowPlayerDialog(playerid,12346,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
  188. login[playerid] = 1;
  189. register[playerid] = 0;
  190. }
  191. }
  192. else if(!strlen(inputtext))
  193. {
  194. new name[MAX_PLAYER_NAME];
  195. GetPlayerName(playerid, name, sizeof(name));
  196. new kayitmsg[256];
  197. format(kayitmsg,256,"Welcome to the server\n\n%s please open a new account\n\nEnter the new password:",name);
  198. ShowPlayerDialog(playerid,12345,DIALOG_STYLE_INPUT,"Register",kayitmsg,"Register","Quit");
  199. register[playerid] = 1;
  200. login[playerid] = 0;
  201. }
  202. }
  203. if(dialogid == 12346)
  204. {
  205. Encrypt(inputtext);
  206. new string2[128];
  207. new playername2[MAX_PLAYER_NAME];
  208. GetPlayerName(playerid, playername2, sizeof(playername2));
  209. format(string2, sizeof(string2), ACCOUNTS_FOLDER, playername2);
  210. new File: UserFile = fopen(string2, io_read);
  211. if ( UserFile )
  212. {
  213. new PassData[256];
  214. new keytmp[256], valtmp[256];
  215. fread( UserFile , PassData , sizeof( PassData ) );
  216. keytmp = ini_GetKey( PassData );
  217. if( strcmp( keytmp , "Password" , true ) == 0 )
  218. {
  219. valtmp = ini_GetValue( PassData );
  220. strmid(AccountInfo[playerid][aPassword], valtmp, 0, strlen(valtmp)-1, 255);
  221. }
  222. if(strcmp(AccountInfo[playerid][aPassword],inputtext, true ) == 0)
  223. {
  224. if(strlen(inputtext))
  225. {
  226. for(new p = 0; p < strlen(AccountInfo[playerid][aPassword]); p++)
  227. {
  228. inputtext[p] = '?';
  229. }
  230. new key[256] , val[256];
  231. new Data[256];
  232. while ( fread( UserFile , Data , sizeof( Data ) ) )
  233. {
  234. key = ini_GetKey( Data );
  235. if(SAVE_MONEY_SCORE_FIGHT_DRUNK == 1)
  236. {
  237. if( strcmp( key , "Money" , true ) == 0 )
  238. {
  239. val = ini_GetValue( Data );
  240. ResetPlayerMoney(playerid);
  241. GivePlayerMoney(playerid,strval(val));
  242. }
  243. if( strcmp( key , "Score" , true ) == 0 )
  244. {
  245. val = ini_GetValue( Data );
  246. SetPlayerScore(playerid,strval(val));
  247. }
  248. if( strcmp( key , "DrunkLevel" , true ) == 0 )
  249. {
  250. val = ini_GetValue( Data );
  251. SetPlayerDrunkLevel(playerid,strval(val));
  252. }
  253. if( strcmp( key , "FightStyle" , true ) == 0 )
  254. {
  255. val = ini_GetValue( Data );
  256. SetPlayerFightingStyle(playerid,strval(val));
  257. }
  258. }
  259. if(SAVE_POS == 1)
  260. {
  261. if( strcmp( key , "PositionX" , true ) == 0 )
  262. {
  263. val = ini_GetValue( Data );
  264. PositionInfo[playerid][aPosX] = strval(val);
  265. }
  266. if( strcmp( key , "PositionY" , true ) == 0 )
  267. {
  268. val = ini_GetValue( Data );
  269. PositionInfo[playerid][aPosY] = strval(val);
  270. }
  271. if( strcmp( key , "PositionZ" , true ) == 0 )
  272. {
  273. val = ini_GetValue( Data );
  274. PositionInfo[playerid][aPosZ] = strval(val);
  275. }
  276. SetPlayerPos(playerid, PositionInfo[playerid][aPosX], PositionInfo[playerid][aPosY], PositionInfo[playerid][aPosZ]);
  277. if( strcmp( key , "Angle" , true ) == 0 )
  278. {
  279. val = ini_GetValue( Data );
  280. PositionInfo[playerid][aAngle] = strval(val);
  281. }
  282. if( strcmp( key , "Interior" , true ) == 0 )
  283. {
  284. val = ini_GetValue( Data );
  285. SetPlayerInterior(playerid, strval(val));
  286. }
  287. SetPlayerFacingAngle(playerid, PositionInfo[playerid][aAngle]);
  288. }
  289. if(SAVE_HEALTH == 1)
  290. {
  291. if( strcmp( key , "Health" , true ) == 0 )
  292. {
  293. val = ini_GetValue( Data );
  294. SetPlayerHealth(playerid, strval(val));
  295. }
  296. }
  297. if(SAVE_ARMOUR == 1)
  298. {
  299. if( strcmp( key , "Armour" , true ) == 0 )
  300. {
  301. val = ini_GetValue( Data );
  302. SetPlayerArmour(playerid, strval(val));
  303. }
  304. }
  305. if(SAVE_WEAPON == 1)
  306. {
  307. new silah[128];
  308. new mermi[128];
  309. ResetPlayerWeapons(playerid);
  310. for(new slot = 0; slot != 12; slot++)
  311. {
  312. format(silah,sizeof(silah),"Weapon%s",slot);
  313. if( strcmp( key , silah, true ) == 0 )
  314. {
  315. val = ini_GetValue( Data );
  316. strmid(WeaponInfo[playerid][slot], val, 0, strlen(val));
  317. }
  318. }
  319. for(new slot = 0; slot != 12; slot++)
  320. {
  321. format(mermi,sizeof(mermi),"Weapon%sAmmo",slot);
  322. if( strcmp( key , mermi, true ) == 0 )
  323. {
  324. val = ini_GetValue( Data );
  325. strmid(AmmoInfo[playerid][slot], val, 0, strlen(val));
  326. }
  327. }
  328. for(new slot = 0; slot != 12; slot++)
  329. {
  330. GivePlayerWeapon(playerid, WeaponInfo[playerid][slot], AmmoInfo[playerid][slot]);
  331. }
  332. if( strcmp( key , "ArmedWeapon" , true ) == 0 )
  333. {
  334. val = ini_GetValue( Data );
  335. SetPlayerArmedWeapon(playerid, strval(val));
  336. }
  337. }
  338. }
  339. register[playerid] = 0;
  340. login[playerid] = 0;
  341. AccountInfo[playerid][aLogged] = 1;
  342. printf("%s is logged in.",playername2);
  343. fclose(UserFile);
  344. }
  345. }
  346. else
  347. {
  348. if(strlen(inputtext))
  349. {
  350. new girismsg[256];
  351. printf("%s is used the wrong password.",playername2);
  352. format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
  353. ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
  354. login[playerid] = 1;
  355. register[playerid] = 0;
  356. failedlogin[playerid]++;
  357. fclose(UserFile);
  358. return 1;
  359. }
  360. }
  361. if(!strlen(inputtext))
  362. {
  363. new girismsg[256];
  364. printf("%s did not enter the password.",playername2);
  365. format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
  366. ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
  367. login[playerid] = 1;
  368. register[playerid] = 0;
  369. failedlogin[playerid]++;
  370. fclose(UserFile);
  371. return 1;
  372. }
  373. }
  374. }
  375. if(dialogid == 12347)
  376. {
  377. Encrypt(inputtext);
  378. new string2[128];
  379. new playername2[MAX_PLAYER_NAME];
  380. GetPlayerName(playerid, playername2, sizeof(playername2));
  381. format(string2, sizeof(string2), ACCOUNTS_FOLDER, playername2);
  382. new File: UserFile = fopen(string2, io_read);
  383. if ( UserFile )
  384. {
  385. new PassData[256];
  386. new keytmp[256], valtmp[256];
  387. fread( UserFile , PassData , sizeof( PassData ) );
  388. keytmp = ini_GetKey( PassData );
  389. if( strcmp( keytmp , "Password" , true ) == 0 )
  390. {
  391. valtmp = ini_GetValue( PassData );
  392. strmid(AccountInfo[playerid][aPassword], valtmp, 0, strlen(valtmp)-1, 255);
  393. }
  394. if(strcmp(AccountInfo[playerid][aPassword],inputtext, true ) == 0)
  395. {
  396. if(strlen(inputtext))
  397. {
  398. for(new p = 0; p < strlen(AccountInfo[playerid][aPassword]); p++)
  399. {
  400. inputtext[p] = '?';
  401. }
  402. new key[256] , val[256];
  403. new Data[256];
  404. while ( fread( UserFile , Data , sizeof( Data ) ) )
  405. {
  406. key = ini_GetKey( Data );
  407. if(SAVE_MONEY_SCORE_FIGHT_DRUNK == 1)
  408. {
  409. if( strcmp( key , "Money" , true ) == 0 )
  410. {
  411. val = ini_GetValue( Data );
  412. ResetPlayerMoney(playerid);
  413. GivePlayerMoney(playerid,strval(val));
  414. }
  415. if( strcmp( key , "Score" , true ) == 0 )
  416. {
  417. val = ini_GetValue( Data );
  418. SetPlayerScore(playerid,strval(val));
  419. }
  420. if( strcmp( key , "DrunkLevel" , true ) == 0 )
  421. {
  422. val = ini_GetValue( Data );
  423. SetPlayerDrunkLevel(playerid,strval(val));
  424. }
  425. if( strcmp( key , "FightStyle" , true ) == 0 )
  426. {
  427. val = ini_GetValue( Data );
  428. SetPlayerFightingStyle(playerid,strval(val));
  429. }
  430. }
  431. if(SAVE_POS == 1)
  432. {
  433. if( strcmp( key , "PositionX" , true ) == 0 )
  434. {
  435. val = ini_GetValue( Data );
  436. PositionInfo[playerid][aPosX] = strval(val);
  437. }
  438. if( strcmp( key , "PositionY" , true ) == 0 )
  439. {
  440. val = ini_GetValue( Data );
  441. PositionInfo[playerid][aPosY] = strval(val);
  442. }
  443. if( strcmp( key , "PositionZ" , true ) == 0 )
  444. {
  445. val = ini_GetValue( Data );
  446. PositionInfo[playerid][aPosZ] = strval(val);
  447. }
  448. SetPlayerPos(playerid, PositionInfo[playerid][aPosX], PositionInfo[playerid][aPosY], PositionInfo[playerid][aPosZ]);
  449. if( strcmp( key , "Angle" , true ) == 0 )
  450. {
  451. val = ini_GetValue( Data );
  452. PositionInfo[playerid][aAngle] = strval(val);
  453. }
  454. if( strcmp( key , "Interior" , true ) == 0 )
  455. {
  456. val = ini_GetValue( Data );
  457. SetPlayerInterior(playerid, strval(val));
  458. }
  459. SetPlayerFacingAngle(playerid, PositionInfo[playerid][aAngle]);
  460. }
  461. if(SAVE_HEALTH == 1)
  462. {
  463. if( strcmp( key , "Health" , true ) == 0 )
  464. {
  465. val = ini_GetValue( Data );
  466. SetPlayerHealth(playerid, strval(val));
  467. }
  468. }
  469. if(SAVE_ARMOUR == 1)
  470. {
  471. if( strcmp( key , "Armour" , true ) == 0 )
  472. {
  473. val = ini_GetValue( Data );
  474. SetPlayerArmour(playerid, strval(val));
  475. }
  476. }
  477. if(SAVE_WEAPON == 1)
  478. {
  479. new silah[128];
  480. new mermi[128];
  481. ResetPlayerWeapons(playerid);
  482. for(new slot = 0; slot != 12; slot++)
  483. {
  484. format(silah,sizeof(silah),"Weapon%s",slot);
  485. if( strcmp( key , silah, true ) == 0 )
  486. {
  487. val = ini_GetValue( Data );
  488. strmid(WeaponInfo[playerid][slot], val, 0, strlen(val));
  489. }
  490. }
  491. for(new slot = 0; slot != 12; slot++)
  492. {
  493. format(mermi,sizeof(mermi),"Weapon%sAmmo",slot);
  494. if( strcmp( key , mermi, true ) == 0 )
  495. {
  496. val = ini_GetValue( Data );
  497. strmid(AmmoInfo[playerid][slot], val, 0, strlen(val));
  498. }
  499. }
  500. for(new slot = 0; slot != 12; slot++)
  501. {
  502. GivePlayerWeapon(playerid, WeaponInfo[playerid][slot], AmmoInfo[playerid][slot]);
  503. }
  504. if( strcmp( key , "ArmedWeapon" , true ) == 0 )
  505. {
  506. val = ini_GetValue( Data );
  507. SetPlayerArmedWeapon(playerid, strval(val));
  508. }
  509. }
  510. }
  511. register[playerid] = 0;
  512. login[playerid] = 0;
  513. AccountInfo[playerid][aLogged] = 1;
  514. printf("%s is logged in.",playername2);
  515. fclose(UserFile);
  516. }
  517. }
  518. else
  519. {
  520. if(strlen(inputtext))
  521. {
  522. new girismsg[256];
  523. printf("%s is used the wrong password.",playername2);
  524. format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
  525. if(FAILED_LOGIN_THRESHOLD == failedlogin[playerid])
  526. {
  527. Kick(playerid);
  528. }
  529. else
  530. {
  531. ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
  532. login[playerid] = 1;
  533. register[playerid] = 0;
  534. failedlogin[playerid]++;
  535. }
  536. fclose(UserFile);
  537. return 1;
  538. }
  539. }
  540. if(!strlen(inputtext))
  541. {
  542. new girismsg[256];
  543. printf("%s did not enter the password.",playername2);
  544. format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
  545. if(FAILED_LOGIN_THRESHOLD == failedlogin[playerid])
  546. {
  547. Kick(playerid);
  548. }
  549. else
  550. {
  551. ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
  552. login[playerid] = 1;
  553. register[playerid] = 0;
  554. failedlogin[playerid]++;
  555. }
  556. fclose(UserFile);
  557. return 1;
  558. }
  559. }
  560. }
  561. }
  562. else return Kick(playerid);
  563. return 0;
  564. }
  565.  
  566. public OnPlayerDeath(playerid, killerid, reason)
  567. {
  568. return 1;
  569. }
  570.  
  571. public OnVehicleSpawn(vehicleid)
  572. {
  573. return 1;
  574. }
  575.  
  576. public OnVehicleDeath(vehicleid, killerid)
  577. {
  578. return 1;
  579. }
  580.  
  581. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  582. {
  583. return 1;
  584. }
  585.  
  586. public OnPlayerExitVehicle(playerid, vehicleid)
  587. {
  588. return 1;
  589. }
  590.  
  591. public OnPlayerStateChange(playerid, newstate, oldstate)
  592. {
  593. return 1;
  594. }
  595.  
  596. public OnPlayerEnterCheckpoint(playerid)
  597. {
  598. return 1;
  599. }
  600.  
  601. public OnPlayerLeaveCheckpoint(playerid)
  602. {
  603. return 1;
  604. }
  605.  
  606. public OnPlayerEnterRaceCheckpoint(playerid)
  607. {
  608. return 1;
  609. }
  610.  
  611. public OnPlayerLeaveRaceCheckpoint(playerid)
  612. {
  613. return 1;
  614. }
  615.  
  616. public OnRconCommand(cmd[])
  617. {
  618. return 1;
  619. }
  620.  
  621. public OnObjectMoved(objectid)
  622. {
  623. return 1;
  624. }
  625.  
  626. public OnPlayerObjectMoved(playerid, objectid)
  627. {
  628. return 1;
  629. }
  630.  
  631. public OnPlayerCommandText(playerid, cmdtext[])
  632. {
  633. if(IsPlayerAdmin(playerid))
  634. {
  635. if(strcmp(cmdtext, "/savepos", true) == 0)
  636. {
  637. if(SAVE_POS == 0)
  638. {
  639. SendClientMessage(playerid,GREEN,"Automatic position saving enabled!");
  640. SAVE_POS = 1;
  641. }
  642. else if(SAVE_POS == 1)
  643. {
  644. SendClientMessage(playerid,RED,"Automatic position saving disabled!");
  645. SAVE_POS = 0;
  646. }
  647. return 1;
  648. }
  649. if(strcmp(cmdtext, "/savewep", true) == 0)
  650. {
  651. if(SAVE_WEAPON == 0)
  652. {
  653. SendClientMessage(playerid,GREEN,"Automatic weapon saving enabled!");
  654. SAVE_WEAPON = 1;
  655. }
  656. else if(SAVE_WEAPON == 1)
  657. {
  658. SendClientMessage(playerid,RED,"Automatic weapon saving disabled!");
  659. SAVE_WEAPON = 0;
  660. }
  661. return 1;
  662. }
  663. if(strcmp(cmdtext, "/savearmo", true) == 0)
  664. {
  665. if(SAVE_ARMOUR == 0)
  666. {
  667. SendClientMessage(playerid,GREEN,"Automatic armour saving enabled!");
  668. SAVE_ARMOUR = 1;
  669. }
  670. else if(SAVE_ARMOUR == 1)
  671. {
  672. SendClientMessage(playerid,RED,"Automatic armour saving disabled!");
  673. SAVE_ARMOUR = 0;
  674. }
  675. return 1;
  676. }
  677. if(strcmp(cmdtext, "/saveheal", true) == 0)
  678. {
  679. if(SAVE_HEALTH == 0)
  680. {
  681. SendClientMessage(playerid,GREEN,"Automatic health saving enabled!");
  682. SAVE_HEALTH = 1;
  683. }
  684. else if(SAVE_HEALTH == 1)
  685. {
  686. SendClientMessage(playerid,RED,"Automatic health saving disabled!");
  687. SAVE_HEALTH = 0;
  688. }
  689. return 1;
  690. }
  691. }
  692. return 1;
  693. }
  694.  
  695. public OnPlayerPickUpPickup(playerid, pickupid)
  696. {
  697. return 1;
  698. }
  699.  
  700. public OnPlayerSelectedMenuRow(playerid, row)
  701. {
  702. return 1;
  703. }
  704.  
  705. public OnPlayerExitedMenu(playerid)
  706. {
  707. return 1;
  708. }
  709.  
  710. stock ini_GetKey( line[] )
  711. {
  712. new keyRes[256];
  713. keyRes[0] = 0;
  714. if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  715. strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  716. return keyRes;
  717. }
  718.  
  719. stock ini_GetValue( line[] )
  720. {
  721. new valRes[256];
  722. valRes[0]=0;
  723. if ( strfind( line , "=" , true ) == -1 ) return valRes;
  724. strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
  725. return valRes;
  726. }
  727.  
  728. public OnPlayerUpdate(playerid)
  729. {
  730. new Float:x, Float:y, Float:z, Float:angle, Float:armour, Float:health;
  731. if(IsPlayerConnected(playerid))
  732. {
  733. if(AccountInfo[playerid][aLogged] == 1)
  734. {
  735. new string3[128];
  736. new playername3[MAX_PLAYER_NAME];
  737. GetPlayerName(playerid, playername3, sizeof(playername3));
  738. format(string3, sizeof(string3), ACCOUNTS_FOLDER, playername3);
  739. new ip[20];
  740. GetPlayerIp(playerid,ip,sizeof(ip));
  741. new File: hFile = fopen(string3, io_write);
  742. if (hFile)
  743. {
  744. new var[128];
  745. format(var, 128, "Password=%s\n", AccountInfo[playerid][aPassword]);fwrite(hFile, var);
  746. format(var, 128, "IP=%s\n",ip);fwrite(hFile, var);
  747. if(SAVE_MONEY_SCORE_FIGHT_DRUNK == 1)
  748. {
  749. format(var, 128, "Money=%d\n",GetPlayerMoney(playerid));fwrite(hFile, var);
  750. format(var, 128, "Score=%d\n",GetPlayerScore(playerid));fwrite(hFile, var);
  751. format(var, 128, "DrunkLevel=%d\n",GetPlayerDrunkLevel(playerid));fwrite(hFile, var);
  752. format(var, 128, "FightStyle=%d\n",GetPlayerFightingStyle(playerid));fwrite(hFile, var);
  753. }
  754. if(SAVE_POS == 1)
  755. {
  756. GetPlayerPos(playerid, x, y, z);
  757. GetPlayerFacingAngle(playerid, angle);
  758. format(var, 128, "PositionX=%f\n",x);fwrite(hFile, var);
  759. format(var, 128, "PositionY=%f\n",y);fwrite(hFile, var);
  760. format(var, 128, "PositionZ=%f\n",z);fwrite(hFile, var);
  761. format(var, 128, "Angle=%f\n",angle);fwrite(hFile, var);
  762. format(var, 128, "Interior=%d\n",GetPlayerInterior(playerid));fwrite(hFile, var);
  763. }
  764. if(SAVE_ARMOUR == 1)
  765. {
  766. GetPlayerArmour(playerid, armour);
  767. format(var, 128, "Armour=%f\n",armour);fwrite(hFile, var);
  768. }
  769. if(SAVE_HEALTH == 1)
  770. {
  771. GetPlayerHealth(playerid, health);
  772. format(var, 128, "Health=%f\n",health);fwrite(hFile, var);
  773. }
  774. if(SAVE_WEAPON == 1)
  775. {
  776. for(new slot = 0; slot != 12; slot++)
  777. {
  778. GetPlayerWeaponData(playerid, slot, WeaponInfo[playerid][slot], AmmoInfo[playerid][slot]);
  779. }
  780. for(new slot = 0; slot != 12; slot++)
  781. {
  782. format(var, 128, "Weapon%d=%d\n", slot, WeaponInfo[playerid][slot]);fwrite(hFile, var);
  783. format(var, 128, "Weapon%dAmmo=%d\n", slot, AmmoInfo[playerid][slot]);fwrite(hFile, var);
  784. }
  785. format(var, 128, "ArmedWeapon=%d\n",GetPlayerWeapon(playerid));fwrite(hFile, var);
  786. }
  787. fclose(hFile);
  788. }
  789. }
  790. }
  791. return 1;
  792. }
  793.  
  794. Encrypt(string[])
  795. {
  796. for(new x=0; x < strlen(string); x++)
  797. {
  798. string[x] += (3^x) * (x % 15);
  799. if(string[x] > (0xff))
  800. {
  801. string[x] -= 256;
  802. }
  803. }
  804. }
  805.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement