Guest User

Untitled

a guest
Sep 7th, 2009
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.86 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define COLOR_GREY 0xBEBEBEAA
  4. #define COLOR_WHITE 0xFFFFFFAA
  5. #define COLOR_BLUE 0x300FFAAB
  6. #define COLOR_MEDIUMBLUE 0x63AFF00A
  7.  
  8. forward OnPlayerUpdate(playerid);
  9. forward Encrypt(string[]);
  10. forward OnPlayerLogin(playerid,const string[]);
  11.  
  12. enum pInfo
  13. {
  14. pPassword[128],
  15. pCash,
  16. pRank,
  17. pJob,
  18. pAdmin,
  19. };
  20.  
  21. new PlayerInfo[MAX_PLAYERS][pInfo];
  22. new gPlayerLogged[MAX_PLAYERS];
  23. new gPlayerAccount[MAX_PLAYERS];
  24.  
  25. main()
  26. {
  27. print("\n----------------------------------");
  28. print(" Saints Roleplay by FreddeN");
  29. print("----------------------------------\n");
  30. }
  31.  
  32. public OnGameModeInit()
  33. {
  34. SetGameModeText("Saints Roleplay 0.1 Beta");
  35.  
  36. AddPlayerClassEx(1,280,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
  37. AddPlayerClassEx(1,281,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
  38. AddPlayerClassEx(1,284,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
  39. AddPlayerClassEx(1,283,610.8701,-585.9324,17.2266,184.1333,3,1,41,600,24,600);
  40. AddPlayerClassEx(1,288,610.8701,-585.9324,17.2266,184.1333,3,1,41,600,24,600);
  41. AddPlayerClassEx(1,282,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
  42. AddPlayerClassEx(1,265,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
  43. AddPlayerClassEx(1,267,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
  44. AddPlayerClassEx(1,286,1512.8138,-1460.1007,9.5000,180.3513,1,1,23,600,0,0);
  45. AddPlayerClassEx(1,163,1512.8138,-1460.1007,9.5000,180.3513,1,1,23,600,0,0);
  46. AddPlayerClassEx(1,164,1512.8138,-1460.1007,9.5000,180.3513,1,1,23,600,0,0);
  47. AddPlayerClassEx(1,147,1512.8138,-1460.1007,9.5000,180.3513,1,1,23,600,0,0);
  48. AddPlayerClassEx(1,71,1527.8987,-1677.8359,5.8906,269.2473,3,1,24,600,0,0);
  49.  
  50. AddStaticVehicleEx(596,1600.7450,-1684.1527,5.6119,90.0628,0,1,3600); // LSPD Car
  51. AddStaticVehicleEx(596,1601.2915,-1687.9362,5.6123,89.2274,0,1,3600); // LSPD Car
  52. AddStaticVehicleEx(596,1600.8694,-1691.9482,5.6122,89.3799,0,1,3600); // LSPD Car
  53. AddStaticVehicleEx(596,1600.8496,-1695.9462,5.6124,88.7060,0,1,3600); // LSPD Car
  54. AddStaticVehicleEx(596,1601.3756,-1704.1774,5.6122,89.6655,0,1,3600); // LSPD Car
  55. AddStaticVehicleEx(596,1595.6819,-1709.8339,5.6123,358.6504,0,1,3600); // LSPD Car
  56. AddStaticVehicleEx(596,1587.4158,-1710.1013,5.6123,359.4464,0,1,3600); // LSPD Car
  57. AddStaticVehicleEx(596,1583.4688,-1709.8881,5.6120,359.1869,0,1,3600); // LSPD Car
  58. AddStaticVehicleEx(596,1578.8707,-1709.8186,5.6118,359.2487,0,1,3600); // LSPD Car
  59. AddStaticVehicleEx(596,1570.5143,-1710.5320,5.6118,0.2044,0,1,3600); // LSPD Car
  60. AddStaticVehicleEx(596,1545.0204,-1684.4034,5.6121,89.1754,0,1,3600); // LSPD Car
  61. AddStaticVehicleEx(596,1544.5200,-1680.3934,5.6119,88.9024,0,1,3600); // LSPD Car
  62. AddStaticVehicleEx(596,1544.9509,-1663.1245,5.6123,87.8911,0,1,3600); // LSPD Car
  63. AddStaticVehicleEx(601,1564.9312,-1710.0203,5.6493,359.2724,1,1,3600); // LSPD Car
  64. AddStaticVehicleEx(427,1526.4474,-1645.8596,6.0224,178.7030,0,1,3600); // LSPD Car
  65. AddStaticVehicleEx(427,1530.6548,-1645.5239,6.0225,179.1615,0,1,3600); // LSPD Car
  66. AddStaticVehicleEx(523,1559.6531,-1695.8699,5.4701,139.9993,0,0,3600); // LSPD Car
  67. AddStaticVehicleEx(523,1562.0741,-1695.6327,5.4611,134.2440,0,0,3600); // LSPD Car
  68. AddStaticVehicleEx(523,1564.3621,-1695.4502,5.4618,133.7394,0,0,3600); // LSPD Car
  69. AddStaticVehicleEx(523,1566.4624,-1695.6405,5.4581,135.6852,0,0,3600); // LSPD Car
  70. return 1;
  71. }
  72.  
  73. public OnGameModeExit()
  74. {
  75. return 1;
  76. }
  77.  
  78. public OnPlayerRequestClass(playerid, classid)
  79. {
  80. PlayerPlaySound(playerid,1185,0,0,0);
  81.  
  82. switch(classid)
  83. {
  84. case 0:
  85. {
  86. GameTextForPlayer(playerid, "Police Officers", 3000, 5);
  87. {
  88. SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
  89. SetPlayerFacingAngle(playerid, 90.3791);
  90. SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
  91. SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
  92. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  93. SetPlayerColor(playerid, COLOR_BLUE);
  94. }
  95. }
  96. case 1:
  97. {
  98. GameTextForPlayer(playerid, "Police Officers", 3000, 5);
  99. {
  100. SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
  101. SetPlayerFacingAngle(playerid, 90.3791);
  102. SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
  103. SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
  104. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  105. SetPlayerColor(playerid, COLOR_BLUE);
  106. }
  107. }
  108. case 2:
  109. {
  110. GameTextForPlayer(playerid, "Police Officers", 3000, 5);
  111. {
  112. SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
  113. SetPlayerFacingAngle(playerid, 90.3791);
  114. SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
  115. SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
  116. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  117. SetPlayerColor(playerid, COLOR_BLUE);
  118. }
  119. }
  120. case 3:
  121. {
  122. GameTextForPlayer(playerid, "Police Officers", 3000, 5);
  123. {
  124. SetPlayerPos(playerid, 630.8762,-571.8481,16.3359);
  125. SetPlayerFacingAngle(playerid, 270.4885);
  126. SetPlayerCameraPos(playerid, 635.6525,-571.8395,16.3359);
  127. SetPlayerCameraLookAt(playerid, 630.8762,-571.8481,16.3359);
  128. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  129. SetPlayerColor(playerid, COLOR_BLUE);
  130. }
  131. }
  132. case 4:
  133. {
  134. GameTextForPlayer(playerid, "~r~Sheriff~n~~w~None", 3000, 5);
  135. {
  136. SetPlayerPos(playerid, 630.8762,-571.8481,16.3359);
  137. SetPlayerFacingAngle(playerid, 270.4885);
  138. SetPlayerCameraPos(playerid, 635.6525,-571.8395,16.3359);
  139. SetPlayerCameraLookAt(playerid, 630.8762,-571.8481,16.3359);
  140. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  141. SetPlayerColor(playerid, COLOR_BLUE);
  142. }
  143. }
  144. case 5:
  145. {
  146. GameTextForPlayer(playerid, "~r~Undersheriff~n~~w~None", 3000, 5);
  147. {
  148. SetPlayerPos(playerid, 630.8762,-571.8481,16.3359);
  149. SetPlayerFacingAngle(playerid, 270.4885);
  150. SetPlayerCameraPos(playerid, 635.6525,-571.8395,16.3359);
  151. SetPlayerCameraLookAt(playerid, 630.8762,-571.8481,16.3359);
  152. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  153. SetPlayerColor(playerid, COLOR_BLUE);
  154. }
  155. }
  156. case 6:
  157. {
  158. GameTextForPlayer(playerid, "~r~Chief of Police~n~~w~FreddeN", 3000, 5);
  159. {
  160. SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
  161. SetPlayerFacingAngle(playerid, 90.3791);
  162. SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
  163. SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
  164. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  165. SetPlayerColor(playerid, COLOR_BLUE);
  166. }
  167. }
  168. case 7:
  169. {
  170. GameTextForPlayer(playerid, "~r~Assistant Chief~n~~w~Dre", 3000, 5);
  171. {
  172. SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
  173. SetPlayerFacingAngle(playerid, 90.3791);
  174. SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
  175. SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
  176. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  177. SetPlayerColor(playerid, COLOR_BLUE);
  178. }
  179. }
  180. case 8:
  181. {
  182. GameTextForPlayer(playerid, "FBI Agents", 3000, 5);
  183. {
  184. SetPlayerPos(playerid, 1518.9713,-1449.9578,13.5469);
  185. SetPlayerFacingAngle(playerid, 0.3747);
  186. SetPlayerCameraPos(playerid, 1518.9800,-1445.4089,13.3828);
  187. SetPlayerCameraLookAt(playerid, 1518.9713,-1449.9578,13.5469);
  188. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  189. SetPlayerColor(playerid, COLOR_BLUE);
  190. }
  191. }
  192. case 9:
  193. {
  194. GameTextForPlayer(playerid, "FBI Agents", 3000, 5);
  195. {
  196. SetPlayerPos(playerid, 1518.9713,-1449.9578,13.5469);
  197. SetPlayerFacingAngle(playerid, 0.3747);
  198. SetPlayerCameraPos(playerid, 1518.9800,-1445.4089,13.3828);
  199. SetPlayerCameraLookAt(playerid, 1518.9713,-1449.9578,13.5469);
  200. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  201. SetPlayerColor(playerid, COLOR_BLUE);
  202. }
  203. }
  204. case 10:
  205. {
  206. GameTextForPlayer(playerid, "FBI Agents", 3000, 5);
  207. {
  208. SetPlayerPos(playerid, 1518.9713,-1449.9578,13.5469);
  209. SetPlayerFacingAngle(playerid, 0.3747);
  210. SetPlayerCameraPos(playerid, 1518.9800,-1445.4089,13.3828);
  211. SetPlayerCameraLookAt(playerid, 1518.9713,-1449.9578,13.5469);
  212. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  213. SetPlayerColor(playerid, COLOR_BLUE);
  214. }
  215. }
  216. case 11:
  217. {
  218. GameTextForPlayer(playerid, "~r~Director~n~~w~None", 3000, 5);
  219. {
  220. SetPlayerPos(playerid, 1518.9713,-1449.9578,13.5469);
  221. SetPlayerFacingAngle(playerid, 0.3747);
  222. SetPlayerCameraPos(playerid, 1518.9800,-1445.4089,13.3828);
  223. SetPlayerCameraLookAt(playerid, 1518.9713,-1449.9578,13.5469);
  224. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  225. SetPlayerColor(playerid, COLOR_BLUE);
  226. }
  227. }
  228. case 12:
  229. {
  230. GameTextForPlayer(playerid, "Laws and Enforcements Cadets", 3000, 5);
  231. {
  232. SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
  233. SetPlayerFacingAngle(playerid, 90.3791);
  234. SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
  235. SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
  236. ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
  237. SetPlayerColor(playerid, COLOR_MEDIUMBLUE);
  238. }
  239. }
  240. }
  241. return 1;
  242. }
  243.  
  244. public OnPlayerRequestSpawn(playerid)
  245. {
  246. return 1;
  247. }
  248.  
  249. public OnPlayerConnect(playerid)
  250. {
  251. SendClientMessage(playerid, COLOR_GREY, "Welcome to Saints Roleplay");
  252. SendClientMessage(playerid, COLOR_GREY, "Saints Roleplay 0.1 Beta");
  253.  
  254. new pName[MAX_PLAYER_NAME];
  255. new string[48];
  256. GetPlayerName(playerid, pName, sizeof(pName));
  257. format(string, sizeof(string), "%s has joined the server. (Joined)", pName);
  258. SendClientMessageToAll(COLOR_GREY, string);
  259.  
  260. SendClientMessage(playerid, COLOR_WHITE, "Please register with /register <password> or login with /login <password>");
  261.  
  262. return 1;
  263. }
  264.  
  265. public OnPlayerDisconnect(playerid, reason)
  266. {
  267. new pName[MAX_PLAYER_NAME], string[56];
  268. GetPlayerName(playerid, pName, sizeof(pName));
  269. switch(reason)
  270. {
  271. case 0: format(string, sizeof(string), "%s has left the server. (Timed Out)", pName);
  272. case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pName);
  273. case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pName);
  274. }
  275. SendClientMessageToAll(COLOR_GREY, string);
  276.  
  277. OnPlayerUpdate(playerid);
  278. gPlayerLogged[playerid] = 0;
  279. return 1;
  280. }
  281.  
  282. public OnPlayerSpawn(playerid)
  283. {
  284. PlayerPlaySound(playerid,1186,0,0,0);
  285. return 1;
  286. }
  287.  
  288. public OnPlayerDeath(playerid, killerid, reason)
  289. {
  290. return 1;
  291. }
  292.  
  293. public OnVehicleSpawn(vehicleid)
  294. {
  295. return 1;
  296. }
  297.  
  298. public OnVehicleDeath(vehicleid, killerid)
  299. {
  300. return 1;
  301. }
  302.  
  303. public OnPlayerText(playerid, text[])
  304. {
  305. return 1;
  306. }
  307.  
  308. public OnPlayerPrivmsg(playerid, recieverid, text[])
  309. {
  310. return 1;
  311. }
  312.  
  313. public OnPlayerCommandText(playerid, cmdtext[])
  314. {
  315. new cmd[256];
  316. new idx;
  317. cmd = strtok(cmdtext, idx);
  318. new tmp[256];
  319. new playername[MAX_PLAYER_NAME];
  320.  
  321. if (strcmp(cmd, "/kill", true) ==0 )
  322. {
  323. SetPlayerHealth(playerid, 0.0);
  324. }
  325.  
  326. if (strcmp(cmd, "/login", true) ==0 )
  327. {
  328. if(IsPlayerConnected(playerid))
  329. {
  330. new tmppass[64];
  331. if(gPlayerLogged[playerid] == 1)
  332. {
  333. SendClientMessage(playerid, COLOR_GREY, " You are already logged in.");
  334. return 1;
  335. }
  336. tmp = strtok(cmdtext, idx);
  337. if(!strlen(tmp))
  338. {
  339. SendClientMessage(playerid, COLOR_GREY, " USAGE: /login <password>");
  340. return 1;
  341. }
  342. strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
  343. Encrypt(tmppass);
  344. OnPlayerLogin(playerid,tmppass);
  345. }
  346. return 1;
  347. }
  348.  
  349. if (strcmp(cmd, "/register", true)==0)
  350. {
  351. new string[265];
  352. tmp = strtok(cmdtext, idx);
  353. if(!strlen(tmp))
  354. {
  355. SendClientMessage(playerid, COLOR_GREY, "USAGE: /register <password>");
  356. return 1;
  357. }
  358. if (gPlayerAccount[playerid] == 1)
  359. {
  360. SendClientMessage(playerid, COLOR_GREY, " That name is already registered");
  361. return 1;
  362. }
  363.  
  364. strmid(PlayerInfo[playerid][pPassword], tmp, 0, strlen(cmdtext), 255);
  365. Encrypt(PlayerInfo[playerid][pPassword]);
  366. GetPlayerName(playerid, playername, sizeof(playername));
  367. format(string, sizeof(string), "%s.cer", playername);
  368. new File: file = fopen(string, io_read);
  369. if (file)
  370. {
  371. SendClientMessage(playerid, COLOR_GREY, " That name is already registered");
  372. fclose(file);
  373. return 1;
  374. }
  375. new File:hFile;
  376. hFile = fopen(string, io_append);
  377. new var[32];//
  378. format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var);
  379. PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
  380. format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
  381. format(var, 32, "Rank=%d\n",PlayerInfo[playerid][pRank]);fwrite(hFile, var);
  382. format(var, 32, "Job=%d\n",PlayerInfo[playerid][pJob]);fwrite(hFile, var);
  383. format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
  384. fclose(hFile);
  385. SendClientMessage(playerid, COLOR_WHITE, "Succesfully Registered!");
  386. SendClientMessage(playerid, COLOR_WHITE, "Next time you connect, type /login <password> to log in.");
  387. OnPlayerLogin(playerid,PlayerInfo[playerid][pPassword]);
  388. return 1;
  389. }
  390.  
  391. if (strcmp(cmd, "/onduty", true) ==0 )
  392. {
  393. new str[256], pname[256];
  394. if(PlayerInfo[playerid][pRank] < 1) return SendClientMessage(playerid,0xFF0000FF, "Identification Error - You need LAE Rank 1 to do this.");
  395. if(GetPlayerTeam(playerid) != 1) return SendClientMessage(playerid,0xFF0000FF, "Identification Error - You are not a Police Officer.");
  396. GetPlayerName(playerid, pname, 256);
  397. format(str, 256, "Officer %s Is now on duty!", pname, cmdtext[7]);
  398. SendClientMessageToAll(COLOR_BLUE, str);
  399. return 1;
  400. }
  401. return 0;
  402. }
  403.  
  404. public OnPlayerInfoChange(playerid)
  405. {
  406. return 1;
  407. }
  408.  
  409. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  410. {
  411. return 1;
  412. }
  413.  
  414. public OnPlayerExitVehicle(playerid, vehicleid)
  415. {
  416. return 1;
  417. }
  418.  
  419. public OnPlayerStateChange(playerid, newstate, oldstate)
  420. {
  421. return 1;
  422. }
  423.  
  424. public OnPlayerEnterCheckpoint(playerid)
  425. {
  426. return 1;
  427. }
  428.  
  429. public OnPlayerLeaveCheckpoint(playerid)
  430. {
  431. return 1;
  432. }
  433.  
  434. public OnPlayerEnterRaceCheckpoint(playerid)
  435. {
  436. return 1;
  437. }
  438.  
  439. public OnPlayerLeaveRaceCheckpoint(playerid)
  440. {
  441. return 1;
  442. }
  443.  
  444. public OnRconCommand(cmd[])
  445. {
  446. return 1;
  447. }
  448.  
  449. public OnObjectMoved(objectid)
  450. {
  451. return 1;
  452. }
  453.  
  454. public OnPlayerObjectMoved(playerid, objectid)
  455. {
  456. return 1;
  457. }
  458.  
  459. public OnPlayerPickUpPickup(playerid, pickupid)
  460. {
  461. return 1;
  462. }
  463.  
  464. public OnPlayerSelectedMenuRow(playerid, row)
  465. {
  466. return 1;
  467. }
  468.  
  469. public OnPlayerExitedMenu(playerid)
  470. {
  471. return 1;
  472. }
  473.  
  474. public Encrypt(string[])
  475. {
  476. for(new x=0; x < strlen(string); x++)
  477. {
  478. string[x] += (3^x) * (x % 15);
  479. if(string[x] > (0xff))
  480. {
  481. string[x] -= 64;
  482. }
  483. }
  484. return 1;
  485. }
  486.  
  487.  
  488. public OnPlayerLogin(playerid,const string[])
  489. {
  490. new pname2[MAX_PLAYER_NAME];
  491. new pname3[MAX_PLAYER_NAME];
  492. new string2[64];
  493. new string3[128];
  494. GetPlayerName(playerid, pname2, sizeof(pname2));
  495. format(string2, sizeof(string2), "%s.cer", pname2);
  496. new File: UserFile = fopen(string2, io_read);
  497.  
  498. if (UserFile)
  499. {
  500. new valtmp[128];
  501. fread(UserFile, valtmp);strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);
  502.  
  503. if ((strcmp(PlayerInfo[playerid][pPassword], string, true, strlen(valtmp)-1) == 0))
  504. {
  505. new key[128],val[128];
  506. new Data[128];
  507. while(fread(UserFile,Data,sizeof(Data)))
  508. {
  509. key = ini_GetKey(Data);
  510. if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
  511. if( strcmp( key , "Rank" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pRank] = strval( val ); }
  512. if( strcmp( key , "Job" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pJob] = strval( val ); }
  513. if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdmin] = strval( val ); }
  514. GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
  515. }
  516. fclose(UserFile);
  517. gPlayerLogged[playerid] = 1;
  518. gPlayerAccount[playerid] = 1;
  519. GetPlayerName(playerid, pname3, sizeof(pname3));
  520. format(string3, sizeof(string3), "Welcome %s, you have been succesfully logged in!", pname3);
  521. SendClientMessage(playerid, COLOR_WHITE,string3);
  522. }
  523. else
  524. {
  525. SendClientMessage(playerid, COLOR_GREY, " Password does not match your name");
  526. fclose(UserFile);
  527. }
  528. }
  529. return 1;
  530. }
  531.  
  532. public OnPlayerUpdate(playerid)
  533. {
  534. if(IsPlayerConnected(playerid))
  535. {
  536. if(gPlayerLogged[playerid])
  537. {
  538. new string3[32];
  539. new pname3[MAX_PLAYER_NAME];
  540. GetPlayerName(playerid, pname3, sizeof(pname3));
  541. format(string3, sizeof(string3), "%s.cer", pname3);
  542. new File: pFile = fopen(string3, io_write);
  543. if (pFile)
  544. {
  545. new var[32];
  546. format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(pFile, var);
  547. fclose(pFile);
  548. new File: hFile = fopen(string3, io_append);
  549. PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
  550. format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
  551. format(var, 32, "Rank=%d\n",PlayerInfo[playerid][pRank]);fwrite(hFile, var);
  552. format(var, 32, "Job=%d\n",PlayerInfo[playerid][pJob]);fwrite(hFile, var);
  553. format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
  554. fclose(hFile);
  555. }
  556. }
  557. }
  558. return 1;
  559. }
  560.  
  561. stock ini_GetKey( line[] )
  562. {
  563. new keyRes[128];
  564. keyRes[0] = 0;
  565. if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  566. strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  567. return keyRes;
  568. }
  569.  
  570. stock ini_GetValue( line[] )
  571. {
  572. new valRes[128];
  573. valRes[0]=0;
  574. if ( strfind( line , "=" , true ) == -1 ) return valRes;
  575. strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
  576. return valRes;
  577. }
  578.  
  579.  
  580. strtok(const string[], &index)
  581. {
  582. new length = strlen(string);
  583. while ((index < length) && (string[index] <= ' '))
  584. {
  585. index++;
  586. }
  587.  
  588. new offset = index;
  589. new result[20];
  590. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  591. {
  592. result[index - offset] = string[index];
  593. index++;
  594. }
  595. result[index - offset] = EOS;
  596. return result;
  597. }
Advertisement
Add Comment
Please, Sign In to add comment