Guest User

Untitled

a guest
Apr 2nd, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.10 KB | None | 0 0
  1. #include <a_samp>
  2. #include <Dini>
  3. #include <dutils>
  4.  
  5. #pragma unused ret_memcpy
  6. #undef MAX_PLAYERS
  7. #define MAX_PLAYERS 32
  8.  
  9. #define COLOR_WHITE 0xFFFFFFAA
  10. #define COLOR_YELLOW 0xFFFFF00AA
  11. #define COLOR_RED 0x660000AA
  12. #define COLOR_PINK 0xFF66FFAA
  13. #define COLOR_LIGHTBLUE 0x33CCFFAA
  14. #define COLOR_DARKRED 0x660000AA
  15. #define COLOR_GREY 0xAFAFAFAA
  16. #define COLOR_ERROR 0xD2691EAA
  17. #define COLOR_ORANGE 0xFF9900AA
  18. #define COLOR_PINK1 0xEC13COFF
  19. #define COLOR_GREEN 0x7CFC00AA
  20.  
  21.  
  22. #define DIALOG_REGISTER 100
  23. #define DIALOG_LOGIN 101
  24.  
  25. enum PlayerInfo
  26. {
  27. Username[MAX_PLAYER_NAME],
  28. Password[32],
  29. RegisterIP[17],
  30. LastIP[17],
  31. Cash,
  32. Bank,
  33. Level,
  34. EXP,
  35. Admin,
  36. AdminLevel,
  37. Job,
  38. JobRank,
  39. Faction,
  40. FactionRank
  41.  
  42. }
  43. new pData[MAX_PLAYERS][PlayerInfo];
  44. new Logged[MAX_PLAYERS];
  45.  
  46. forward ScoreUpdate();
  47. public ScoreUpdate()
  48. {
  49. new Score;
  50. new name[MAX_PLAYER_NAME];
  51. //new string[256];
  52. for(new i=0; i<MAX_PLAYERS; i++)
  53. {
  54. if (IsPlayerConnected(i))
  55. {
  56. GetPlayerName(i, name, sizeof(name));
  57. Score = pData[i][Level];
  58. SetPlayerScore(i, Score);
  59. }
  60. }
  61. }
  62. main()
  63. {
  64. printf("Mod Loaded.");
  65. }
  66.  
  67. public OnGameModeInit()
  68. {
  69. SetTimer("ScoreUpdate", 1000, 1);
  70. SetGameModeText("BETA");
  71.  
  72. return 1;
  73. }
  74.  
  75. public OnGameModeExit()
  76. {
  77. return 1;
  78. }
  79.  
  80. public OnPlayerRequestClass(playerid, classid)
  81. {
  82. return 1;
  83. }
  84.  
  85. public OnPlayerConnect(playerid)
  86. {
  87. new string[158], string1[50];
  88. if(!dini_Exists(GetPlayerFile(playerid)))
  89. {
  90. format(string, sizeof(string), "Welcome to {0000FF}BETA %s{a9c4e4}, Your username didn't found in our database.\nType your {FF0000}password{a9c4e4}, for login in the next times.", GetName(playerid));
  91. format(string1, sizeof(string1), "Register - {0000FF}%s", GetName(playerid));
  92. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, string1, string, "Register", "Cancel");
  93. }
  94. else
  95. {
  96. format(string, sizeof(string), "Welcome back {0000FF}%s{a9c4e4}, to {0000FF}BETA.\n{a9c4e4}Enter your {FF0000}password {a9c4e4}below to login.", GetName(playerid));
  97. format(string1, sizeof(string1), "Login - {0000FF}%s", GetName(playerid));
  98. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Cancel");
  99. }
  100. return 1;
  101. }
  102.  
  103. public OnPlayerDisconnect(playerid, reason)
  104. {
  105. if(Logged[playerid] == 1)
  106. {
  107. dini_Set(GetPlayerFile(playerid), "LastIP", GetIP(playerid));
  108. dini_IntSet(GetPlayerFile(playerid), "Cash", pData[playerid][Cash]);
  109. dini_IntSet(GetPlayerFile(playerid), "Bank", pData[playerid][Bank]);
  110. dini_IntSet(GetPlayerFile(playerid), "Level", pData[playerid][Level]);
  111. dini_IntSet(GetPlayerFile(playerid), "EXP", pData[playerid][EXP]);
  112. dini_IntSet(GetPlayerFile(playerid), "Admin", pData[playerid][Admin]);
  113. dini_IntSet(GetPlayerFile(playerid), "AdminLevel", pData[playerid][AdminLevel]);
  114. dini_IntSet(GetPlayerFile(playerid), "Job", pData[playerid][Job]);
  115. dini_IntSet(GetPlayerFile(playerid), "JobRank", pData[playerid][JobRank]);
  116. dini_IntSet(GetPlayerFile(playerid), "Faction", pData[playerid][Faction]);
  117. dini_IntSet(GetPlayerFile(playerid), "FactionRank", pData[playerid][FactionRank]);
  118. }
  119. return 1;
  120. }
  121.  
  122. public OnPlayerSpawn(playerid)
  123. {
  124. return 1;
  125. }
  126.  
  127. public OnPlayerDeath(playerid, killerid, reason)
  128. {
  129. return 1;
  130. }
  131.  
  132. public OnVehicleSpawn(vehicleid)
  133. {
  134. return 1;
  135. }
  136.  
  137. public OnVehicleDeath(vehicleid, killerid)
  138. {
  139. return 1;
  140. }
  141.  
  142. public OnPlayerText(playerid, text[])
  143. {
  144. if(Logged[playerid] == 1)
  145. {
  146. new string[256];
  147. format(string, sizeof(string), "%s says: %s", UnderlineRemove(playerid), text);
  148. }
  149. return 1;
  150. }
  151.  
  152. public OnPlayerCommandText(playerid, cmdtext[])
  153. {
  154. return 1;
  155. }
  156.  
  157. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  158. {
  159. return 1;
  160. }
  161.  
  162. public OnPlayerExitVehicle(playerid, vehicleid)
  163. {
  164. return 1;
  165. }
  166.  
  167. public OnPlayerStateChange(playerid, newstate, oldstate)
  168. {
  169. return 1;
  170. }
  171.  
  172. public OnPlayerEnterCheckpoint(playerid)
  173. {
  174. return 1;
  175. }
  176.  
  177. public OnPlayerLeaveCheckpoint(playerid)
  178. {
  179. return 1;
  180. }
  181.  
  182. public OnPlayerEnterRaceCheckpoint(playerid)
  183. {
  184. return 1;
  185. }
  186.  
  187. public OnPlayerLeaveRaceCheckpoint(playerid)
  188. {
  189. return 1;
  190. }
  191.  
  192. public OnRconCommand(cmd[])
  193. {
  194. return 1;
  195. }
  196.  
  197. public OnPlayerRequestSpawn(playerid)
  198. {
  199. return 1;
  200. }
  201.  
  202. public OnObjectMoved(objectid)
  203. {
  204. return 1;
  205. }
  206.  
  207. public OnPlayerObjectMoved(playerid, objectid)
  208. {
  209. return 1;
  210. }
  211.  
  212. public OnPlayerPickUpPickup(playerid, pickupid)
  213. {
  214. return 1;
  215. }
  216.  
  217. public OnVehicleMod(playerid, vehicleid, componentid)
  218. {
  219. return 1;
  220. }
  221.  
  222. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  223. {
  224. return 1;
  225. }
  226.  
  227. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  228. {
  229. return 1;
  230. }
  231.  
  232. public OnPlayerSelectedMenuRow(playerid, row)
  233. {
  234. return 1;
  235. }
  236.  
  237. public OnPlayerExitedMenu(playerid)
  238. {
  239. return 1;
  240. }
  241.  
  242. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  243. {
  244. return 1;
  245. }
  246.  
  247. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  248. {
  249. return 1;
  250. }
  251.  
  252. public OnRconLoginAttempt(ip[], password[], success)
  253. {
  254. return 1;
  255. }
  256.  
  257. public OnPlayerUpdate(playerid)
  258. {
  259. for(new i; i > MAX_PLAYERS; i++)
  260. {
  261. SetPlayerMarkerForPlayer(i,playerid,0xFFFFFF00);
  262. }
  263. return 1;
  264. }
  265.  
  266. public OnPlayerStreamIn(playerid, forplayerid)
  267. {
  268. return 1;
  269. }
  270.  
  271. public OnPlayerStreamOut(playerid, forplayerid)
  272. {
  273. return 1;
  274. }
  275.  
  276. public OnVehicleStreamIn(vehicleid, forplayerid)
  277. {
  278. return 1;
  279. }
  280.  
  281. public OnVehicleStreamOut(vehicleid, forplayerid)
  282. {
  283. return 1;
  284. }
  285.  
  286. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  287. {
  288. new string[180], string1[50];
  289. if(dialogid == DIALOG_REGISTER)
  290. {
  291. if(response)
  292. {
  293. if(strlen(inputtext) < 4 || strlen(inputtext) > 32)
  294. {
  295. format(string, sizeof(string), "Welcome to {0000FF}BETA %s{a9c4e4}, Your username didn't found in our database.\nType your {FF0000}password{a9c4e4}, for login in the next times.\n{FF0000}ERROR: Invaild Password", GetName(playerid));
  296. format(string1, sizeof(string1), "Register - {0000FF}%s", GetName(playerid));
  297. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, string1, string, "Register", "Cancel");
  298. return 0;
  299. }
  300. format(string, sizeof(string), "Users/%s.ini", GetName(playerid));
  301. dini_Create(string);
  302. dini_Set(GetPlayerFile(playerid), "Username", GetName(playerid));
  303. dini_Set(GetPlayerFile(playerid), "Password", hash(inputtext));
  304. dini_Set(GetPlayerFile(playerid), "RegisterIP", GetIP(playerid));
  305. dini_Set(GetPlayerFile(playerid), "LastIP", GetIP(playerid));
  306. dini_IntSet(GetPlayerFile(playerid), "Level", 1);
  307. dini_IntSet(GetPlayerFile(playerid), "EXP", 0);
  308. dini_IntSet(GetPlayerFile(playerid), "Admin", 0);
  309. dini_IntSet(GetPlayerFile(playerid), "AdminLevel", 0);
  310. dini_Set(GetPlayerFile(playerid), "Job", "0");
  311. dini_Set(GetPlayerFile(playerid), "JobRank", "0");
  312. dini_Set(GetPlayerFile(playerid), "Faction", "0");
  313. dini_Set(GetPlayerFile(playerid), "FactionRank", "0");
  314. format(string, sizeof(string), "Congratulations {0000FF}%s{a9c4e4}, You have been registered successfully.\ntype your {FF0000}password {a9c4e4}again to login.");
  315. format(string1, sizeof(string1), "Login - {0000FF}%s", GetName(playerid));
  316. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, string1, string, "Login", "Cancel");
  317. return 1;
  318. }
  319. }
  320. else if(dialogid == DIALOG_LOGIN)
  321. {
  322. if(!response) return Kick(playerid);
  323. if(strlen(inputtext) < 4 || strlen(inputtext) > 32)
  324. {
  325. format(string, sizeof(string), "Welcome back {0000FF}%s{a9c4e4}, to {0000FF}BETA.\n{a9c4e4}Enter your {FF0000}password {a9c4e4}below to login.\n{FF0000}ERROR: Type password between 4-32 characters", GetName(playerid));
  326. format(string1, sizeof(string1), "Login - {0000FF}%s", GetName(playerid));
  327. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, string1, string, "Login", "Cancel");
  328. format(string, sizeof(string), "%s[Server:]{FF0000}Type Password between 4-32 characters!", COLOR_WHITE);
  329. SendClientMessage(playerid, COLOR_RED, string);
  330. return 0;
  331. }
  332. else if(strcmp(hash(inputtext), dini_Get(GetPlayerFile(playerid), "Password"), true))
  333. {
  334. format(string, sizeof(string), "Welcome back {0000FF}%s{a9c4e4}, to {0000FF}BETA.\n{a9c4e4}Enter your {FF0000}password {a9c4e4}below to login.\n{FF0000}ERROR: Invalid Password!", GetName(playerid));
  335. format(string1, sizeof(string1), "Login - {0000FF}%s", GetName(playerid));
  336. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, string1, string, "Login", "Cancel");
  337. format(string, sizeof(string), "%s[Server:]{FF0000}Invalid Password!", COLOR_WHITE);
  338. SendClientMessage(playerid, COLOR_RED, string);
  339. return 0;
  340. } else {
  341. pData[playerid][Cash] = dini_Int(GetPlayerFile(playerid), "Money");
  342. pData[playerid][Bank] = dini_Int(GetPlayerFile(playerid), "Bank");
  343. pData[playerid][Level] = dini_Int(GetPlayerFile(playerid), "Level");
  344. pData[playerid][EXP] = dini_Int(GetPlayerFile(playerid), "EXP");
  345. pData[playerid][Admin] = dini_Int(GetPlayerFile(playerid), "Admin");
  346. pData[playerid][AdminLevel] = dini_Int(GetPlayerFile(playerid), "AdminLevel");
  347. pData[playerid][Job] = dini_Int(GetPlayerFile(playerid), "Job");
  348. pData[playerid][JobRank] = dini_Int(GetPlayerFile(playerid), "JobRank");
  349. pData[playerid][Faction] = dini_Int(GetPlayerFile(playerid), "Faction");
  350. pData[playerid][FactionRank] = dini_Int(GetPlayerFile(playerid), "FactionRank");
  351.  
  352. Logged[playerid] = 1;
  353. SpawnPlayer(playerid);
  354. SetPlayerScore(playerid, pData[playerid][Level]);
  355. return 1;
  356. }
  357. }
  358. return 1;
  359. }
  360.  
  361. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  362. {
  363. return 1;
  364. }
  365.  
  366. stock GetName(playerid)
  367. {
  368. new pName[MAX_PLAYER_NAME];
  369. GetPlayerName(playerid, pName, sizeof(pName));
  370. return pName;
  371. }
  372.  
  373. stock GetIP(playerid)
  374. {
  375. new ip[30];
  376. GetPlayerIp(playerid, ip, 30);
  377. return ip;
  378. }
  379.  
  380. stock GetPlayerFile(playerid)
  381. {
  382. new file[128];
  383. format(file, sizeof(file), "Users/%s.ini", GetName(playerid));
  384. return file;
  385. }
  386.  
  387. stock UnderlineRemove(playerid)
  388. {
  389. new Name[24];
  390. GetPlayerName(playerid,Name,24);
  391. new N[24];
  392. strmid(N,Name,0,strlen(Name),24);
  393. for(new i = 0; i < MAX_PLAYER_NAME; i++)
  394. {
  395. if (N [i] == '_') N[i] = ' ';
  396. }
  397. return N;
  398. }
Advertisement
Add Comment
Please, Sign In to add comment