Guest User

Untitled

a guest
Nov 28th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.30 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_ini>
  3. #include <zcmd>
  4.  
  5.  
  6. #define DIALOG_REGISTER 1
  7. #define DIALOG_LOGIN 2
  8.  
  9.  
  10. #define COLOR_WHITE "{FFFFFF}"
  11. #define COLOR_RED"{F81414}"
  12. #define COLOR_GREEN "{00FF22}"
  13. #define COLOR_LIGHTBLUE "{00CED1}"
  14.  
  15.  
  16. #define PATH "/Users/%s.ini"
  17. #pragma tabsize 0
  18.  
  19.  
  20. enum pInfo
  21. {
  22.   pPass,
  23.   pCash,
  24.   pAdmin,
  25.   pScore,
  26.   pBankmoney,
  27.   pBanned
  28. }
  29. new PlayerInfo[MAX_PLAYERS][pInfo];
  30. forward LoadUser_data(playerid,name[],value[]);
  31. public LoadUser_data(playerid,name[],value[])
  32. {
  33.  
  34.   INI_Int("Password",PlayerInfo[playerid][pPass]);
  35.   INI_Int("Cash",PlayerInfo[playerid][pCash]);
  36.   INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  37.   INI_Int("Score",PlayerInfo[playerid][pScore]);
  38.   INI_Int("Bankmoney",PlayerInfo[playerid][pBankmoney]);
  39.   INI_Int("Banned",PlayerInfo[playerid][pBanned]);
  40.   return 1;
  41.  
  42. }
  43. stock UserPath(playerid)
  44. {
  45.  
  46.   new string[128],playername[MAX_PLAYER_NAME];
  47.   GetPlayerName(playerid,playername,sizeof(playername));
  48.   format(string,sizeof(string),PATH,playername);
  49.   return string;
  50. }
  51. stock udb_hash(buf[])
  52. {
  53.  
  54.   new length=strlen(buf);
  55.   new s1 = 1;
  56.   new s2 = 0;
  57.   new n;
  58.   for (n=0; n<length; n++)
  59.   {
  60.     s1 = (s1+buf[n]) % 65521;
  61.     s1 = (s2+s1)     % 65521;
  62.   }
  63.     return (s2 << 16) +s1;
  64. }
  65.  
  66.  
  67. main()
  68. {
  69.     print("\n----------------------------------");
  70.     print(" Blank Gamemode by your name here");
  71.     print("----------------------------------\n");
  72. }
  73.  
  74.  
  75. public OnGameModeInit()
  76. {
  77.     // Don't use these lines if it's a filterscript
  78.     SetGameModeText("Blank Script");
  79.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  80.     return 1;
  81. }
  82.  
  83. public OnGameModeExit()
  84. {
  85.     return 1;
  86. }
  87.  
  88. public OnPlayerRequestClass(playerid, classid)
  89. {
  90.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  91.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  92.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  93.     return 1;
  94. }
  95.  
  96. public OnPlayerConnect(playerid)
  97. {
  98.     if(fexist(UserPath(playerid)))
  99.     {
  100.         INI_ParseFile(UserPath(playerid),"LoadUser_%s",.bExtra = true ,.extra = playerid);
  101.         ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login:","Please enter your password to log in in your account!","Login","Quit");
  102.  
  103.     }
  104.     else
  105.     {
  106.         ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register:","If you would register new account just type password which you want!","Register","Quit");
  107.     }
  108.     return 1;
  109. }
  110.  
  111. public OnPlayerDisconnect(playerid, reason)
  112. {
  113.   new INI:File = INI_Open(UserPath(playerid));
  114.   INI_SetTag(File,"data");
  115.   INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  116.   INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  117.   INI_WriteInt(File,"Score",GetPlayerScore(playerid));
  118.   INI_WriteInt(File,"Bankmoney",PlayerInfo[playerid][pBankmoney]);
  119.   INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
  120.   INI_Close(File);
  121.   return 1;
  122. }
  123. public OnPlayerSpawn(playerid)
  124. {
  125.     return 1;
  126. }
  127.  
  128. public OnPlayerDeath(playerid, killerid, reason)
  129. {
  130.     return 1;
  131. }
  132.  
  133. public OnVehicleSpawn(vehicleid)
  134. {
  135.     return 1;
  136. }
  137.  
  138. public OnVehicleDeath(vehicleid, killerid)
  139. {
  140.     return 1;
  141. }
  142.  
  143. public OnPlayerText(playerid, text[])
  144. {
  145.     return 1;
  146. }
  147.  
  148. public OnPlayerCommandText(playerid, cmdtext[])
  149. {
  150.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  151.     {
  152.         // Do something here
  153.         return 1;
  154.     }
  155.     return 0;
  156. }
  157.  
  158. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  159. {
  160.     return 1;
  161. }
  162.  
  163. public OnPlayerExitVehicle(playerid, vehicleid)
  164. {
  165.     return 1;
  166. }
  167.  
  168. public OnPlayerStateChange(playerid, newstate, oldstate)
  169. {
  170.     return 1;
  171. }
  172.  
  173. public OnPlayerEnterCheckpoint(playerid)
  174. {
  175.     return 1;
  176. }
  177.  
  178. public OnPlayerLeaveCheckpoint(playerid)
  179. {
  180.     return 1;
  181. }
  182.  
  183. public OnPlayerEnterRaceCheckpoint(playerid)
  184. {
  185.     return 1;
  186. }
  187.  
  188. public OnPlayerLeaveRaceCheckpoint(playerid)
  189. {
  190.     return 1;
  191. }
  192.  
  193. public OnRconCommand(cmd[])
  194. {
  195.     return 1;
  196. }
  197.  
  198. public OnPlayerRequestSpawn(playerid)
  199. {
  200.     return 1;
  201. }
  202.  
  203. public OnObjectMoved(objectid)
  204. {
  205.     return 1;
  206. }
  207.  
  208. public OnPlayerObjectMoved(playerid, objectid)
  209. {
  210.     return 1;
  211. }
  212.  
  213. public OnPlayerPickUpPickup(playerid, pickupid)
  214. {
  215.     return 1;
  216. }
  217.  
  218. public OnVehicleMod(playerid, vehicleid, componentid)
  219. {
  220.     return 1;
  221. }
  222.  
  223. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  224. {
  225.     return 1;
  226. }
  227.  
  228. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  229. {
  230.     return 1;
  231. }
  232.  
  233. public OnPlayerSelectedMenuRow(playerid, row)
  234. {
  235.     return 1;
  236. }
  237.  
  238. public OnPlayerExitedMenu(playerid)
  239. {
  240.     return 1;
  241. }
  242.  
  243. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  244. {
  245.     return 1;
  246. }
  247.  
  248. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  249. {
  250.     return 1;
  251. }
  252.  
  253. public OnRconLoginAttempt(ip[], password[], success)
  254. {
  255.     return 1;
  256. }
  257.  
  258. public OnPlayerUpdate(playerid)
  259. {
  260.     return 1;
  261. }
  262.  
  263. public OnPlayerStreamIn(playerid, forplayerid)
  264. {
  265.     return 1;
  266. }
  267.  
  268. public OnPlayerStreamOut(playerid, forplayerid)
  269. {
  270.     return 1;
  271. }
  272.  
  273. public OnVehicleStreamIn(vehicleid, forplayerid)
  274. {
  275.     return 1;
  276. }
  277.  
  278. public OnVehicleStreamOut(vehicleid, forplayerid)
  279. {
  280.     return 1;
  281. }
  282.  
  283. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  284. {
  285.    switch(dialogid)
  286.    {
  287.         case DIALOG_REGISTER:
  288.         {
  289.             if(response)
  290.             {
  291.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register:","Password invalid,try again!",Register","Quit");
  292.                 new INI:File = INI_Open(UserPath(playerid));
  293.                 INI_SetTag(File,"data");
  294.                 INI_WriteInt(File,"Password",udb_hash(inputtext));
  295.                 INI_WriteInt(File,"Cash",0);
  296.                 INI_WriteInt(File,"Admin",0);
  297.                 INI_WriteInt(File,"Score",0;
  298.                 INI_WriteInt(File,"Bankmoney,0);
  299.                 INI_WriteInt(File,"Banned",0);
  300.                 Ini_Close(File);
  301.             }
  302.         }
  303.         case DIALOG_LOGIN:
  304.         {
  305.             if(response)
  306.             {
  307.                 if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  308.                 {
  309.                     INI_ParseFile(UserPath(playerid),"LoadUser_%s,".bExtra = true,.extra = playerid);
  310.                     GivePlayerMoney(playerid,Playerinfo[playerid][pCash];
  311.                     SetPlayerScore(playerid,PlayerInfo[playerid][pScore];
  312.                     SendClientMessage(playerid,-1,"You've successfully logged in your account!");
  313.                 }
  314.                 else
  315.                 {
  316.                     ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login:","Password incorrect,try again!","Login!","Quit");
  317.                 }
  318.             }
  319.         }
  320.     }
  321.     return 1;
  322. }
  323.  
  324. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  325. {
  326.     return 1;
  327. }
Advertisement
Add Comment
Please, Sign In to add comment