Advertisement
Guest User

Untitled

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