Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #define set_vip_flags(%1,%2) (g_vipflags[%1] |= (1<<(%2&31)))
- #define remove_vip_flags(%1,%2) (g_vipflags[%1] &= ~(1 <<(%2&31)))
- #define get_vip_flags(%1,%2) (g_vipflags[%1] & (1<<(%2&31)))
- #define vipcfgfile "vipcfg.ini"
- new g_vipflags[33];
- new Trie:g_vips;
- new logfile[128];
- new szFile[64];
- enum ( <<=1 )
- {
- VIP_FLAG_A = 1, // Flag "a"
- VIP_FLAG_B, // Flag "b"
- VIP_FLAG_C, // Flag "c"
- VIP_FLAG_D, // Flag "d"
- VIP_FLAG_E, // Flag "e"
- VIP_FLAG_F, // Flag "f"
- VIP_FLAG_G, // Flag "g"
- VIP_FLAG_H // Flag "h"
- }
- public plugin_init(){
- register_plugin("VIP Plugin","1.0","Hyuna & xControl");
- register_concmd("amx_addvip","cmd_addvip",ADMIN_RCON,"<name or steamid> <flags>",1);
- register_concmd("amx_reloadvips","cmd_reloadvips",ADMIN_RCON,"- Reload VIPs",1);
- register_clcmd("say /vip","check_vip");
- }
- public plugin_cfg(){
- get_time("vip_log_%d-%m-%Y.log",logfile,128);
- g_vips = TrieCreate();
- get_configsdir(szFile,63);
- format(szFile,63,"%s/%s",szFile,vipcfgfile);
- if (!file_exists(szFile))
- {
- write_file(szFile,"; Vip Config");
- write_file(szFile,"");
- write_file(szFile,"");
- write_file(szFile,"; Flags:");
- write_file(szFile,"; a - bla bla bla");
- write_file(szFile,"; b - bla bla bla");
- write_file(szFile,"; c - bla bla bla");
- write_file(szFile,"; d - bla bla bla");
- write_file(szFile,"; e - bla bla bla");
- write_file(szFile,"; f - bla bla bla");
- write_file(szFile,"; g - bla bla bla");
- write_file(szFile,"; h - bla bla bla");
- write_file(szFile,"");
- write_file(szFile,"");
- write_file(szFile,"; How to add vips?");
- write_file(szFile,"; ^"STEAMID^" ^"FLAGS^"");
- write_file(szFile,"");
- write_file(szFile,"; Example:");
- write_file(szFile,"; ^"STEAM_0:0:50958313^" ^"abcdefgh^"");
- }
- ReadVips(szFile);
- }
- public plugin_natives(){
- register_library("vips");
- register_native("get_vip_flags","_get_vip_flags");
- }
- public _get_vip_flags(plugin,params){
- new client = get_param(1);
- if (client < 1 || client > 32 || !is_user_connected(client))
- {
- log_error(AMX_ERR_NATIVE,"[Vips] Invaild player id %d",client);
- return -1;
- }
- return g_vipflags[client];
- }
- public client_authorized(client){
- static szID[35];
- get_user_authid(client,szID,charsmax(szID));
- if (TrieKeyExists(g_vips,szID))
- {
- new szKey[32];
- TrieGetString(g_vips,szID,szKey,31);
- set_vip_flags(client,read_flags(szKey));
- }
- else
- g_vipflags[client] = 0;
- }
- public check_vip(client){
- client_print(client,print_chat,"[AMXX] You are%s vip!",(g_vipflags[client] ? "":"n't"));
- if (g_vipflags[client])
- {
- new szFlags[16];
- get_flags(g_vipflags[client],szFlags,15);
- client_print(client,print_chat,"[AMXX] You'r flags: %s",szFlags);
- }
- }
- public cmd_addvip(client,level,cid){
- if(!cmd_access(client,level,cid,3))
- return 1;
- new szFlags[16],szID[35];
- read_argv(1,szID,34);
- read_argv(2,szFlags,15);
- remove_quotes(szID);
- remove_quotes(szFlags);
- if ((contain(szID,"STEAM_") == -1))
- {
- new player = cmd_target(client,szID,CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF);
- if (!player)
- return 1;
- if (!g_vipflags[client])
- return 1;
- get_user_authid(player,szID,34);
- set_vip_flags(player,read_flags(szFlags));
- }
- else if (contain(szID,"_ID_LAN") != -1 || contain(szID,"STEAM_0:4") != -1 || contain(szID,"VALVE") != -1 || equali(szID,"STEAM_666:88:666"))
- {
- console_print(client,"Error: Invaild SteamID!");
- return 1;
- }
- static some[128];
- formatex(some,127,"^"%s^" ^"%s^"",szID,szFlags);
- write_file(szFile,some);
- ReadVips(szFile);
- return 1;
- }
- public cmd_reloadvips(client,level,cid){
- if(!cmd_access(client,level,cid,1))
- return 1;
- ReadVips(szFile);
- return 1;
- }
- stock ReadVips(szFile[]){
- new cfg = fopen(szFile,"rt");
- if (!cfg)
- {
- new some[128];
- formatex(some,127,"Error openning config file (%s)",szFile);
- set_fail_state(some);
- }
- static szText[128],szID[35],szFlags[16];
- new totalvips;
- while(!feof(cfg))
- {
- fgets(cfg,szText,charsmax(szText));
- if (equali(szText,"") || szText[0] == ';' || szText[0] == '#' || (szText[0] == '/' && szText[1] == '/'))
- continue;
- remove_quotes(szText);
- parse(szText,szID,charsmax(szID),szFlags,charsmax(szFlags));
- if((contain(szID,"STEAM_") == -1) || contain(szID,"_ID_LAN") != -1 || contain(szID,"STEAM_0:4") != -1 || contain(szID,"VALVE") != -1 || equali(szID,"STEAM_666:88:666"))
- {
- log_to_file(logfile,"ERROR: Failed to load VIP: %s isn't an vaild steamid!",szID);
- continue;
- }
- TrieSetString(g_vips,szID,szFlags);
- log_to_file(logfile,"VIP Loaded: SteamID: %s | Flags: %s",szID,szFlags);
- totalvips++;
- }
- log_to_file(logfile,"Total vips loaded: %d",totalvips);
- fclose(cfg);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement