artyom_triodin1

REGISTER AND LOGIN SYSTEM WITH DINI AND DUDB

Oct 19th, 2014
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #include <dudb>
  4.  
  5. #define RED 0xFF0000FF
  6. #define YELLOW 0xFFFF00FF
  7. #define GREEN 0x00FF00FF
  8.  
  9. new Money;
  10.  
  11. #define ACC "Users2/%s.ini"
  12.  
  13. enum pInfo
  14. {
  15. pPass,
  16. pScore,
  17. pCash
  18. }
  19.  
  20. new PlayerInfo[MAX_PLAYERS][pInfo];
  21.  
  22. new gPlayerLogged[MAX_PLAYERS];
  23.  
  24. #if defined FILTERSCRIPT
  25.  
  26. public OnFilterScriptInit()
  27. {
  28. print("\n--------------------------------------");
  29. print(" Blank Filterscript by your name here");
  30. print("--------------------------------------\n");
  31. return 1;
  32. }
  33.  
  34. public OnFilterScriptExit()
  35. {
  36. return 1;
  37. }
  38.  
  39. #else
  40.  
  41. main()
  42. {
  43. print("\n----------------------------------");
  44. print(" Blank Gamemode by your name here");
  45. print("----------------------------------\n");
  46. }
  47.  
  48. #endif
  49.  
  50. public OnGameModeInit()
  51. {
  52. // Don't use these lines if it's a filterscript
  53. SetGameModeText("Blank Script");
  54. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  55. return 1;
  56. }
  57.  
  58. public OnGameModeExit()
  59. {
  60. return 1;
  61. }
  62.  
  63. public OnPlayerRequestClass(playerid, classid)
  64. {
  65. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  66. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  67. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  68. return 1;
  69. }
  70.  
  71. public OnPlayerConnect(playerid)
  72. {
  73. new pName[MAX_PLAYER_NAME], File[256];
  74. GetPlayerName(playerid, pName, sizeof(pName));
  75. format(File, sizeof(File), ACC, pName);
  76. if(!dini_Exists(File))
  77. {
  78. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "Welcome Please Register Now ! ", "Register", "Quit");
  79. }
  80. if(fexist(File))
  81. {
  82. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "You Allready Registered Please Login ! ! ! ", "login", "Quit");
  83. }
  84. return 1;
  85. }
  86.  
  87. public OnPlayerDisconnect(playerid, reason)
  88. {
  89. Money = GetPlayerMoney(playerid);
  90. gPlayerLogged[playerid] = 1;
  91. new pName[MAX_PLAYER_NAME], File[256];
  92. GetPlayerName(playerid, pName, sizeof(pName));
  93. format(File, sizeof(File), ACC, pName);
  94. {
  95. dini_IntSet(File, "Score", PlayerInfo[playerid][pScore]);
  96. Money = dini_IntSet(File, "Cash", PlayerInfo[playerid][pCash]);
  97. }
  98. gPlayerLogged[playerid] = 0;
  99. return 1;
  100. }
  101.  
  102. public OnPlayerSpawn(playerid)
  103. {
  104. return 1;
  105. }
  106.  
  107. public OnPlayerDeath(playerid, killerid, reason)
  108. {
  109. return 1;
  110. }
  111.  
  112. public OnVehicleSpawn(vehicleid)
  113. {
  114. return 1;
  115. }
  116.  
  117. public OnVehicleDeath(vehicleid, killerid)
  118. {
  119. return 1;
  120. }
  121.  
  122. public OnPlayerText(playerid, text[])
  123. {
  124. return 1;
  125. }
  126.  
  127. public OnPlayerCommandText(playerid, cmdtext[])
  128. {
  129. if (strcmp("/mdjksg", cmdtext, true, 10) == 0)
  130. {
  131. GivePlayerMoney(playerid, 900);
  132. return 1;
  133. }
  134. return 0;
  135. }
  136.  
  137. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  138. {
  139. return 1;
  140. }
  141.  
  142. public OnPlayerExitVehicle(playerid, vehicleid)
  143. {
  144. return 1;
  145. }
  146.  
  147. public OnPlayerStateChange(playerid, newstate, oldstate)
  148. {
  149. return 1;
  150. }
  151.  
  152. public OnPlayerEnterCheckpoint(playerid)
  153. {
  154. return 1;
  155. }
  156.  
  157. public OnPlayerLeaveCheckpoint(playerid)
  158. {
  159. return 1;
  160. }
  161.  
  162. public OnPlayerEnterRaceCheckpoint(playerid)
  163. {
  164. return 1;
  165. }
  166.  
  167. public OnPlayerLeaveRaceCheckpoint(playerid)
  168. {
  169. return 1;
  170. }
  171.  
  172. public OnRconCommand(cmd[])
  173. {
  174. return 1;
  175. }
  176.  
  177. public OnPlayerRequestSpawn(playerid)
  178. {
  179. return 1;
  180. }
  181.  
  182. public OnObjectMoved(objectid)
  183. {
  184. return 1;
  185. }
  186.  
  187. public OnPlayerObjectMoved(playerid, objectid)
  188. {
  189. return 1;
  190. }
  191.  
  192. public OnPlayerPickUpPickup(playerid, pickupid)
  193. {
  194. return 1;
  195. }
  196.  
  197. public OnVehicleMod(playerid, vehicleid, componentid)
  198. {
  199. return 1;
  200. }
  201.  
  202. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  203. {
  204. return 1;
  205. }
  206.  
  207. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  208. {
  209. return 1;
  210. }
  211.  
  212. public OnPlayerSelectedMenuRow(playerid, row)
  213. {
  214. return 1;
  215. }
  216.  
  217. public OnPlayerExitedMenu(playerid)
  218. {
  219. return 1;
  220. }
  221.  
  222. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  223. {
  224. return 1;
  225. }
  226.  
  227. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  228. {
  229. return 1;
  230. }
  231.  
  232. public OnRconLoginAttempt(ip[], password[], success)
  233. {
  234. return 1;
  235. }
  236.  
  237. public OnPlayerUpdate(playerid)
  238. {
  239. return 1;
  240. }
  241.  
  242. public OnPlayerStreamIn(playerid, forplayerid)
  243. {
  244. return 1;
  245. }
  246.  
  247. public OnPlayerStreamOut(playerid, forplayerid)
  248. {
  249. return 1;
  250. }
  251.  
  252. public OnVehicleStreamIn(vehicleid, forplayerid)
  253. {
  254. return 1;
  255. }
  256.  
  257. public OnVehicleStreamOut(vehicleid, forplayerid)
  258. {
  259. return 1;
  260. }
  261.  
  262. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  263. {
  264. if(dialogid == 1)
  265. {
  266. new Message[128];
  267. new pName[MAX_PLAYER_NAME], File[256];
  268. GetPlayerName(playerid, pName, sizeof(pName));
  269. format(File, sizeof(File), ACC, pName);
  270. if(!response) return Kick(playerid);
  271. if(!strlen (inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "{FF0000} You Have To Register Or You Will Not Play So Register Please !!! !!! !!!", "Register", "Quit");
  272. format(Message, sizeof(Message), "Name : {FF0000}%s {FFFF00}Password : {FF0000}%s {FFFF00}And Press To ScreenShot You Password If You Want{00FFFF}!! !! ! ! !!!!!!!", pName, inputtext);
  273. SendClientMessage(playerid, YELLOW, Message);
  274. dini_Create(File);
  275. dini_IntSet(File, "Password", udb_hash(inputtext));
  276. }
  277. if(dialogid == 2)
  278. {
  279. new tmp;
  280. new pName[MAX_PLAYER_NAME], File[256];
  281. GetPlayerName(playerid, pName, sizeof(pName));
  282. format(File, sizeof(File), ACC, pName);
  283. if(!response) return Kick(playerid);
  284. if(!strlen (inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "{FF0000} You HAve To Login If You Dont Remember So Create A New Account!!! !! ! ! !! !! ! ! ! ! ", "login", "Quit");
  285. tmp = dini_Int(File, "Password");
  286. if(udb_hash(inputtext) != tmp) {
  287. SendClientMessage(playerid, RED, "Invalid Password! ! ! ! ! ! ! ! ! ! ! ");
  288. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "{FF0000} You HAve To Login If You Dont Remember So Create A New Account!!! !! ! ! !! !! ! ! ! ! ", "login", "Quit");
  289. }
  290. else
  291. {
  292. gPlayerLogged[playerid] = 1;
  293. SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
  294. GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  295. SendClientMessage(playerid, GREEN, "You Logged In Succes Fully Man !!! !!! !!!");
  296. }
  297. }
  298. return 1;
  299. }
  300.  
  301. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  302. {
  303. return 1;
  304. }
  305.  
  306. #pragma unused ret_memcpy
Advertisement
Add Comment
Please, Sign In to add comment