Guest User

Trolly :)

a guest
Jan 31st, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 14.48 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <dini>
  5. #include <dutils>
  6.  
  7. #if defined FILTERSCRIPT
  8.  
  9. ////////////////////////////////////////////////////////////////////////////////
  10.  
  11. enum PLAYER_MAIN {
  12.     PLAYER_NAME[MAX_PLAYER_NAME],
  13.     PLAYER_IP[16],
  14.     PLAYER_REGGED,
  15.     PLAYER_PASS,
  16.     PLAYER_LOGGED,
  17.     PLAYER_LEVEL,
  18.     PLAYER_WIRED,
  19.     PLAYER_JAILED
  20. }
  21.  
  22. enum SETTINGS_MAIN {
  23.     POCKET_MONEY,
  24.     JAIL_COMMANDS,
  25.     ANNOUNCE_SECONDS,
  26.     PASS_MIN,
  27.     PASS_MAX
  28. }
  29.  
  30. enum COMMANDS_MAIN {
  31.     AKILL,
  32.     ANNOUNCE,
  33.     ARMOURALL,
  34.     BAN,
  35.     CARHP,
  36.     EXPLODE,
  37.     FLIP,
  38.     GOTO,
  39.     GETHERE,
  40.     GIVEARMOUR,
  41.     GIVEHEALTH,
  42.     GIVEWEAPON,
  43.     GOD,
  44.     HEALALL,
  45.     IMITATE,
  46.     IP,
  47.     KICK,
  48.     MAXAMMO,
  49.     PING,
  50.     SETLEVEL,
  51.     SETWANTED,
  52.     TBAN,
  53.     TIME,
  54.     WEATHER
  55. }
  56.  
  57. ////////////////////////////////////////////////////////////////////////////////
  58.  
  59.  
  60. new gPlayerInfo[MAX_PLAYERS][PLAYER_MAIN];
  61. new gSettings[SETTINGS_MAIN];
  62. new gCommands[COMMANDS_MAIN];
  63.  
  64. ////////////////////////////////////////////////////////////////////////////////
  65.  
  66. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  67. #define PlayerFile         "Administration/Users/%s.ini"
  68. #define SettingFile        "Administration/Settings/MainSettings.ini"
  69. #define CommandFile        "Administration/Settings/Commands.ini"
  70.  
  71. #define COLOUR_GREEN           0x33AA33AA
  72. #define COLOUR_RED             0xAA3333AA
  73. #define COLOUR_YELLOW          0xFFFF00AA
  74. #define COLOUR_LIGHTBLUE       0x33CCFFAA
  75. #define COLOUR_ORANGE          0xFF9900AA
  76.  
  77. ////////////////////////////////////////////////////////////////////////////////
  78.  
  79. #pragma unused ret_memcpy
  80.  
  81. ////////////////////////////////////////////////////////////////////////////////
  82.  
  83. public OnFilterScriptInit()
  84. {
  85.     print("\n********************************************");
  86.     print("* Admin Filterscript Loaded! by Jack_Nitch *");
  87.     print("********************************************\n");
  88.    
  89.     if(!fexist(SettingFile))
  90.     {
  91.     dini_Create(SettingFile);
  92.     dini_IntSet(SettingFile, "PocketMoney", 3000);
  93.     dini_IntSet(SettingFile, "JailCommands", 0);
  94.     dini_IntSet(SettingFile, "AnnounceSeconds", 3);
  95.     dini_IntSet(SettingFile, "PassMin", 3);
  96.     dini_IntSet(SettingFile, "PassMax", 15);
  97.     }
  98.  
  99.     gSettings[POCKET_MONEY]         = dini_Int(SettingFile, "PocketMoney");
  100.     gSettings[JAIL_COMMANDS]        = dini_Int(SettingFile, "JailCommands");
  101.     gSettings[ANNOUNCE_SECONDS]             = dini_Int(SettingFile, "AnnounceSeconds");
  102.     gSettings[PASS_MIN]             = dini_Int(SettingFile, "PassMin");
  103.     gSettings[PASS_MAX]             = dini_Int(SettingFile, "PassMax");
  104.  
  105.     if(!fexist(CommandFile))
  106.     {
  107.     dini_Create(CommandFile);
  108.     dini_IntSet(CommandFile, "Akill", 6);
  109.     dini_IntSet(CommandFile, "Announce", 5);
  110.     dini_IntSet(CommandFile, "Armourall", 3);
  111.     dini_IntSet(CommandFile, "Ban", 9);
  112.     dini_IntSet(CommandFile, "Carhp", 4);       dini_IntSet(CommandFile, "Explode", 5);
  113.     dini_IntSet(CommandFile, "Goto", 4);
  114.     dini_IntSet(CommandFile, "Gethere", 5);
  115.     dini_IntSet(CommandFile, "Givearmour", 6);
  116.     dini_IntSet(CommandFile, "Givehealth", 6);
  117.     dini_IntSet(CommandFile, "Giveweapon", 7);
  118.     dini_IntSet(CommandFile, "God", 10);
  119.     dini_IntSet(CommandFile, "Healall", 7);
  120.     dini_IntSet(CommandFile, "Imitate", 8);
  121.     dini_IntSet(CommandFile, "Ip", 2);
  122.     dini_IntSet(CommandFile, "Kick", 7);
  123.     dini_IntSet(CommandFile, "Maxammo", 8);
  124.     dini_IntSet(CommandFile, "Ping", 1);
  125.     dini_IntSet(CommandFile, "Setlevel", 10);
  126.     dini_IntSet(CommandFile, "Setwanted", 6);
  127.     dini_IntSet(CommandFile, "Tban", 9);
  128.     dini_IntSet(CommandFile, "Time", 3);
  129.     dini_IntSet(CommandFile, "Weather", 3);
  130.     }
  131.  
  132.     gCommands[AKILL]            = dini_Int(CommandFile, "Akill");
  133.     gCommands[ANNOUNCE]                 = dini_Int(CommandFile, "Announce");
  134.     gCommands[ARMOURALL]            = dini_Int(CommandFile, "Armourall");
  135.     gCommands[BAN]              = dini_Int(CommandFile, "Ban");
  136.     gCommands[CARHP]            = dini_Int(CommandFile, "Carhp");
  137.     gCommands[EXPLODE]          = dini_Int(CommandFile, "Explode");
  138.     gCommands[GOTO]             = dini_Int(CommandFile, "Goto");
  139.     gCommands[GETHERE]          = dini_Int(CommandFile, "Gethere");
  140.     gCommands[GIVEARMOUR]           = dini_Int(CommandFile, "Givearmour");
  141.     gCommands[GIVEHEALTH]           = dini_Int(CommandFile, "Givehealth");
  142.     gCommands[GIVEWEAPON]           = dini_Int(CommandFile, "Giveweapon");
  143.     gCommands[GOD]              = dini_Int(CommandFile, "God");
  144.     gCommands[HEALALL]          = dini_Int(CommandFile, "Healall");
  145.     gCommands[IMITATE]          = dini_Int(CommandFile, "Imitate");
  146.     gCommands[IP]               = dini_Int(CommandFile, "Ip");
  147.     gCommands[KICK]             = dini_Int(CommandFile, "Kick");
  148.     gCommands[MAXAMMO]          = dini_Int(CommandFile, "Maxammo");
  149.     gCommands[SETLEVEL]             = dini_Int(CommandFile, "Setlevel");
  150.     gCommands[SETWANTED]            = dini_Int(CommandFile, "Setwanted");
  151.     gCommands[TBAN]             = dini_Int(CommandFile, "Tban");
  152.     gCommands[TIME]             = dini_Int(CommandFile, "Time");
  153.     gCommands[WEATHER]          = dini_Int(CommandFile, "Weather");
  154.     return 1;
  155.     }
  156.  
  157. public OnFilterScriptExit()
  158. {
  159.     return 1;
  160. }
  161.  
  162. #else
  163.  
  164. main()
  165. {
  166.     print("\n----------------------------------");
  167.     print(" Blank Gamemode by your name here");
  168.     print("----------------------------------\n");
  169. }
  170.  
  171. #endif
  172.  
  173. public OnGameModeInit()
  174. {
  175.     return 1;
  176. }
  177.  
  178. public OnGameModeExit()
  179. {
  180.     return 1;
  181. }
  182.  
  183. public OnPlayerRequestClass(playerid, classid)
  184. {
  185.     return 1;
  186. }
  187.  
  188. public OnPlayerConnect(playerid)
  189. {
  190.     new file[100],Name[MAX_PLAYER_NAME],Ip[16];
  191.     GetPlayerName(playerid,Name,sizeof(Name));
  192.     GetPlayerIp(playerid,Ip,sizeof(Ip));
  193.     format(file,sizeof(file),PlayerFile,Name);
  194.  
  195.     if(!dini_Exists(file))
  196.         {
  197.     dini_Create(file);
  198.     dini_Set(file,"Name",Name);
  199.     dini_Set(file,"Ip",Ip);
  200.     dini_IntSet(file,"Registered",-1);
  201.     dini_IntSet(file,"Password",0);
  202.     dini_IntSet(file,"Level",0);
  203.     dini_IntSet(file,"Wired",0);
  204.     dini_IntSet(file,"Jailed",0);
  205.     SendClientMessage(playerid,COLOUR_ORANGE,"Your username is not recognized on this server. Please /register to continue.");
  206.     }
  207.     strcat(gPlayerInfo[playerid][PLAYER_NAME],          dini_Get(file,"Name"));
  208.     strcat(gPlayerInfo[playerid][PLAYER_IP],            dini_Get(file,"Ip"));
  209.     gPlayerInfo[playerid][PLAYER_REGGED]                  = dini_Int(file,"Registered");
  210.     gPlayerInfo[playerid][PLAYER_PASS]                            = dini_Int(file,"Password");
  211.     gPlayerInfo[playerid][PLAYER_LEVEL]                   = dini_Int(file,"Level");
  212.     gPlayerInfo[playerid][PLAYER_WIRED]                           = dini_Int(file,"Wired");
  213.     gPlayerInfo[playerid][PLAYER_JAILED]                  = dini_Int(file,"Jailed");
  214.     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.");
  215.     else if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)              SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server. Please /login to continue.");
  216.     gPlayerInfo[playerid][PLAYER_REGGED]                          = 0;
  217.     return 1;
  218. }
  219.  
  220. public OnPlayerDisconnect(playerid, reason)
  221. {
  222.     new file[100];
  223.     format(file,sizeof(file),PlayerFile,gPlayerInfo[playerid][PLAYER_NAME]);
  224.     dini_Set(file,"Name",gPlayerInfo[playerid][PLAYER_NAME]);
  225.     dini_Set(file,"Ip",gPlayerInfo[playerid][PLAYER_IP]);
  226.     dini_IntSet(file,"Registered",gPlayerInfo[playerid][PLAYER_REGGED]);
  227.     dini_IntSet(file,"Password",gPlayerInfo[playerid][PLAYER_PASS]);
  228.     dini_IntSet(file,"Level",gPlayerInfo[playerid][PLAYER_LEVEL]);
  229.     dini_IntSet(file,"Wired",gPlayerInfo[playerid][PLAYER_WIRED]);
  230.     dini_IntSet(file,"Jailed",gPlayerInfo[playerid][PLAYER_JAILED]);
  231.     gPlayerInfo[playerid][PLAYER_NAME]   = 0;
  232.     gPlayerInfo[playerid][PLAYER_IP]     = 0;
  233.     gPlayerInfo[playerid][PLAYER_REGGED] = 0;
  234.     gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
  235.     gPlayerInfo[playerid][PLAYER_PASS]   = 0;
  236.     gPlayerInfo[playerid][PLAYER_LEVEL]  = 0;
  237.     gPlayerInfo[playerid][PLAYER_WIRED]  = 0;
  238.     gPlayerInfo[playerid][PLAYER_JAILED] = 0;
  239.     return 1;
  240. }
  241.  
  242. public OnPlayerSpawn(playerid)
  243. {
  244.     return 1;
  245. }
  246.  
  247. public OnPlayerDeath(playerid, killerid, reason)
  248. {
  249.     return 1;
  250. }
  251.  
  252. public OnVehicleSpawn(vehicleid)
  253. {
  254.     return 1;
  255. }
  256.  
  257. public OnVehicleDeath(vehicleid, killerid)
  258. {
  259.     return 1;
  260. }
  261.  
  262. public OnPlayerText(playerid, text[])
  263. {
  264.     return 1;
  265. }
  266.  
  267. public OnPlayerCommandText(playerid, cmdtext[])
  268. {
  269.     dcmd(register, 8, cmdtext);
  270.     dcmd(login, 5, cmdtext);
  271.     dcmd(logout, 6, cmdtext);
  272.     dcmd(password, 8, cmdtext);
  273.  
  274.     return 0;
  275. }
  276.  
  277. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  278. {
  279.     return 1;
  280. }
  281.  
  282. public OnPlayerExitVehicle(playerid, vehicleid)
  283. {
  284.     return 1;
  285. }
  286.  
  287. public OnPlayerStateChange(playerid, newstate, oldstate)
  288. {
  289.     return 1;
  290. }
  291.  
  292. public OnPlayerEnterCheckpoint(playerid)
  293. {
  294.     return 1;
  295. }
  296.  
  297. public OnPlayerLeaveCheckpoint(playerid)
  298. {
  299.     return 1;
  300. }
  301.  
  302. public OnPlayerEnterRaceCheckpoint(playerid)
  303. {
  304.     return 1;
  305. }
  306.  
  307. public OnPlayerLeaveRaceCheckpoint(playerid)
  308. {
  309.     return 1;
  310. }
  311.  
  312. public OnRconCommand(cmd[])
  313. {
  314.     return 1;
  315. }
  316.  
  317. public OnPlayerRequestSpawn(playerid)
  318. {
  319.     return 1;
  320. }
  321.  
  322. public OnObjectMoved(objectid)
  323. {
  324.     return 1;
  325. }
  326.  
  327. public OnPlayerObjectMoved(playerid, objectid)
  328. {
  329.     return 1;
  330. }
  331.  
  332. public OnPlayerPickUpPickup(playerid, pickupid)
  333. {
  334.     return 1;
  335. }
  336.  
  337. public OnVehicleMod(playerid, vehicleid, componentid)
  338. {
  339.     return 1;
  340. }
  341.  
  342. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  343. {
  344.     return 1;
  345. }
  346.  
  347. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  348. {
  349.     return 1;
  350. }
  351.  
  352. public OnPlayerSelectedMenuRow(playerid, row)
  353. {
  354.     return 1;
  355. }
  356.  
  357. public OnPlayerExitedMenu(playerid)
  358. {
  359.     return 1;
  360. }
  361.  
  362. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  363. {
  364.     return 1;
  365. }
  366.  
  367. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  368. {
  369.     return 1;
  370. }
  371.  
  372. public OnRconLoginAttempt(ip[], password[], success)
  373. {
  374.     return 1;
  375. }
  376.  
  377. public OnPlayerUpdate(playerid)
  378. {
  379.     return 1;
  380. }
  381.  
  382. public OnPlayerStreamIn(playerid, forplayerid)
  383. {
  384.     return 1;
  385. }
  386.  
  387. public OnPlayerStreamOut(playerid, forplayerid)
  388. {
  389.     return 1;
  390. }
  391.  
  392. public OnVehicleStreamIn(vehicleid, forplayerid)
  393. {
  394.     return 1;
  395. }
  396.  
  397. public OnVehicleStreamOut(vehicleid, forplayerid)
  398. {
  399.     return 1;
  400. }
  401.  
  402. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  403. {
  404.     return 1;
  405. }
  406.  
  407. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  408. {
  409.     return 1;
  410. }
  411.  
  412. dcmd_register(playerid, params[])
  413. {
  414.     if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)
  415.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You have already registered!");
  416.     else if(!params[0])
  417.     return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /register [password]");
  418.     else if(strlen(params) < gSettings[PASS_MIN] || strlen(params) > gSettings[PASS_MAX])
  419.     {
  420.     new string[128];
  421.     format(string, sizeof(string), "ERROR: Password must be between %d and $d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
  422.     return SendClientMessage(playerid, COLOUR_ORANGE, string);
  423.     }
  424.     else
  425.     {
  426.     new password = num_hash(params);
  427.     gPlayerInfo[playerid][PLAYER_PASS] = password;
  428.     gPlayerInfo[playerid][PLAYER_REGGED] = 1;
  429.     gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
  430.     GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
  431.     new string[128]; format(string, sizeof(string), "You have successfully registered your account. You have been automatically logged in.", params);
  432.     return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  433.     }
  434. }
  435.  
  436. dcmd_login(playerid, params[])
  437. {
  438.     if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  439.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
  440.     else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 1)
  441.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged in.");
  442.     else if(!params[0])
  443.     return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /login [password]");
  444.     else
  445.     {
  446.     new password = num_hash(params);
  447.     if(gPlayerInfo[playerid][PLAYER_PASS] == password)
  448.     {
  449.     gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
  450.     GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
  451.     return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged in to your account.");
  452.     }
  453.     else
  454.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  455.     }
  456. }
  457.  
  458. dcmd_password(playerid, params[])
  459. {
  460.     if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  461.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must registered first to do that! Use /register [password] to register and login.");
  462.     else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
  463.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must be logged in to do that! Use /login [password] to login.");
  464.     else
  465.     {
  466.     new tmp[256], tmp2[256],
  467.         index;
  468.     tmp = strtok(params, index);
  469.     if(!strlen(tmp))
  470.     return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
  471.     tmp2 = strtok(params, index);
  472.     if(!strlen(tmp2))
  473.     return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
  474.     new oldpassword = num_hash(tmp), newpassword = num_hash(tmp2);
  475.     if(gPlayerInfo[playerid][PLAYER_PASS] == oldpassword)
  476.     {
  477.     if(oldpassword == newpassword)
  478.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Your old password cannot be the same as your new password.");
  479.     else if(strlen(tmp2) < gSettings[PASS_MIN] || strlen(tmp2) > gSettings[PASS_MAX])
  480.     {
  481.     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]);
  482.     return SendClientMessage(playerid, COLOUR_ORANGE, string);
  483.     }
  484.     gPlayerInfo[playerid][PLAYER_PASS] = newpassword;
  485.     new string[128]; format(string, sizeof(string), "You have successfully changed your password.", tmp, tmp2);
  486.     return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  487.     }
  488.     else
  489.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  490.     }
  491. }
  492.  
  493. dcmd_logout(playerid, params[])
  494. {
  495. #pragma unused params
  496.     if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
  497.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register.");
  498.     else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
  499.     return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-out.");
  500.     else
  501.     {
  502.     gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
  503.     return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged out of your account.");
  504.     }
  505. }
Advertisement
Add Comment
Please, Sign In to add comment