Guest User

Blank admin FS

a guest
Nov 10th, 2013
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.69 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_ini>
  3. #include <sscanf2>
  4. #include <zcmd>
  5.  
  6. #define FILTERSCRIPT
  7.  
  8. #define DIALOG_REGISTER         9998
  9. #define DIALOG_LOGIN            9999
  10. #define UserPath                "Users/%s.ini"
  11.  
  12. #define COLOR_RED               0xFF0000FF
  13. #define COLOR_BLUE              0x0000FFFF
  14. #define COLOR_YELLOW            0xFFFF00FF
  15. #define COLOR_GREEN             0x00FF00FF
  16. #define COLOR_LIGHTBLUE         0x00FFFFFF
  17. #define COLOR_WHITE             0xFFFFFFFF
  18. #define COLOR_BLACK             0x000000FF
  19. #define COLOR_GRAY              0x808080FF
  20.  
  21. native WP_Hash(buffer[],len,const str[]);
  22.  
  23. forward loadaccount_user(playerid, name[], value[]);
  24.  
  25. #if defined FILTERSCRIPT
  26.  
  27. public OnFilterScriptInit()
  28. {
  29.     print("\n---------------------------------------");
  30.     print("  Blank admin filterscript by Stinged  ");
  31.     print("---------------------------------------\n");
  32.     return 1;
  33. }
  34.  
  35. public OnFilterScriptExit()
  36. {
  37.     return 1;
  38. }
  39.  
  40. #else
  41.  
  42. main()
  43. {
  44.     print("\n----------------------------------");
  45.     print(" Blank Gamemode by your name here");
  46.     print("----------------------------------\n");
  47. }
  48.  
  49. #endif
  50.  
  51.  
  52. enum PlayerStats
  53. {
  54.     password[128],
  55.     money,
  56.     score,
  57.     deaths,
  58.     admin,
  59. }
  60. new pStats[MAX_PLAYERS][PlayerStats];
  61.  
  62. public OnPlayerConnect(playerid)
  63. {
  64.     new name[MAX_PLAYER_NAME];
  65.     GetPlayerName(playerid,name,sizeof(name));
  66.     if(fexist(Path(playerid)))
  67.     {
  68.         INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
  69.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{00FFFF}Login", "{00FFFF}Please enter your password to login.", "OK", "Cancel");
  70.     }
  71.     else
  72.     {
  73.         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FFFF}Register", "{00FFFF}Please enter your password to register.", "OK", "Cancel");
  74.     }
  75.     return 1;
  76. }
  77.  
  78. public OnPlayerDisconnect(playerid, reason)
  79. {
  80.     new INI:file = INI_Open(Path(playerid));
  81.     INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
  82.     INI_WriteInt(file,"Score",GetPlayerScore(playerid));
  83.     INI_WriteInt(file,"Deaths",pStats[playerid][deaths]);
  84.     INI_WriteInt(file,"Admin",pStats[playerid][admin]);
  85.     INI_Close(file);
  86.     return 1;
  87. }
  88.  
  89. public OnPlayerSpawn(playerid)
  90. {
  91.     ResetPlayerMoney(playerid);
  92.     GivePlayerMoney(playerid, pStats[playerid][money]);
  93.     SetPlayerScore(playerid, pStats[playerid][score]);
  94.     return 1;
  95. }
  96.  
  97. public OnPlayerDeath(playerid, killerid, reason)
  98. {
  99.     pStats[killerid][score]++;
  100.     pStats[killerid][money]++;
  101.     pStats[playerid][deaths]++;
  102.     GivePlayerMoney(killerid, 1);
  103.     SetPlayerScore(killerid, pStats[killerid][score]);
  104.     return 1;
  105. }
  106.  
  107. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  108. {
  109.     if(response)
  110.     {
  111.         switch(dialogid)
  112.         {
  113.             case DIALOG_REGISTER:
  114.             {
  115.                 if(!response) return Kick(playerid);
  116.                 if(response)
  117.                 {
  118.                     if(!strlen(inputtext))
  119.                     {
  120.                         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FFFF}Register", "{00FFFF}Please enter your password to register.\n{FF0000}You can't leave this empty.", "OK", "Cancel");
  121.                         return 1;
  122.                     }
  123.                     new hashpass[129];
  124.                     WP_Hash(hashpass,sizeof(hashpass),inputtext);
  125.                     new string[128];
  126.                     new INI:file = INI_Open(Path(playerid));
  127.                     INI_WriteString(file,"Password",hashpass);
  128.                     INI_WriteInt(file,"Money",0);
  129.                     INI_WriteInt(file,"Score",0);
  130.                     INI_WriteInt(file,"Deaths",0);
  131.                     INI_WriteInt(file,"Admin",0);
  132.                     INI_Close(file);
  133.                     format(string, sizeof(string), "You have successfully registered. Password: {00FF00)%s", inputtext);
  134.                     SendClientMessage(playerid, COLOR_WHITE, string);
  135.                     return 1;
  136.                 }
  137.             }
  138.             case DIALOG_LOGIN:
  139.             {
  140.                 if(!response) return Kick(playerid);
  141.                 if(response)
  142.                 {
  143.                     new hashpass[129];
  144.                     WP_Hash(hashpass,sizeof(hashpass),inputtext);
  145.                     if(!strcmp(hashpass, pStats[playerid][password], false))
  146.                     {
  147.                         INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
  148.                         SendClientMessage(playerid,COLOR_WHITE,"You have successfully logged in.");
  149.                     }
  150.                     else
  151.                     {
  152.                         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{00FFFF}Please enter your password to login.\n{FF0000}Incorrect password.", "OK", "Cancel");
  153.                         return 1;
  154.                     }
  155.                 }
  156.             }
  157.         }
  158.     }
  159.     return 1;
  160. }
  161.  
  162.  
  163. CMD:setlevel(playerid,params[])
  164. {
  165.     if(IsPlayerAdmin(playerid))
  166.     {
  167.         new id,level,string[128],aName[MAX_PLAYER_NAME];
  168.         if(sscanf(params,"ud",id,level)) SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /setlevel [id/name] [level]");
  169.         else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "Invalid player id.");
  170.         else if(level > 5) SendClientMessage(playerid, COLOR_RED, "Highest admin level is 5.");
  171.         else
  172.         {
  173.             pStats[id][admin] = 5;
  174.             new INI:file = INI_Open(Path(id));
  175.             INI_WriteInt(file,"Admin",level);
  176.             INI_Close(file);
  177.             GetPlayerName(playerid, aName, sizeof(aName));
  178.             format(string, sizeof(string), "Admin %s has set your admin level to %d.",aName,level);
  179.             SendClientMessage(playerid, COLOR_WHITE, "You have changed the selected user's admin level.");
  180.             SendClientMessage(id,COLOR_GREEN,string);
  181.         }
  182.     }
  183.     else
  184.     {
  185.         SendClientMessage(playerid, COLOR_RED, "[!] You need to be a higher admin level to use this command.");
  186.     }
  187.     return 1;
  188. }
  189.  
  190. public loadaccount_user(playerid, name[], value[])
  191. {
  192.     INI_String("Password",pStats[playerid][password],128);
  193.     INI_Int("Money",pStats[playerid][money]);
  194.     INI_Int("Score",pStats[playerid][score]);
  195.     INI_Int("Deaths",pStats[playerid][deaths]);
  196.     INI_Int("Admin",pStats[playerid][admin]);
  197.     return 1;
  198. }
  199.  
  200. stock Path(playerid)
  201. {
  202.     new str[128],name[MAX_PLAYER_NAME];
  203.     GetPlayerName(playerid,name,sizeof(name));
  204.     format(str,sizeof(str),UserPath,name);
  205.     return str;
  206. }
Advertisement
Add Comment
Please, Sign In to add comment