Guest User

here it is

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