SHARE
TWEET

Untitled

a guest May 19th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <dcmd>
  5. #include <dini>
  6. #include <dutils>
  7.  
  8. #define COLOUR_GREEN           0x33AA33AA
  9. #define COLOUR_RED             0xAA3333AA
  10. #define COLOUR_YELLOW          0xFFFF00AA
  11. #define COLOUR_LIGHTBLUE       0x33CCFFAA
  12. #define COLOUR_ORANGE          0xFF9900AA
  13.  
  14. #define PlayerFile         "Users/%s.ini"
  15. #define SettingFile        "Settings/MainSettings.ini"
  16. #define CommandFile        "Settings/Commands.ini"
  17.  
  18. #pragma tabsize 0
  19.  
  20. enum PLAYER_MAIN {
  21.     PLAYER_NAME[MAX_PLAYER_NAME],
  22.     PLAYER_IP[16],
  23.     PLAYER_REGGED,
  24.     PLAYER_PASS,
  25.     PLAYER_LOGGED,
  26.     PLAYER_LEVEL,
  27.     PLAYER_WIRED,
  28.     PLAYER_JAILED
  29. }
  30.  
  31. new gPlayerInfo[MAX_PLAYERS][PLAYER_MAIN];
  32.  
  33. enum COMMANDS_MAIN {
  34.     AKILL,
  35.     ANNOUNCE,
  36.     ARMOURALL,
  37.     BAN,
  38.     CARHP,
  39.     EXPLODE,
  40.     FLIP,
  41.     GOTO,
  42.     GETHERE,
  43.     GIVEARMOUR,
  44.     GIVEHEALTH,
  45.     GIVEWEAPON,
  46.     GOD,
  47.     HEALALL,
  48.     IMITATE,
  49.     IP,
  50.     KICK,
  51.     MAXAMMO,
  52.     PING,
  53.     SETLEVEL,
  54.     SETWANTED,
  55.     TBAN,
  56.     TIME,
  57.     WEATHER
  58. }
  59.  
  60. new gCommands[COMMANDS_MAIN];
  61.  
  62. enum SETTINGS_MAIN {
  63.     POCKET_MONEY,
  64.     JAIL_COMMANDS,
  65.     ANNOUNCE_SECONDS,
  66.     PASS_MIN,
  67.     PASS_MAX
  68. }
  69. new gSettings[SETTINGS_MAIN];
  70.  
  71.  
  72. public OnFilterScriptInit()
  73. {
  74.     print("\n****************************************");
  75.     print("* Admin Filterscript by your name here *");
  76.     print("****************************************\n");
  77.  
  78.        if(!fexist(SettingFile))
  79.     {
  80.         dini_Create(SettingFile);
  81.         dini_IntSet(SettingFile, "PocketMoney", 3000);
  82.         dini_IntSet(SettingFile, "JailCommands", 0);
  83.         dini_IntSet(SettingFile, "AnnounceSeconds", 3);
  84.         dini_IntSet(SettingFile, "PassMin", 3);
  85.         dini_IntSet(SettingFile, "PassMax", 15);
  86.     }
  87.  
  88.     gSettings[POCKET_MONEY]         = dini_Int(SettingFile, "PocketMoney");
  89.     gSettings[JAIL_COMMANDS]        = dini_Int(SettingFile, "JailCommands");
  90.     gSettings[ANNOUNCE_SECONDS]             = dini_Int(SettingFile, "AnnounceSeconds");
  91.     gSettings[PASS_MIN]             = dini_Int(SettingFile, "PassMin");
  92.     gSettings[PASS_MAX]             = dini_Int(SettingFile, "PassMax");
  93.  
  94.     if(!fexist(CommandFile))
  95.     {
  96.         dini_Create(CommandFile);
  97.         dini_IntSet(CommandFile, "Akill", 6);
  98.         dini_IntSet(CommandFile, "Announce", 5);
  99.         dini_IntSet(CommandFile, "Armourall", 3);
  100.         dini_IntSet(CommandFile, "Ban", 9);
  101.         dini_IntSet(CommandFile, "Carhp", 4);
  102.         dini_IntSet(CommandFile, "Explode", 5);
  103.         dini_IntSet(CommandFile, "Goto", 4);
  104.         dini_IntSet(CommandFile, "Gethere", 5);
  105.         dini_IntSet(CommandFile, "Givearmour", 6);
  106.         dini_IntSet(CommandFile, "Givehealth", 6);
  107.         dini_IntSet(CommandFile, "Giveweapon", 7);
  108.         dini_IntSet(CommandFile, "God", 10);
  109.         dini_IntSet(CommandFile, "Healall", 7);
  110.         dini_IntSet(CommandFile, "Imitate", 8);
  111.         dini_IntSet(CommandFile, "Ip", 2);
  112.         dini_IntSet(CommandFile, "Kick", 7);
  113.         dini_IntSet(CommandFile, "Maxammo", 8);
  114.         dini_IntSet(CommandFile, "Ping", 1);
  115.         dini_IntSet(CommandFile, "Setlevel", 10);
  116.         dini_IntSet(CommandFile, "Setwanted", 6);
  117.         dini_IntSet(CommandFile, "Tban", 9);
  118.         dini_IntSet(CommandFile, "Time", 3);
  119.         dini_IntSet(CommandFile, "Weather", 3);
  120.         }
  121.  
  122.  
  123.  
  124.     gCommands[AKILL]            = dini_Int(CommandFile, "Akill");
  125.     gCommands[ANNOUNCE]                 = dini_Int(CommandFile, "Announce");
  126.     gCommands[ARMOURALL]            = dini_Int(CommandFile, "Armourall");
  127.     gCommands[BAN]              = dini_Int(CommandFile, "Ban");
  128.     gCommands[CARHP]            = dini_Int(CommandFile, "Carhp");
  129.     gCommands[EXPLODE]          = dini_Int(CommandFile, "Explode");
  130.     gCommands[GOTO]             = dini_Int(CommandFile, "Goto");
  131.     gCommands[GETHERE]          = dini_Int(CommandFile, "Gethere");
  132.     gCommands[GIVEARMOUR]           = dini_Int(CommandFile, "Givearmour");
  133.     gCommands[GIVEHEALTH]           = dini_Int(CommandFile, "Givehealth");
  134.     gCommands[GIVEWEAPON]           = dini_Int(CommandFile, "Giveweapon");
  135.     gCommands[GOD]              = dini_Int(CommandFile, "God");
  136.     gCommands[HEALALL]          = dini_Int(CommandFile, "Healall");
  137.     gCommands[IMITATE]          = dini_Int(CommandFile, "Imitate");
  138.     gCommands[IP]               = dini_Int(CommandFile, "Ip");
  139.     gCommands[KICK]             = dini_Int(CommandFile, "Kick");
  140.     gCommands[MAXAMMO]          = dini_Int(CommandFile, "Maxammo");
  141.     gCommands[SETLEVEL]             = dini_Int(CommandFile, "Setlevel");
  142.     gCommands[SETWANTED]            = dini_Int(CommandFile, "Setwanted");
  143.     gCommands[TBAN]             = dini_Int(CommandFile, "Tban");
  144.     gCommands[TIME]             = dini_Int(CommandFile, "Time");
  145.     gCommands[WEATHER]          = dini_Int(CommandFile, "Weather");
  146.  
  147.     return 1;
  148. }
  149.  
  150.  
  151.  
  152. public OnPlayerConnect(playerid)
  153. {
  154.     new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  155.     if(!dini_Exists(file)) {
  156.         dini_Create(file);
  157.         dini_Set(file,"Name",Name);
  158.         dini_Set(file,"Ip",Ip);
  159.         dini_IntSet(file,"Registered",-1);
  160.         dini_IntSet(file,"Password",0);
  161.         dini_IntSet(file,"Level",0);
  162.         dini_IntSet(file,"Wired",0);
  163.         dini_IntSet(file,"Jailed",0);
  164.         SendClientMessage(playerid,COLOUR_ORANGE,"You're username is not recognized on this server. Please /register to continue.");
  165.     }
  166.     strcat(gPlayerInfo[playerid][PLAYER_NAME],          dini_Get(file,"Name"));
  167.     strcat(gPlayerInfo[playerid][PLAYER_IP],            dini_Get(file,"Ip"));
  168.     gPlayerInfo[playerid][PLAYER_REGGED]                  = dini_Int(file,"Registered");
  169.     gPlayerInfo[playerid][PLAYER_PASS]                            = dini_Int(file,"Password");
  170.     gPlayerInfo[playerid][PLAYER_LEVEL]                   = dini_Int(file,"Level");
  171.     gPlayerInfo[playerid][PLAYER_WIRED]                           = dini_Int(file,"Wired");
  172.     gPlayerInfo[playerid][PLAYER_JAILED]                  = dini_Int(file,"Jailed");
  173.     if(gPlayerInfo[playerid][PLAYER_REGGED] == 0)                   SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server, but you have not registered. Please /register to continue.");
  174.     else if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)              SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server. Please /login to continue.");
  175.     gPlayerInfo[playerid][PLAYER_REGGED]                          = 0;
  176.     return 1;
  177. }
  178.  
  179. public OnPlayerDisconnect(playerid, reason)
  180. {
  181.     new file[100];
  182.         format(file,sizeof(file),PlayerFile,gPlayerInfo[playerid][PLAYER_NAME]);
  183.     dini_Set(file,"Name",gPlayerInfo[playerid][PLAYER_NAME]);
  184.     dini_Set(file,"Ip",gPlayerInfo[playerid][PLAYER_IP]);
  185.     dini_IntSet(file,"Registered",gPlayerInfo[playerid][PLAYER_REGGED]);
  186.     dini_IntSet(file,"Password",gPlayerInfo[playerid][PLAYER_PASS]);
  187.     dini_IntSet(file,"Level",gPlayerInfo[playerid][PLAYER_LEVEL]);
  188.     dini_IntSet(file,"Wired",gPlayerInfo[playerid][PLAYER_WIRED]);
  189.     dini_IntSet(file,"Jailed",gPlayerInfo[playerid][PLAYER_JAILED]);
  190.     gPlayerInfo[playerid][PLAYER_NAME]   = 0;
  191.     gPlayerInfo[playerid][PLAYER_IP]     = 0;
  192.     gPlayerInfo[playerid][PLAYER_REGGED] = 0;
  193.     gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
  194.     gPlayerInfo[playerid][PLAYER_PASS]   = 0;
  195.     gPlayerInfo[playerid][PLAYER_LEVEL]  = 0;
  196.     gPlayerInfo[playerid][PLAYER_WIRED]  = 0;
  197.     gPlayerInfo[playerid][PLAYER_JAILED] = 0;
  198.         return 1;
  199. }
  200.  
  201. public OnPlayerCommandText(playerid, cmdtext[])
  202. {
  203.     dcmd(register, 8, cmdtext);
  204.     dcmd(login, 5, cmdtext);
  205.     dcmd(logout, 6, cmdtext);
  206.     dcmd(password, 8, cmdtext);
  207.  
  208.     return 0;
  209. }
  210.  
  211. dcmd_register(playerid, params[])
  212. {
  213.     if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)
  214.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You have already registered!");
  215.     else if(!params[0])
  216.     return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /register [password]");
  217.     else if(strlen(params) < gSettings[PASS_MIN] || strlen(params) > gSettings[PASS_MAX])
  218.     {
  219.     new string[200];
  220.         format(string, sizeof(string), "ERROR: Password must be between %d and $d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
  221.     return SendClientMessage(playerid, COLOUR_ORANGE, string);
  222.     }
  223.     else
  224.     {
  225.     new password = num_hash(params);
  226.     gPlayerInfo[playerid][PLAYER_PASS] = password;
  227.     gPlayerInfo[playerid][PLAYER_REGGED] = 1;
  228.         gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
  229.     GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
  230.     new string[256]; format(string, sizeof(string), "You have successfully registered your account with the password \'%s\'. You have been automatically logged in.", params);
  231.     return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  232.     }
  233. }
  234.  
  235. dcmd_login(playerid, params[])
  236. {
  237.     if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  238.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
  239.     else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 1)
  240.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-in.");
  241.     else if(!params[0])
  242.     return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /login [password]");
  243.     else
  244.     {
  245.     new password = num_hash(params);
  246.     if(gPlayerInfo[playerid][PLAYER_PASS] == password)
  247.     {
  248.         gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
  249.             GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
  250.         return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged in to your account.");
  251.     }
  252.     else
  253.         return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  254.     }
  255. }
  256.  
  257. dcmd_logout(playerid, params[])
  258. {
  259. #pragma unused params
  260.     if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  261.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register.");
  262.     else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
  263.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-out.");
  264.     else
  265.     {
  266.     gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
  267.     return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged out of your account.");
  268.     }
  269. }
  270.  
  271. dcmd_password(playerid, params[])
  272. {
  273.     if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  274.         return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
  275.     else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
  276.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must be logged-in to do that! Use /login [password] to login.");
  277.     else
  278.     {
  279.     new tmp[30],
  280.         tmp2[30],
  281.         index;
  282.     tmp = strtok(params, index);
  283.     if(!strlen(tmp))
  284.             return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
  285.     tmp2 = strtok(params, index);
  286.     if(!strlen(tmp2))
  287.         return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
  288.         new oldpassword = num_hash(tmp), newpassword = num_hash(tmp2);
  289.     if(gPlayerInfo[playerid][PLAYER_PASS] == oldpassword)
  290.     {
  291.         if(oldpassword == newpassword)
  292.             return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Your old password can not be the same as your new password.");
  293.             else if(strlen(tmp2) < gSettings[PASS_MIN] || strlen(tmp2) > gSettings[PASS_MAX])
  294.             {
  295.                 new string[100]; format(string, sizeof(string), "ERROR: Your new password must be between %d and %d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
  296.                 return SendClientMessage(playerid, COLOUR_ORANGE, string);
  297.             }
  298.         gPlayerInfo[playerid][PLAYER_PASS] = newpassword;
  299.         new string[256]; format(string, sizeof(string), "You have successfully changed your password from \'%s\' to \'%s\'.", tmp, tmp2);
  300.         return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  301.     }
  302.     else
  303.         return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  304.     }
  305. }
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top