Advertisement
Guest User

Script

a guest
Oct 10th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.81 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_ini>
  3.  
  4. #define DIALOG_REGISTER 1
  5. #define DIALOG_LOGIN 2
  6. #define DIALOG_ERFOLGREICH_1 3
  7. #define DIALOG_ERFOLGREICH_2 4
  8.  
  9. #define PATH "IRegister/Users/%s.ini"
  10.  
  11. #define COL_WHITE "{FFFFFF}"
  12. #define COL_RED "{F81414}"
  13. #define COL_GREEN "{00FF22}"
  14. #define COL_LIGHTBLUE "{00CED1}"
  15.  
  16. enum pInfo
  17. {
  18. pPass,
  19. pCash,
  20. pKills,
  21. pDeaths
  22. }
  23. new PlayerInfo[MAX_PLAYERS][pInfo];
  24.  
  25. forward LoadUser_data(playerid,name[],value[]);
  26. public LoadUser_data(playerid,name[],value[])
  27. {
  28. INI_Int("Passwort",PlayerInfo[playerid][pPass]);
  29. INI_Int("Geld",PlayerInfo[playerid][pCash]);
  30. INI_Int("Kills",PlayerInfo[playerid][pKills]);
  31. INI_Int("Tode",PlayerInfo[playerid][pDeaths]);
  32. return 1;
  33. }
  34.  
  35. stock UserPath(playerid)
  36. {
  37. new string[128],playername[MAX_PLAYER_NAME];
  38. GetPlayerName(playerid,playername,sizeof(playername));
  39. format(string,sizeof(string),PATH,playername);
  40. return string;
  41. }
  42.  
  43.  
  44. stock udb_hash(buf[]) {
  45. new length=strlen(buf);
  46. new s1 = 1;
  47. new s2 = 0;
  48. new n;
  49. for (n=0; n<length; n++)
  50. {
  51. s1 = (s1 + buf[n]) % 65521;
  52. s2 = (s2 + s1) % 65521;
  53. }
  54. return (s2 << 16) + s1;
  55. }
  56.  
  57. main()
  58. {
  59. print("\n----------------------------------");
  60. print("");
  61. print("----------------------------------\n");
  62. }
  63.  
  64. public OnGameModeInit()
  65. {
  66. SetGameModeText("BLRP");
  67. return 1;
  68. }
  69.  
  70. public OnGameModeExit()
  71. {
  72. return 1;
  73. }
  74.  
  75. public OnPlayerRequestClass(playerid, classid)
  76. {
  77. return 1;
  78. }
  79.  
  80. public OnPlayerConnect(playerid)
  81. {
  82. if(fexist(UserPath(playerid)))
  83. {
  84. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  85. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Gebe dein Passwort ein um zu spielen!","Login","Beenden");
  86. }
  87. else
  88. {
  89. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registrieren...",""COL_WHITE"Gebe ein Passwort ein um zu registrieren.","Registrieren","Beenden");
  90. }
  91. return 1;
  92. }
  93.  
  94. public OnPlayerDisconnect(playerid, reason)
  95. {
  96. new INI:File = INI_Open(UserPath(playerid));
  97. INI_SetTag(File,"data");
  98. INI_WriteInt(File,"Geld",GetPlayerMoney(playerid));
  99. INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
  100. INI_WriteInt(File,"Tode",PlayerInfo[playerid][pDeaths]);
  101. INI_Close(File);
  102. return 1;
  103. }
  104.  
  105. public OnPlayerSpawn(playerid)
  106. {
  107. return 1;
  108. }
  109.  
  110. public OnPlayerDeath(playerid, killerid, reason)
  111. {
  112. PlayerInfo[killerid][pKills]++;
  113. PlayerInfo[playerid][pDeaths]++;
  114. return 1;
  115. }
  116.  
  117. public OnVehicleSpawn(vehicleid)
  118. {
  119. return 1;
  120. }
  121.  
  122. public OnVehicleDeath(vehicleid, killerid)
  123. {
  124. return 1;
  125. }
  126.  
  127. public OnPlayerText(playerid, text[])
  128. {
  129. return 1;
  130. }
  131.  
  132. public OnPlayerCommandText(playerid, cmdtext[])
  133. {
  134. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  135. {
  136. // Do something here
  137. return 1;
  138. }
  139. return 0;
  140. }
  141.  
  142. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  143. {
  144. return 1;
  145. }
  146.  
  147. public OnPlayerExitVehicle(playerid, vehicleid)
  148. {
  149. return 1;
  150. }
  151.  
  152. public OnPlayerStateChange(playerid, newstate, oldstate)
  153. {
  154. return 1;
  155. }
  156.  
  157. public OnPlayerEnterCheckpoint(playerid)
  158. {
  159. return 1;
  160. }
  161.  
  162. public OnPlayerLeaveCheckpoint(playerid)
  163. {
  164. return 1;
  165. }
  166.  
  167. public OnPlayerEnterRaceCheckpoint(playerid)
  168. {
  169. return 1;
  170. }
  171.  
  172. public OnPlayerLeaveRaceCheckpoint(playerid)
  173. {
  174. return 1;
  175. }
  176.  
  177. public OnRconCommand(cmd[])
  178. {
  179. return 1;
  180. }
  181.  
  182. public OnPlayerRequestSpawn(playerid)
  183. {
  184. return 1;
  185. }
  186.  
  187. public OnObjectMoved(objectid)
  188. {
  189. return 1;
  190. }
  191.  
  192. public OnPlayerObjectMoved(playerid, objectid)
  193. {
  194. return 1;
  195. }
  196.  
  197. public OnPlayerPickUpPickup(playerid, pickupid)
  198. {
  199. return 1;
  200. }
  201.  
  202. public OnVehicleMod(playerid, vehicleid, componentid)
  203. {
  204. return 1;
  205. }
  206.  
  207. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  208. {
  209. return 1;
  210. }
  211.  
  212. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  213. {
  214. return 1;
  215. }
  216.  
  217. public OnPlayerSelectedMenuRow(playerid, row)
  218. {
  219. return 1;
  220. }
  221.  
  222. public OnPlayerExitedMenu(playerid)
  223. {
  224. return 1;
  225. }
  226.  
  227. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  228. {
  229. return 1;
  230. }
  231.  
  232. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  233. {
  234. return 1;
  235. }
  236.  
  237. public OnRconLoginAttempt(ip[], password[], success)
  238. {
  239. return 1;
  240. }
  241.  
  242. public OnPlayerUpdate(playerid)
  243. {
  244. return 1;
  245. }
  246.  
  247. public OnPlayerStreamIn(playerid, forplayerid)
  248. {
  249. return 1;
  250. }
  251.  
  252. public OnPlayerStreamOut(playerid, forplayerid)
  253. {
  254. return 1;
  255. }
  256.  
  257. public OnVehicleStreamIn(vehicleid, forplayerid)
  258. {
  259. return 1;
  260. }
  261.  
  262. public OnVehicleStreamOut(vehicleid, forplayerid)
  263. {
  264. return 1;
  265. }
  266.  
  267. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  268. {
  269. switch( dialogid )
  270. {
  271. case DIALOG_REGISTER:
  272. {
  273. if (!response) return Kick(playerid);
  274. if(response)
  275. {
  276. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registrierung...",""COL_RED"Du hast ein ungültiges Passwort eingegeben!\n"COL_WHITE"Gebe ein Passwort ein um zu registrieren.","Registrierung","Beenden");
  277. new INI:File = INI_Open(UserPath(playerid));
  278. INI_SetTag(File,"data");
  279. INI_WriteInt(File,"Passwort",udb_hash(inputtext));
  280. INI_WriteInt(File,"Geld",0);
  281. INI_WriteInt(File,"Kills",0);
  282. INI_WriteInt(File,"Tode",0);
  283. INI_Close(File);
  284.  
  285. SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  286. SpawnPlayer(playerid);
  287. ShowPlayerDialog(playerid, DIALOG_ERFOLGREICH_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Erfolgreich!",""COL_GREEN"Danke, du bist nun ein Teil des Servers "COL_LIGHTBLUE"BLACK LIFE ROLEPLAY","Ok","");
  288. }
  289. }
  290.  
  291. case DIALOG_LOGIN:
  292. {
  293. if ( !response ) return Kick ( playerid );
  294. if( response )
  295. {
  296. if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  297. {
  298. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  299. GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  300. ShowPlayerDialog(playerid, DIALOG_ERFOLGREICH_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Erfolgreich!",""COL_GREEN"Du darfst nun Spielen!","Ok","");
  301. }
  302. else
  303. {
  304. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"Du hast ein falschen Passwort eingegeben.\n"COL_WHITE"Gebe dein Passwort ein um zu spielen!","Login","Beenden");
  305. }
  306. return 1;
  307. }
  308. }
  309. }
  310. return 1;
  311. }
  312.  
  313. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  314. {
  315. return 1;
  316. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement