Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * bAdmin - Scripted by [RP]Brock.
- * Do not alter these credits, cause thats just stupid.
- *
- */
- #include <a_samp>
- #include <bDUDb>
- #define FILTERSCRIPT // remove this if adding this script into your gamemode
- #include <zcmd>
- #define SLOTS 5 // amount of slots your server has
- #define BAVERSION "1.1"
- #define BOTNAME "BrockBot"
- #define RCMD_PREFIX "/"
- #define rcmd(%1,%2,%3) if((strcmp((%3), RCMD_PREFIX #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (rcmd_%1(""))) || (((%3)[(%2) + 1] == 32) && (rcmd_%1((%3)[(%2) + 2]))))) return 1
- #define COLOUR_BAMSG 0xA9C4E4FF
- #define COLOUR_WHITE 0xFFFFFFFF
- #define COLOUR_RED 0xDC0000FF
- #define COLOUR_ACHAT 0xFAABFFFF
- #define COLOUR_ADM 0xC2C2C2FF
- #define COLOUR_YELLOW 0xFFFF00FF
- #define DIALOG_REGISTER 1
- #define DIALOG_LOGIN 2
- #define DIALOG_WEPS 3
- enum PlayerInfo
- {
- bLogged,
- bAdmin,
- bIsMuted,
- bSpec,
- bSkin,
- bMins,
- bHours
- }
- new PlayerData[SLOTS][PlayerInfo];
- new AdminRankNames[][]=
- {
- "Regular Player", "Moderator", "Junior Admin", "Senior Admin", "Server Owner"
- };
- forward sRestart();
- forward PlayingTime(playerid);
- public OnFilterScriptInit()
- {
- print("\n");
- print(" _ _ _ _ ");
- print("| |__ / \\ __| |_ __ ___ (_)_ __ ");
- print("| '_ \\ / _ \\ / _` | '_ ` _ \\| | '_ \\ ");
- print("| |_) / ___ \\ (_| | | | | | | | | | | ");
- print("|_.__/_/ \\_\\__,_|_| |_| |_|_|_| |_| ");
- printf("\n Loaded. v%s", BAVERSION);
- print("\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n");
- print(" _ _ _ _ ");
- print("| |__ / \\ __| |_ __ ___ (_)_ __ ");
- print("| '_ \\ / _ \\ / _` | '_ ` _ \\| | '_ \\ ");
- print("| |_) / ___ \\ (_| | | | | | | | | | | ");
- print("|_.__/_/ \\_\\__,_|_| |_| |_|_|_| |_| ");
- printf("\n Unloaded. v%s", BAVERSION);
- print("\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new JoinPlayer[MAX_PLAYER_NAME];
- new string[128], string2[128];
- GetPlayerName(playerid, JoinPlayer, sizeof(JoinPlayer));
- for(new i = 0; i < SLOTS; i++)
- {
- if (PlayerData[i][bAdmin] >= 1)
- {
- format(string, sizeof(string), "[JOINED] %s (IP: %s)", JoinPlayer, pIp(playerid));
- SendClientMessage(i, COLOUR_YELLOW, string);
- }
- else
- {
- format(string2, sizeof(string2), "[JOINED] %s", JoinPlayer);
- SendClientMessage(i, COLOUR_YELLOW ,string2);
- }
- }
- if(!udb_Exists(PlayerName(playerid)))
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Please register before continuing.", "Enter Password Below", "Register", "Cancel");
- return 1;
- }
- if(udb_Exists(PlayerName(playerid)))
- {
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Please login before continuing.", "Enter Password Below", "Login", "Cancel");
- return 1;
- }
- PlayerData[playerid][bAdmin] = 0;
- PlayerData[playerid][bSkin] = 1;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new string[128];
- switch(reason)
- {
- case 0: format(string, sizeof(string), "[TIMEOUT] %s", PlayerName(playerid));
- case 1: format(string, sizeof(string), "[LEFT] %s", PlayerName(playerid));
- case 2: format(string, sizeof(string), "[KICKED] %s", PlayerName(playerid));
- }
- SendClientMessageToAll(COLOUR_YELLOW, string);
- if(PlayerData[playerid][bLogged])
- {
- bUserSetINT(PlayerName(playerid)).("bAdmin", PlayerData[playerid][bAdmin]);
- bUserSetINT(PlayerName(playerid)).("bSkin", PlayerData[playerid][bSkin]);
- bUserSetINT(PlayerName(playerid)).("bMins", PlayerData[playerid][bMins]);
- bUserSetINT(PlayerName(playerid)).("bHours", PlayerData[playerid][bHours]);
- }
- PlayerData[playerid][bLogged] = 0;
- PlayerData[playerid][bSpec] = -1;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(PlayerData[playerid][bLogged] == 0)
- {
- SendClientMessage(playerid, COLOUR_RED, "You have been kicked for not logging in!");
- return Kick(playerid);
- }
- SetPlayerSkin(playerid, PlayerData[playerid][bSkin]);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if (killerid != INVALID_PLAYER_ID) return KillsLog(killerid, playerid);
- else return DeathsLog(playerid);
- }
- public OnPlayerText(playerid, text[])
- {
- if (PlayerData[playerid][bIsMuted] == 1 && PlayerData[playerid][bAdmin] < 1)
- {
- SendClientMessage(playerid, COLOUR_BAMSG, "ShoBot: You've been muted by an admin, you are unable to talk!");
- return 0;
- }
- ChatLog(playerid, text);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- return 0;
- }
- public OnRconCommand(cmd[])
- {
- rcmd(unmute, 6, cmd);
- rcmd(whois, 5, cmd);
- rcmd(kick, 4, cmd);
- rcmd(slap, 4, cmd);
- rcmd(mute, 4, cmd);
- rcmd(ann, 3, cmd);
- rcmd(explode, 7, cmd);
- rcmd(setskin, 7, cmd);
- rcmd(akill, 5, cmd);
- rcmd(ban, 3, cmd);
- rcmd(rename, 6, cmd);
- rcmd(setweather, 10, cmd);
- rcmd(setarmour, 9, cmd);
- rcmd(sethealth, 9, cmd);
- rcmd(setvw, 5, cmd);
- rcmd(restart, 7, cmd);
- rcmd(banip, 5, cmd);
- rcmd(unbanip, 7, cmd);
- rcmd(makeadmin, 9, cmd);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_REGISTER)
- {
- if(udb_Create(PlayerName(playerid),inputtext))
- return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Please login before continuing.", "Enter Password Below", "Login", "Cancel");
- }
- if(dialogid == DIALOG_LOGIN)
- {
- if(!udb_CheckLogin(PlayerName(playerid), inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Please login before continuing.", "Enter Password Below", "Login", "Cancel");
- if(strlen(inputtext) < 1) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Please login before continuing.", "Enter Password Below", "Login", "Cancel");
- PlayerData[playerid][bAdmin] = (bUserINT(PlayerName(playerid)).("bAdmin"));
- PlayerData[playerid][bSkin] = (bUserINT(PlayerName(playerid)).("bSkin"));
- PlayerData[playerid][bMins] = (bUserINT(PlayerName(playerid)).("bMins"));
- PlayerData[playerid][bHours] = (bUserINT(PlayerName(playerid)).("bHours"));
- PlayerData[playerid][bLogged] = 1;
- PlayerData[playerid][bSpec] = -1;
- PlayerData[playerid][bIsMuted] = 0;
- SetTimerEx("PlayingTime", 60000, 1, "i", playerid);
- return 1;
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- COMMAND:admins(playerid, params[])
- {
- new C = 0;
- SendClientMessage(playerid, COLOUR_BAMSG, "__________________| Online Admins |__________________");
- for(new i = 0; i < SLOTS; i++)
- {
- if (IsPlayerConnected(i))
- {
- if(PlayerData[i][bAdmin] >= 1 && PlayerData[i][bAdmin] <= 4)
- {
- new string[128];
- format(string, sizeof(string), "> %s %s", AdminRankNames[PlayerData[i][bAdmin]], PlayerName(i));
- SendClientMessage(playerid, COLOUR_WHITE, string);
- C++;
- }
- }
- }
- if (C == 0) SendClientMessage(playerid, COLOUR_RED, BOTNAME ": There are no admins online!");
- return 1;
- }
- COMMAND:acmds(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 1) return 0;
- else if (PlayerData[playerid][bAdmin] == 1)
- {
- new string[128];
- format(string, sizeof(string), "__________________| bAdmin %s commands |__________________", AdminRankNames[PlayerData[playerid][bAdmin]]);
- SendClientMessage(playerid, COLOUR_BAMSG, string);
- SendClientMessage(playerid, COLOUR_WHITE, "> /(un)mute [id], /whois [id], /kick [id] [reason], /slap [id], /goto [id], /get [id], /adm [text]");
- SendClientMessage(playerid, COLOUR_WHITE, "> /ann [text], /spec [id]");
- return 1;
- }
- else if (PlayerData[playerid][bAdmin] == 2)
- {
- new string[128];
- format(string, sizeof(string), "__________________| bAdmin %s commands |__________________", AdminRankNames[PlayerData[playerid][bAdmin]]);
- SendClientMessage(playerid, COLOUR_BAMSG, string);
- SendClientMessage(playerid, COLOUR_WHITE, "> /(un)mute [id], /whois [id], /kick [id] [reason], /slap [id], /goto [id], /get [id], /adm [text]");
- SendClientMessage(playerid, COLOUR_WHITE, "> /ann [text], /spec [id], /ban [id] [reason], /explode [id], /setskin [id] [skinid], /akill [id]");
- SendClientMessage(playerid, COLOUR_WHITE, "> /rename [id] [name]");
- return 1;
- }
- else if (PlayerData[playerid][bAdmin] == 3)
- {
- new string[128];
- format(string, sizeof(string), "__________________| bAdmin %s commands |__________________", AdminRankNames[PlayerData[playerid][bAdmin]]);
- SendClientMessage(playerid, COLOUR_BAMSG, string);
- SendClientMessage(playerid, COLOUR_WHITE, "> /(un)mute [id], /whois [id], /kick [id] [reason], /slap [id], /goto [id], /get [id], /adm [text]");
- SendClientMessage(playerid, COLOUR_WHITE, "> /ann [text], /spec [id], /ban [id] [reason], /explode [id], /setskin [id] [skinid], /akill [id]");
- SendClientMessage(playerid, COLOUR_WHITE, "> /rename [id] [name] /setweather [weatherid], /sethealth [id] [amount], /setarmour [id] [amount]");
- SendClientMessage(playerid, COLOUR_WHITE, "> /setvw [id] [vwid], /restart [reason], /banip [*.*.*.*], /unbanip [*.*.*.*]");
- return 1;
- }
- else if (PlayerData[playerid][bAdmin] == 4)
- {
- new string[128];
- format(string, sizeof(string), "__________________| bAdmin %s commands |__________________", AdminRankNames[PlayerData[playerid][bAdmin]]);
- SendClientMessage(playerid, COLOUR_BAMSG, string);
- SendClientMessage(playerid, COLOUR_WHITE, "> /(un)mute [id], /whois [id], /kick [id] [reason], /slap [id], /goto [id], /get [id], /adm [text]");
- SendClientMessage(playerid, COLOUR_WHITE, "> /ann [text], /spec [id], /ban [id] [reason], /explode [id], /setskin [id] [skinid], /akill [id]");
- SendClientMessage(playerid, COLOUR_WHITE, "> /rename [id] [name], /setweather [weatherid], /sethealth [id] [amount], /setarmour [id] [amount]");
- SendClientMessage(playerid, COLOUR_WHITE, "> /setvw [id] [vwid], /restart [reason], /banip [*.*.*.*], /unbanip [*.*.*.*], /makeadmin [id] [level]");
- return 1;
- }
- return 1;
- }
- // Level 1 cmds
- COMMAND:kick(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 1) return 0;
- new pid, reason[128];
- if (sscanf(params, "us", pid, reason)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /kick [id] [reason]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has kicked %s from the server (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), reason);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": %s %s kicked %s from the server (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), reason);
- Kick(pid);
- }
- return 1;
- }
- COMMAND:whois(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 1) return 0;
- new pid;
- if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /whois [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- new string[128], string2[128];
- new Float:health, Float:armour;
- GetPlayerHealth(pid,health);
- GetPlayerArmour(pid,armour);
- format(string, sizeof(string), BOTNAME ": [WHOIS: %s %s]", AdminRankNames[PlayerData[pid][bAdmin]], PlayerName(pid));
- SendClientMessage(playerid, COLOUR_WHITE, string);
- format(string2, sizeof(string2), "@| Cash: %d, Health: %0.1f, Armour: %0.1f, IP: %s, Ping: %d, Skin: %d, Time Online: %s hours and %s minutes", GetPlayerMoney(pid), health, armour, pIp(pid), GetPlayerPing(pid), GetPlayerSkin(pid), PlayerData[pid][bHours], PlayerData[pid][bMins]);
- SendClientMessage(playerid, COLOUR_WHITE, string2);
- }
- return 1;
- }
- COMMAND:mute(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 1) return 0;
- new pid;
- if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /mute [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has muted %s.", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- PlayerData[pid][bIsMuted] = 1;
- }
- return 1;
- }
- COMMAND:unmute(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 1) return 0;
- new pid;
- if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /unmute [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has unmuted %s.", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- PlayerData[pid][bIsMuted] = 0;
- }
- return 1;
- }
- COMMAND:slap(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 1) return 0;
- new pid;
- if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /slap [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- new string[128];
- new Float:pX, Float:pY, Float:pZ;
- GetPlayerPos(pid, pX, pY, pZ);
- SetPlayerPos(pid, pX, pY, pZ+5);
- format(string, sizeof(string), BOTNAME ": %s %s slapped %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": %s %s slapped %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- }
- return 1;
- }
- COMMAND:@(playerid, params[])
- {
- new string[256];
- if(PlayerData[playerid][bAdmin] >= 1)
- {
- format(string, sizeof(string), "Admin Chat | %s %s: %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), params);
- SendClientMessageToAdmin(COLOUR_ADM, string);
- }
- return 1;
- }
- COMMAND:ann(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 1) return 0;
- new msg[128];
- if (sscanf(params, "s", msg)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /ann [text]");
- else
- {
- GameTextForAll(msg, 3000, 5);
- }
- return 1;
- }
- COMMAND:goto(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 1) return 0;
- new pid;
- if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /goto [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- new Float:pX, Float:pY, Float:pZ;
- if (!IsPlayerInAnyVehicle(pid)) GetPlayerPos(pid, pX, pY, pZ);
- else GetVehiclePos( GetPlayerVehicleID(pid), pX, pY, pZ);
- if (!IsPlayerInAnyVehicle(playerid)) SetPlayerPos(playerid, pX+0.1, pY+0.1, pZ);
- else SetVehiclePos( GetPlayerVehicleID(playerid), pX, pY, pZ);
- SetPlayerInterior(playerid, GetPlayerInterior(pid));
- SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(pid));
- }
- return 1;
- }
- COMMAND:get(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 1) return 0;
- new pid;
- if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /get [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- new Float:pX, Float:pY, Float:pZ;
- if (!IsPlayerInAnyVehicle(playerid)) GetPlayerPos(pid, pX, pY, pZ);
- else GetVehiclePos( GetPlayerVehicleID(playerid), pX, pY, pZ);
- if (!IsPlayerInAnyVehicle(pid)) SetPlayerPos(pid, pX+0.1, pY+0.1, pZ);
- else SetVehiclePos( GetPlayerVehicleID(pid), pX, pY, pZ);
- SetPlayerInterior(pid, GetPlayerInterior(playerid));
- SetPlayerVirtualWorld(pid, GetPlayerVirtualWorld(playerid));
- }
- return 1;
- }
- COMMAND:spec(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 1) return 0;
- new pid;
- if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /spec [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- if (PlayerData[playerid][bSpec] != -1)
- {
- PlayerData[playerid][bSpec] = -1;
- TogglePlayerSpectating(playerid, 0);
- SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": You stopped spectating");
- return 1;
- }
- PlayerData[playerid][bSpec] = pid;
- TogglePlayerSpectating(playerid, 1);
- SetPlayerInterior(playerid, GetPlayerInterior(pid));
- SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(pid));
- if (IsPlayerInAnyVehicle(pid)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(pid));
- else PlayerSpectatePlayer(playerid, pid);
- new string[128];
- format(string, sizeof(string), BOTNAME ": You are now spectating %s", PlayerName(pid));
- SendClientMessage(playerid, COLOUR_BAMSG, string);
- }
- return 1;
- }
- // Level 2 cmds
- COMMAND:ban(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 2) return 0;
- new pid, reason[128];
- if (sscanf(params, "us", pid, reason)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /ban [id] [reason]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has banned %s from the server (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), reason);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": %s %s banned %s from the server (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), reason);
- Ban(pid);
- }
- return 1;
- }
- COMMAND:explode(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 2) return 0;
- new pid;
- if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /explode [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- new Float:pX, Float:pY, Float:pZ;
- if (IsPlayerInAnyVehicle(pid)) GetVehiclePos(GetPlayerVehicleID(pid), pX, pY, pZ);
- else GetPlayerPos(pid, pX, pY, pZ);
- CreateExplosion(pX, pY, pZ, 6, 20);
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has exploded %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- }
- return 1;
- }
- COMMAND:akill(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 2) return 0;
- new pid;
- if (sscanf(params, "u", pid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /akill [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has killed %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- SetPlayerHealth(pid, 0.0);
- }
- return 1;
- }
- COMMAND:setskin(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 2) return 0;
- new pid, skinid;
- if (sscanf(params, "ui", pid, skinid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /setskin [id] [skinid]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else if (skinid < 0 || skinid > 299 || IsInvalidSkin(skinid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Invalid Skin");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has changed %s's skin to ID: %i", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), skinid);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- SetPlayerSkin(pid, skinid);
- PlayerData[pid][bSkin] = skinid;
- printf(BOTNAME ": %s %s changed %s's skin to ID: %i", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), skinid);
- }
- return 1;
- }
- COMMAND:rename(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 2) return 0;
- new pid, name[24];
- if (sscanf(params, "us", pid, name)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /rename [id] [name]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has changed %s's name to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), name);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": %s %s changed %s's name to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), name);
- udb_RenameUser(PlayerName(pid), name);
- SetPlayerName(pid, name);
- }
- return 1;
- }
- // Level 3 cmds
- COMMAND:restart(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 3) return 0;
- new reason[128];
- if (sscanf(params, "s", reason)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /restart [reason]");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has initiated a server restart. (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), reason);
- SendClientMessageToAll(COLOUR_RED, string);
- printf(BOTNAME ": %s %s has initiated a server restart. (Reason: %s)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), reason);
- SetTimer("sRestart", 5000, 0);
- }
- return 1;
- }
- COMMAND:sethealth(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 3) return 0;
- new pid, health;
- if (sscanf(params, "ui", pid, health)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /sethealth [id] [amount]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else if (health < 0 || health > 100) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Amount must be between 0 & 100");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has changed %s's health", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": %s %s has changed %s's health", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- SetPlayerHealth(pid, health);
- }
- return 1;
- }
- COMMAND:setarmour(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 3) return 0;
- new pid, armour;
- if (sscanf(params, "ui", pid, armour)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /setarmour [id] [amount]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else if (armour < 0 || armour > 100) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Amount must be between 0 & 100");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has changed %s's armour", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": %s %s has changed %s's armour", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- SetPlayerArmour(pid, armour);
- }
- return 1;
- }
- COMMAND:setweather(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 3) return 0;
- new wid;
- if (sscanf(params, "i", wid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /setweather [weatherid]");
- else if (wid < 0) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Amount must be above 0");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has set the weather to ID: %d", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), wid);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": %s %s has set the weather to ID: %d", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), wid);
- SetWeather(wid);
- }
- return 1;
- }
- COMMAND:banip(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 3) return 0;
- new bip[16];
- if (sscanf(params, "s", bip)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /banip [*.*.*.*]");
- else
- {
- new string[128];
- format(string, sizeof(string), "banip %s", bip);
- SendRconCommand(string);
- format(string, sizeof(string), BOTNAME ": You banned the IP: %s", bip);
- SendClientMessage(playerid, COLOUR_WHITE, string );
- }
- return 1;
- }
- COMMAND:unbanip(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 3) return 0;
- new ubip[16];
- if (sscanf(params, "s", ubip)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /unbanip [*.*.*.*]");
- else
- {
- new string[128];
- format(string, sizeof(string), "unbanip %s", ubip);
- SendRconCommand("reloadbans");
- SendRconCommand(string);
- SendRconCommand("reloadbans");
- format(string, sizeof(string), BOTNAME ": You unbanned the IP: %s", ubip);
- SendClientMessage(playerid, COLOUR_WHITE, string);
- }
- return 1;
- }
- COMMAND:setvw(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 3) return 0;
- new pid, vwid;
- if (sscanf(params, "ui", pid, vwid)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /setvw [id] [vwid]");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has set %s's virtual world to ID: %d", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), vwid);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": %s %s has set %s's virtual world to ID: %d", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), vwid);
- SetPlayerVirtualWorld(pid, vwid);
- }
- return 1;
- }
- // Level 4 cmds
- COMMAND:makeadmin(playerid, params[])
- {
- if (PlayerData[playerid][bAdmin] < 4) return 0;
- new pid, level;
- if (sscanf(params, "ui", pid, level)) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Correct usage: /makeadmin [id] [level]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Player not found");
- else if (level > 4 || level < 0) SendClientMessage(playerid, COLOUR_BAMSG, BOTNAME ": Level must be between 0 & 4");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": %s %s has made %s a %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), AdminRankNames[level]);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": %s %s has made %s a %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), AdminRankNames[level]);
- PlayerData[pid][bAdmin] = level;
- }
- return 1;
- }
- // RCON console cmds
- rcmd_kick(command[])
- {
- new pid, reason[128];
- if (sscanf(command, "us", pid, reason)) print(BOTNAME ": Correct usage: /kick [id] [reason]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has kicked %s from the server (Reason: %s)", PlayerName(pid), reason);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You kicked %s from the server (Reason: %s)", PlayerName(pid), reason);
- Kick(pid);
- }
- return 1;
- }
- rcmd_whois(command[])
- {
- new pid;
- if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /whois [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else
- {
- new string[128], string2[128];
- new Float:health, Float:armour;
- GetPlayerHealth(pid,health);
- GetPlayerArmour(pid,armour);
- format(string, sizeof(string), BOTNAME ": [WHOIS: %s %s]", AdminRankNames[PlayerData[pid][bAdmin]], PlayerName(pid));
- printf(string);
- format(string2, sizeof(string2), "@| Cash: %d, Health: %0.1f, Armour: %0.1f, IP: %s, Ping: %d, Skin: %d", GetPlayerMoney(pid), health, armour, pIp(pid), GetPlayerPing(pid), GetPlayerSkin(pid));
- printf(string2);
- }
- return 1;
- }
- rcmd_mute(command[])
- {
- new pid;
- if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /mute [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has muted %s.", PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You muted %s.", PlayerName(pid));
- PlayerData[pid][bIsMuted] = 1;
- }
- return 1;
- }
- rcmd_unmute(command[])
- {
- new pid;
- if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /unmute [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has unmuted %s.", PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You unmuted %s.", PlayerName(pid));
- PlayerData[pid][bIsMuted] = 0;
- }
- return 1;
- }
- rcmd_slap(command[])
- {
- new pid;
- if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /slap [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else
- {
- new string[128];
- new Float:pX, Float:pY, Float:pZ;
- GetPlayerPos(pid, pX, pY, pZ);
- SetPlayerPos(pid, pX, pY, pZ+5);
- format(string, sizeof(string), BOTNAME ": An RCON Admin slapped %s", PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You slapped %s", PlayerName(pid));
- }
- return 1;
- }
- rcmd_ann(command[])
- {
- new msg[128];
- if (sscanf(command, "s", msg)) print(BOTNAME ": Correct usage: /ann [text]");
- else
- {
- GameTextForAll(msg, 3000, 5);
- }
- return 1;
- }
- rcmd_ban(command[])
- {
- new pid, reason[128];
- if (sscanf(command, "us", pid, reason)) print(BOTNAME ": Correct usage: /ban [id] [reason]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has banned %s from the server (Reason: %s)", PlayerName(pid), reason);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You banned %s from the server (Reason: %s)", PlayerName(pid), reason);
- Ban(pid);
- }
- return 1;
- }
- rcmd_explode(command[])
- {
- new pid;
- if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /explode [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else
- {
- new Float:pX, Float:pY, Float:pZ;
- if (IsPlayerInAnyVehicle(pid)) GetVehiclePos(GetPlayerVehicleID(pid), pX, pY, pZ);
- else GetPlayerPos(pid, pX, pY, pZ);
- CreateExplosion(pX, pY, pZ, 6, 20);
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has exploded %s", PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You exploded %s", PlayerName(pid));
- }
- return 1;
- }
- rcmd_rename(command[])
- {
- new pid, name[24];
- if (sscanf(command, "us", pid, name)) print(BOTNAME ": Correct usage: /rename [id] [name]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has changed %s's name to %s", PlayerName(pid), name);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You changed %s's name to %s", PlayerName(pid), name);
- udb_RenameUser(PlayerName(pid), name);
- SetPlayerName(pid, name);
- }
- return 1;
- }
- rcmd_akill(command[])
- {
- new pid;
- if (sscanf(command, "u", pid)) print(BOTNAME ": Correct usage: /akill [id]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has killed %s", PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- SetPlayerHealth(pid, 0.0);
- printf(BOTNAME ": You killed %s", PlayerName(pid));
- }
- return 1;
- }
- rcmd_setskin(command[])
- {
- new pid, skinid;
- if (sscanf(command, "ui", pid, skinid)) print(BOTNAME ": Correct usage: /setskin [id] [skinid]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else if (skinid < 0 || skinid > 299 || IsInvalidSkin(skinid)) print(BOTNAME ": Invalid Skin");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has changed %s's skin to ID: %i", PlayerName(pid), skinid);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- SetPlayerSkin(pid, skinid);
- PlayerData[pid][bSkin] = skinid;
- printf(BOTNAME ": You changed %s's skin to ID: %i", PlayerName(pid), skinid);
- }
- return 1;
- }
- rcmd_restart(command[])
- {
- new reason[128];
- if (sscanf(command, "s", reason)) print(BOTNAME ": Correct usage: /restart [reason]");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has initiated a server restart. (Reason: %s)", reason);
- SendClientMessageToAll(COLOUR_RED, string);
- printf(BOTNAME ": You have initiated a server restart. (Reason: %s)", reason);
- SetTimer("sRestart", 5000, 0);
- }
- return 1;
- }
- rcmd_sethealth(command[])
- {
- new pid, health;
- if (sscanf(command, "ui", pid, health)) print(BOTNAME ": Correct usage: /sethealth [id] [amount]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else if (health < 0 || health > 100) print(BOTNAME ": Amount must be between 0 & 100");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has changed %s's health", PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You have changed %s's health", PlayerName(pid));
- SetPlayerHealth(pid, health);
- }
- return 1;
- }
- rcmd_setarmour(command[])
- {
- new pid, armour;
- if (sscanf(command, "ui", pid, armour)) print(BOTNAME ": Correct usage: /setarmour [id] [amount]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else if (armour < 0 || armour > 100) print(BOTNAME ": Amount must be between 0 & 100");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has changed %s's armour", PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You have changed %s's armour", PlayerName(pid));
- SetPlayerArmour(pid, armour);
- }
- return 1;
- }
- rcmd_setweather(command[])
- {
- new wid;
- if (sscanf(command, "i", wid)) print(BOTNAME ": Correct usage: /setweather [weatherid]");
- else if (wid < 0) print(BOTNAME ": Amount must be above 0");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has set the weather to ID: %d)", wid);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You have set the weather to ID: %d)", wid);
- SetWeather(wid);
- }
- return 1;
- }
- rcmd_setvw(command[])
- {
- new pid, vwid;
- if (sscanf(command, "ui", pid, vwid)) print(BOTNAME ": Correct usage: /setvw [id] [vwid]");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has set %s's virtual world to ID: %d", PlayerName(pid), vwid);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You have set %s's virtual world to ID: %d", PlayerName(pid), vwid);
- SetPlayerVirtualWorld(pid, vwid);
- }
- return 1;
- }
- rcmd_banip(command[])
- {
- new bip[16];
- if (sscanf(command, "s", bip)) print(BOTNAME ": Correct usage: /banip [*.*.*.*]");
- else
- {
- new string[128];
- format(string, sizeof(string), "banip %s", bip);
- SendRconCommand(string);
- format(string, sizeof(string), BOTNAME ": You banned the IP: %s", bip);
- }
- return 1;
- }
- rcmd_unbanip(command[])
- {
- new ubip[16];
- if (sscanf(command, "s", ubip)) print(BOTNAME ": Correct usage: /unbanip [*.*.*.*]");
- else
- {
- new string[128];
- format(string, sizeof(string), "unbanip %s", ubip);
- SendRconCommand("reloadbans");
- SendRconCommand(string);
- SendRconCommand("reloadbans");
- printf(BOTNAME ": You unbanned the IP: %s", ubip);
- }
- return 1;
- }
- rcmd_makeadmin(command[])
- {
- new pid, level;
- if (sscanf(command, "ui", pid, level)) print(BOTNAME ": Correct usage: /makeadmin [id] [level]");
- else if (!IsPlayerConnected(pid) || pid == INVALID_PLAYER_ID) print(BOTNAME ": Player not found");
- else if (level > 4 || level < 0) print(BOTNAME ": Level must be between 0 & 4");
- else
- {
- new string[128];
- format(string, sizeof(string), BOTNAME ": An RCON Admin has made %s a %s", PlayerName(pid), AdminRankNames[level]);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You have made %s a %s", PlayerName(pid), AdminRankNames[level]);
- PlayerData[pid][bAdmin] = level;
- }
- return 1;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- sscanf
- Params:
- string[] - String to extract parameters from.
- format[] - Parameter types to get.
- {Float,_}:... - Data return variables.
- Return:
- 0 - Successful, not 0 - fail.
- Notes:
- A fail is either insufficient variables to store the data or insufficient
- data for the format string - excess data is disgarded.
- A string in the middle of the input data is extracted as a single word, a
- string at the end of the data collects all remaining text.
- The format codes are:
- c - A character.
- d, i - An integer.
- h, x - A hex number (e.g. a colour).
- f - A float.
- s - A string.
- z - An optional string.
- pX - An additional delimiter where X is another character.
- '' - Encloses a litteral string to locate.
- u - User, takes a name, part of a name or an id and returns the id if they're connected.
- Now has IsNumeric integrated into the code.
- Added additional delimiters in the form of all whitespace and an
- optioanlly specified one in the format string.
- -*----------------------------------------------------------------------------*/
- stock sscanf(string[], format[], {Float,_}:...)
- {
- #if defined isnull
- if (isnull(string))
- #else
- if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
- #endif
- {
- return format[0];
- }
- #pragma tabsize 4
- new
- formatPos = 0,
- stringPos = 0,
- paramPos = 2,
- paramCount = numargs(),
- delim = ' ';
- while (string[stringPos] && string[stringPos] <= ' ')
- {
- stringPos++;
- }
- while (paramPos < paramCount && string[stringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = string[stringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = string[++stringPos];
- }
- do
- {
- stringPos++;
- if ('0' <= ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return -1;
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- num = 0,
- ch = string[stringPos];
- do
- {
- stringPos++;
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- default:
- {
- return -1;
- }
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, string[stringPos++]);
- }
- case 'f':
- {
- new changestr[16], changepos = 0, strpos = stringPos;
- while(changepos < 16 && string[strpos] && string[strpos] != delim)
- {
- changestr[changepos++] = string[strpos++];
- }
- changestr[changepos] = '\0';
- setarg(paramPos,0,_:floatstr(changestr));
- }
- case 'p':
- {
- delim = format[formatPos++];
- continue;
- }
- case '\'':
- {
- new
- end = formatPos - 1,
- ch;
- while ((ch = format[++end]) && ch != '\'') {}
- if (!ch)
- {
- return -1;
- }
- format[end] = '\0';
- if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
- {
- if (format[end + 1])
- {
- return -1;
- }
- return 0;
- }
- format[end] = '\'';
- stringPos = ch + (end - formatPos);
- formatPos = end + 1;
- }
- case 'u':
- {
- new
- end = stringPos - 1,
- id = 0,
- bool:num = true,
- ch;
- while ((ch = string[++end]) && ch != delim)
- {
- if (num)
- {
- if ('0' <= ch <= '9')
- {
- id = (id * 10) + (ch - '0');
- }
- else
- {
- num = false;
- }
- }
- }
- if (num && IsPlayerConnected(id))
- {
- setarg(paramPos, 0, id);
- }
- else
- {
- #if !defined foreach
- #define foreach(%1,%2) for (new %2 = 0; %2 < SLOTS; %2++) if (IsPlayerConnected(%2))
- #define __SSCANF_FOREACH__
- #endif
- string[end] = '\0';
- num = false;
- new
- name[MAX_PLAYER_NAME];
- id = end - stringPos;
- foreach (Player, playerid)
- {
- GetPlayerName(playerid, name, sizeof (name));
- if (!strcmp(name, string[stringPos], true, id))
- {
- setarg(paramPos, 0, playerid);
- num = true;
- break;
- }
- }
- if (!num)
- {
- setarg(paramPos, 0, INVALID_PLAYER_ID);
- }
- string[end] = ch;
- #if defined __SSCANF_FOREACH__
- #undef foreach
- #undef __SSCANF_FOREACH__
- #endif
- }
- stringPos = end;
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = string[stringPos++]) && ch != delim)
- {
- setarg(paramPos, i++, ch);
- }
- if (!i)
- {
- return -1;
- }
- }
- else
- {
- while ((ch = string[stringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- stringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
- {
- stringPos++;
- }
- while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
- {
- stringPos++;
- }
- paramPos++;
- }
- do
- {
- if ((delim = format[formatPos++]) > ' ')
- {
- if (delim == '\'')
- {
- while ((delim = format[formatPos++]) && delim != '\'') {}
- }
- else if (delim != 'z')
- {
- return delim;
- }
- }
- }
- while (delim > ' ');
- return 0;
- }
- stock PlayerName(playerid)
- {
- new pname[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
- return pname;
- }
- stock is_numeric(const string[])
- {
- for (new i; i < strlen(string); i++)
- if (string[i] < '0' || string[i] > '9')
- return 0;
- return 1;
- }
- stock IsInvalidSkin(skinid)
- {
- new InSkin[] = {0, 3, 4, 5, 6, 8, 42, 65, 86, 74, 119, 149, 208, 273, 289};
- for (new i=0; i<sizeof(InSkin); i++) if(skinid == InSkin[i]) return 1;
- return 0;
- }
- stock pIp(playerid)
- {
- new ip[16];
- GetPlayerIp(playerid, ip, sizeof(ip));
- return ip;
- }
- stock ChatLog(playerid, string[])
- {
- new File: logfile, logtext[128];
- new byear, bmonth, bday, bhour, bminute, bsecond;
- getdate(byear, bmonth, bday);
- gettime(bhour, bminute, bsecond);
- logfile = fopen("bAdmin/Logs/Chat.log", io_append);
- format(logtext, sizeof(logtext),"[%02d/%02d/%04d %02d:%02d:%02d] %s: %s \r\n", bday, bmonth, byear, bhour, bminute, bsecond, PlayerName(playerid), string);
- fwrite(logfile, logtext);
- fclose (logfile);
- }
- stock AdminChatLog(string[])
- {
- new File: logfile, logtext[128];
- new byear, bmonth, bday, bhour, bminute, bsecond;
- getdate(byear, bmonth, bday);
- gettime(bhour, bminute, bsecond);
- logfile = fopen("bAdmin/Logs/AdminChat.log", io_append);
- format(logtext, sizeof(logtext),"[%02d/%02d/%04d %02d:%02d:%02d] %s \r\n", bday, bmonth, byear, bhour, bminute, bsecond, string);
- fwrite(logfile, logtext);
- fclose (logfile);
- }
- stock KillsLog(killerid, playerid)
- {
- new File: logfile, logtext[128];
- new byear, bmonth, bday, bhour, bminute, bsecond;
- getdate(byear, bmonth, bday);
- gettime(bhour, bminute, bsecond);
- logfile = fopen("bAdmin/Logs/Kills.log", io_append);
- format(logtext, sizeof(logtext),"[%04d-%02d-%02d %02d:%02d:%02d] %s killed %s. \r\n", byear, bmonth, bday, bhour, bminute, bsecond, PlayerName(killerid), PlayerName(playerid));
- fwrite(logfile, logtext);
- fclose (logfile);
- return 1;
- }
- stock DeathsLog(playerid)
- {
- new File: logfile, logtext[128];
- new byear, bmonth, bday, bhour, bminute, bsecond;
- getdate(byear, bmonth, bday);
- gettime(bhour, bminute, bsecond);
- logfile = fopen("bAdmin/Logs/Deaths.log", io_append);
- format(logtext, sizeof(logtext),"[%04d-%02d-%02d %02d:%02d:%02d] %s died. \r\n", byear, bmonth, bday, bhour, bminute, bsecond, PlayerName(playerid));
- fwrite(logfile, logtext);
- fclose (logfile);
- return 1;
- }
- public PlayingTime(playerid)
- {
- PlayerData[playerid][bMins] ++;
- if(PlayerData[playerid][bMins] == 60)
- {
- PlayerData[playerid][bHours] ++;
- PlayerData[playerid][bMins] = 0;
- }
- }
- public sRestart()
- {
- SendRconCommand("gmx");
- return 1;
- }
- stock SendClientMessageToAdmin(color, string[])
- {
- AdminChatLog(string);
- for(new i = 0; i <SLOTS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(PlayerData[i][bAdmin] >= 1)
- {
- SendClientMessage(i, color, string);
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment