Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Peace keeper System by Usman Memon aka Areeb */
- #include <a_samp>
- #include <dini>
- #include <zcmd>
- #include <foreach>
- #include <sscanf2>
- // COLORS //
- #define COLOR_ORANGE 0xFF9900FF
- #define COLOR_YELLOW 0xFFFF00FF
- #define COLOR_WHITE 0xFFFFFFFF
- #define COLOR_ERROR 0xFF0000FF
- // Path of pk file //
- #define FILE_PK "peacekeeper/%s.ini"
- new pklvl[MAX_PLAYERS];
- new pkpm[MAX_PLAYERS];
- new pkicktimer[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Peace Keeper System by Usman");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new pname[MAX_PLAYER_NAME], filepk[MAX_PLAYERS];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(filepk, sizeof(filepk), FILE_PK, pname);
- pklvl[playerid] = dini_Int(filepk, "pklvl");
- if(!fexist(filepk))
- {
- dini_Create(filepk);
- dini_IntSet(filepk, "pklvl", 0);
- }
- pklvl[playerid] = dini_Int(filepk, "pklvl");
- pkpm[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new pname[MAX_PLAYER_NAME], filepk[MAX_PLAYERS];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(filepk, sizeof(filepk), FILE_PK, pname);
- dini_IntSet(filepk, "pklvl", pklvl[playerid]);
- pklvl[playerid] = 0;
- return 1;
- }
- CMD:setpeacekeeper(playerid, params[])
- {
- if (!IsPlayerAdmin(playerid)) return 0;
- new giveplayerid, moneys1, giveplayer[25], playername[25], string[256], filepk[MAX_PLAYERS];
- if (sscanf(params, "ud", giveplayerid, moneys1)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /setpeacekeeper [playerid] [0 = not Peace keeper, 1 = peace keeper]");
- if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "Error: Inactive player id!");
- if (moneys1 < 0 || moneys1 > 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: Invalid peacekeeper level.");
- GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
- if (moneys1 == pklvl[giveplayerid])
- {
- format(string, 64, "%s is already peacekeeper level %d.", giveplayer, moneys1);
- SendClientMessage(playerid, COLOR_WHITE, string);
- return 1;
- }
- GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
- if (moneys1 == 0)
- {
- pklvl[giveplayerid] = 0;
- format(filepk, sizeof(filepk), FILE_PK, giveplayer);
- dini_IntSet(filepk, "pklvl", 0);
- SendClientMessage(playerid, -1, "You have been remove from peacekeeper");
- }
- else
- {
- pklvl[giveplayerid] = 1;
- format(filepk, sizeof(filepk), FILE_PK, giveplayer);
- dini_IntSet(filepk, "pklvl", 1);
- format(string, 64, "You have been set as peacekeeper.");
- SendClientMessage(giveplayerid, COLOR_YELLOW, string);
- format(string, 64, "You have set %s as peacekeeper.", giveplayer);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- }
- return 1;
- }
- CMD:pkcmds(playerid, params[])
- {
- if(pklvl[playerid] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not peace keeper.");
- SendClientMessage(playerid, COLOR_ORANGE, "~Peace Keeper Command");
- SendClientMessage(playerid, COLOR_WHITE, "/pgoto, /pget, /pksay, /pkc, /pkpm, /pkkick");
- return 1;
- }
- CMD:pkc(playerid, params[])
- {
- new tmp[256], playername[25], string[256];
- if (pklvl[playerid] < 1) return 0;
- if (sscanf(params, "s[128]", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pkc [message]");
- GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
- format(string, sizeof(string), "{FF9900}PeaceKeeper Chat [%s] %s", playername, tmp);
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i) && pklvl[i])
- {
- if(pklvl[playerid] == 1) SendClientMessage(i, -1, string);
- }
- }
- return 1;
- }
- CMD:pksay(playerid, params[])
- {
- new tmp[256], playername[25], string[256];
- if (pklvl[playerid] < 1) return 0;
- if (sscanf(params, "s[128]", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pksay [message]");
- GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
- format(string, sizeof(string), "* {FF9900}Peacekeeper {FFFFFF}- %s: %s", playername, tmp);
- SendClientMessageToAll(COLOR_WHITE, string);
- return 1;
- }
- CMD:pks(playerid,params[])
- {
- SendClientMessage(playerid, COLOR_ORANGE, "Current Peace Keepers Online..");
- new count=0;
- new string[256], pname[MAX_PLAYER_NAME];
- foreach(Player, i){
- if (IsPlayerConnected(i)){
- if (pklvl[i] == 1){
- GetPlayerName(i,pname,sizeof(pname));
- format(string, 128, "%s - ({FFCC00}Peace Keeper{FFFFFF})", pname);
- SendClientMessage(playerid, COLOR_WHITE, string);
- count++;}
- }
- }
- if(count==0)
- SendClientMessage(playerid, COLOR_WHITE,"There are currently no pk members online.");
- return 1;
- }
- CMD:pkpm(playerid, params[])
- {
- new tmp[256], giveplayerid, giveplayer[25], playername[25],string[256];
- if(pklvl[playerid] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not peace keeper.");
- GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
- if (sscanf(params, "us[128]", giveplayerid, tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pm [playerid] [message]");
- if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "Error: Inactive player id!");
- if (giveplayerid == playerid) return SendClientMessage(playerid, COLOR_ERROR, "Error: You can't send private message to your self!");
- GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
- GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
- format(string, sizeof(string), "PM received from %s(%d):{ffffff} %s", playername, playerid, tmp);
- SendClientMessage(giveplayerid, COLOR_YELLOW, string);
- format(string,sizeof(string), "{FFFF00}PM delivered to %s(%d):{ffffff} %s", giveplayer, giveplayerid, tmp);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- PlayerPlaySound(giveplayerid, 1056, 0.0, 0.0, 0.0);
- pkpm[giveplayerid] = 1;
- SetPVarInt(giveplayerid, "AdminId", playerid);
- SendClientMessage(giveplayerid, COLOR_YELLOW, "You can use /pmreply to reply peacekeeper.");
- return 1;
- }
- CMD:pmreply(playerid, params[])
- {
- new id = GetPVarInt(playerid, "AdminId");
- new tmp[256], str[256], name[MAX_PLAYER_NAME];
- if(pkpm[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "An admin didnt pm you to reply.");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_ERROR, "The admin that pmed you has CUTTOFF");
- if(sscanf(params, "s", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /areply [message]");
- GetPlayerName(playerid, name, sizeof(name));
- format(str, sizeof(str), "PM reply: {FFFFFF}%s.", tmp);
- SendClientMessage(playerid, COLOR_YELLOW, str);
- format(str, sizeof(str), "PM from %s(ID%d): {FFFFFF}%s.", name, playerid, tmp);
- SendClientMessage(id, COLOR_ERROR, str);
- pkpm[playerid] = 0;
- SetPVarInt(id, "AdminId", 0);
- return 1;
- }
- CMD:pkgoto(playerid, params[])
- {
- new giveplayerid, Float:gx, Float:gy, Float:gz, string[256];
- if(pklvl[playerid] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not peace keeper.");
- if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pkgoto [playerid]");
- if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "Error: Inactive player id!");
- new pname[MAX_PLAYER_NAME];
- GetPlayerName(giveplayerid, pname, sizeof(pname));
- GetPlayerPos(giveplayerid, gx, gy, gz);
- SetPlayerPos(playerid, gx, gy, gz+1);
- format(string, sizeof(string), "You have warped to player %s (Id%d).", pname, giveplayerid);
- SendClientMessage(playerid, COLOR_ORANGE , string);
- return 1;
- }
- CMD:pkget(playerid, params[])
- {
- new giveplayerid, Float:gx, Float:gy, Float:gz, string[256];
- if(pklvl[playerid] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not peace keeper.");
- if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pkget [playerid]");
- if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "Error: Inactive player id!");
- new pname[MAX_PLAYER_NAME];
- GetPlayerName(giveplayerid, pname, sizeof(pname));
- SetCameraBehindPlayer(giveplayerid);
- GetPlayerPos(playerid, gx, gy, gz);
- SetPlayerPos(giveplayerid, gx+2, gy+2, gz);
- SetPlayerInterior(giveplayerid, GetPlayerInterior(playerid));
- format(string, sizeof(string), "You have warped player %s (Id%d) to your position", pname, giveplayerid);
- SendClientMessage(playerid, COLOR_ORANGE, string);
- SendClientMessage(giveplayerid, COLOR_ORANGE , "An peacekeeper have warped you to his position.");
- return 1;
- }
- CMD:pkkick(playerid, params[])
- {
- if(pklvl[playerid] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not peace keeper.");
- new string[256], giveplayerid, resaon[256], pname[MAX_PLAYER_NAME];
- if (sscanf(params, "us[128]", giveplayerid, resaon)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pkkick [playerid] [resaon]");
- if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "Error: Inactive player id!");
- GetPlayerName(giveplayerid, pname, sizeof(pname));
- format(string, sizeof(string), "An admin has kicked player %s for %s", pname, resaon);
- SendClientMessageToAll(COLOR_ERROR, string);
- pkicktimer[giveplayerid] = SetTimerEx("KickBanTimer", 50, 0, "dd", giveplayerid, 1);
- return 1;
- }
- forward KickBanTimer(playerid, kickban);
- public KickBanTimer(playerid, kickban)
- {
- switch (kickban)
- {
- case 1: Kick(playerid);
- case 2: Ban(playerid);
- }
- KillTimer(pkicktimer[playerid]);
- pkicktimer[playerid] = 0;
- }
Add Comment
Please, Sign In to add comment