Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * AdminWarnings Plugin.
- * This Plugin Built By koko.
- * Please DO NOT Change The Credit.
- */
- #include <amxmodx>
- #include <amxmisc>
- #include <fvault>
- #define GIVEACCESS ADMIN_IMMUNITY
- #define CommunityName "koko"
- new warnings[33];
- new const szVaultName[] = "Warnings_Vault";
- public plugin_init() {
- register_plugin("Admin Warnings", "1.0", "koko")
- register_clcmd("say", "AddNTakeWarnings");
- register_clcmd("say", "ShowWarnings");
- register_clcmd("say /mywarnings", "MyWarnings");
- }
- public client_connect(id)
- {
- Load(id);
- }
- public client_disconnect(id)
- {
- Save(id);
- }
- public AddNTakeWarnings(id)
- {
- new Message[192], Cmd[33], Amount[33], HisName[33];
- read_args(Message, 191);
- remove_quotes(Message);
- parse(Message, Cmd, 32, HisName, 32, Amount, 32);
- // Add Warnings
- if(equali(Cmd, "/addwarning") || equali(Cmd, "/addwarnings") || equali(Cmd, "/givewarnings") || equali(Cmd, "/givewarning"))
- {
- new AddPlayer = cmd_target(AddPlayer, HisName, 8);
- if(equali(HisName, ""))
- {
- ColorChat(id, "^4Sytax: ^1<admin name> <amount>");
- return 1;
- }
- if(!AddPlayer)
- {
- ColorChat(id, "^1This player ^4was not ^1found.");
- return 1;
- }
- if(AddPlayer == id)
- {
- ColorChat(id, "^1You ^4cannot ^1add warnings to yourself.");
- return 1;
- }
- if(!(get_user_flags(AddPlayer) & ADMIN_CHAT))
- {
- ColorChat(id, "^1This player ^4is not ^1a admin.");
- return 1;
- }
- new ChatAmount = str_to_num(Amount)
- if(ChatAmount > 5)
- {
- ColorChat(id, "^1max warnings ^4is^1 5.");
- return 1;
- }
- if(AddPlayer && ChatAmount)
- {
- ColorChat(0, "^1%s ^4just added ^1to %s^4 %i warnings.", GetName(id), GetName(AddPlayer), ChatAmount);
- warnings[AddPlayer] += ChatAmount;
- if(warnings[AddPlayer] > 5)
- warnings[AddPlayer] = 5;
- if(warnings[AddPlayer] == 5)
- {
- ColorChat(0, "^4%s ^1just got his^4 5 warnings^1, and now he ^4dont have ^1admin anymore.", GetName(AddPlayer));
- new Flags = get_user_flags(AddPlayer)
- remove_user_flags(AddPlayer, Flags)
- warnings[AddPlayer] = 0;
- return 1;
- }
- Save(AddPlayer);
- return 1;
- }
- else if(AddPlayer)
- {
- ColorChat(id, "^1You ^4must ^1type amount.");
- return 1;
- }
- }
- // Remove Warnings
- if(equali(Cmd, "/removewarning") || equali(Cmd, "/removewarnings") || equali(Cmd, "/takewarnings") || equali(Cmd, "/takewarnings"))
- {
- new TakePlayer = cmd_target(TakePlayer, HisName, 8);
- if(equali(HisName, ""))
- {
- ColorChat(id, "^4Sytax: ^1<admin name> <amount>");
- return 1;
- }
- if(!TakePlayer)
- {
- ColorChat(id, "^1This player ^4was not ^1found.");
- return 1;
- }
- if(TakePlayer == id)
- {
- ColorChat(id, "^1You ^4cannot ^1remove warnings to yourself.");
- return 1;
- }
- if(!(get_user_flags(TakePlayer) & ADMIN_CHAT))
- {
- ColorChat(id, "^1This player ^4is not ^1a admin.");
- return 1;
- }
- new ChatAmount = str_to_num(Amount)
- if(ChatAmount > 5)
- {
- ColorChat(id, "^1You must remove ^4at least^1 5 warnings.");
- return 1;
- }
- if(warnings[id] == 0)
- {
- ColorChat(id, "^1This player ^4dont have ^1warnings.");
- return 1;
- }
- if(TakePlayer && ChatAmount)
- {
- ColorChat(0, "^1%s ^4just removed ^1to %s^4 %i warnings.", GetName(id), GetName(TakePlayer), ChatAmount);
- warnings[TakePlayer] -= ChatAmount;
- if(warnings[TakePlayer] < 0)
- warnings[TakePlayer] = 0;
- Save(TakePlayer);
- return 1;
- }
- else if(TakePlayer)
- {
- ColorChat(id, "^1You ^4must ^1type amount.");
- return 1;
- }
- }
- return 0;
- }
- public ShowWarnings(id)
- {
- new Message[192], Cmd[33], HisName[33];
- read_args(Message, 191);
- remove_quotes(Message);
- parse(Message, Cmd, 32, HisName, 32);
- // Add Warnings
- if(equali(Cmd, "/warning") || equali(Cmd, "/warnings"))
- {
- new ThePlayer = cmd_target(ThePlayer, HisName, 8);
- if(equali(HisName, ""))
- {
- ColorChat(id, "^4Sytax: ^1<admin name>");
- return 1;
- }
- if(!ThePlayer)
- {
- ColorChat(id, "^1This player ^4was not ^1found.");
- return 1;
- }
- if(ThePlayer == id)
- {
- ColorChat(id, "^1type ^4/mywarnings^1.");
- return 1;
- }
- if(!(get_user_flags(ThePlayer) & ADMIN_CHAT))
- {
- ColorChat(id, "^1This player ^4is not ^1a admin.");
- return 1;
- }
- if(ThePlayer)
- {
- ColorChat(id, "^1%s have^4 %i ^1warnings.", GetName(ThePlayer), warnings[ThePlayer])
- return 1;
- }
- }
- return 0;
- }
- public MyWarnings(id)
- {
- if(!(get_user_flags(id) & ADMIN_CHAT))
- return 1;
- ColorChat(id, "^1You have^4 %i ^1warnings.", warnings[id]);
- return 1;
- }
- public Save(id)
- {
- new Steam[35], IP[22], bool:SteamUser, szData[32];
- get_user_authid(id, Steam, 35);
- if(equal(Steam, "STEAM_ID_LAN"))
- {
- SteamUser = true;
- get_user_ip(id, IP, 21);
- }
- formatex(szData, 31, "%i", warnings[id]);
- fvault_set_data(szVaultName, SteamUser ? IP : Steam, szData);
- }
- public Load(id)
- {
- new Steam[35], IP[22], bool:SteamUser, szData[32];
- get_user_authid(id, Steam, 35);
- if(equal(Steam, "STEAM_ID_LAN"))
- {
- SteamUser = true;
- get_user_ip(id, IP, 21);
- }
- new szwarnings[16];
- if(fvault_get_data(szVaultName, SteamUser ? IP : Steam, szData, 31))
- {
- parse(szData, szwarnings, 15);
- warnings[id] = str_to_num(szwarnings);
- }
- else
- {
- warnings[id] = 0;
- }
- }
- stock GetName(id)
- {
- static szName[33];
- get_user_name(id, szName, charsmax(szName));
- return szName;
- }
- stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...) {
- new msg[191], players[32], count = 1
- new Community[30];
- formatex(Community, charsmax(Community), "^3[%s] ", CommunityName);
- static len
- len = formatex(msg, charsmax(msg), Community)
- vformat(msg[len], charsmax(msg) - len, string, 3)
- if(id) players[0] = id
- else get_players(players,count,"ch")
- for (new i = 0; i < count; i++)
- {
- if(is_user_connected(players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i])
- write_byte(players[i])
- write_string(msg)
- message_end()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement