Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- bAdmin - Scripted by [RP]Brock_Shogun.
- Do not alter these credits, cause thats just stupid.
- */
- #include <a_samp>
- #include <bDUDb>
- #define SLOTS 5 // amount of slots your server has
- #define BAVERSION "1.0"
- #define BOTNAME "ShoBot"
- #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- #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 DIALOG_REGISTER 1
- #define DIALOG_LOGIN 2
- #define DIALOG_WEPS 3
- enum PlayerInfo
- {
- bLogged,
- bAdmin,
- bIsMuted,
- bSpec,
- bSkin
- }
- new PlayerData[MAX_PLAYERS][PlayerInfo];
- new AdminRankNames[][]=
- {
- "Non-Staff", "Moderator", "Junior Admin", "Senior Admin", "Server Owner"
- };
- forward SendClientMessageToAdmin(color, string[]);
- forward sRestart();
- public OnFilterScriptInit()
- {
- print("\n");
- print("BBBBBBBB SSSSSS AAA SSSSSS");
- print("BB BB SS SS AA AA SS SS");
- print("BB BB SS AA AA SS");
- print("BBBBBBBB SSSSSS AA AA SSSSSS");
- print("BB BB SS AAAAAAAAA SS");
- print("BB BB SS SS AA AA SS SS");
- print("BBBBBBBB SSSSSS AA AA SSSSSS");
- printf("\n Loaded. v%s", BAVERSION);
- print("\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n");
- print("BBBBBBBB SSSSSS AAA SSSSSS");
- print("BB BB SS SS AA AA SS SS");
- print("BB BB SS AA AA SS");
- print("BBBBBBBB SSSSSS AA AA SSSSSS");
- print("BB BB SS AAAAAAAAA SS");
- print("BB BB SS SS AA AA SS SS");
- print("BBBBBBBB SSSSSS AA AA SSSSSS");
- printf("\n Unloaded. v%s", BAVERSION);
- print("\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new string[128];
- format(string, sizeof(string), "%s has joined the server.", PlayerName(playerid));
- SendClientMessageToAll(0xFFFF00FF, string);
- 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), "%s has left the server. (Lost Connection)", PlayerName(playerid));
- case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", PlayerName(playerid));
- case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", PlayerName(playerid));
- }
- SendClientMessageToAll(0xFFFF00FF, string);
- if(PlayerData[playerid][bLogged])
- {
- bUserSetINT(PlayerName(playerid)).("bAdmin", PlayerData[playerid][bAdmin]);
- bUserSetINT(PlayerName(playerid)).("bSkin", PlayerData[playerid][bSkin]);
- }
- 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)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if (PlayerData[playerid][bIsMuted] == 1)
- {
- SendClientMessage(playerid, COLOUR_BAMSG, "ShoBot: You've been muted by an admin, you are unable to talk!");
- return 0;
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- printf("ShoBot: %s entered command %s", PlayerName(playerid), cmdtext);
- // Level 1 cmds
- dcmd(unmute, 6, cmdtext);
- dcmd(whois, 5, cmdtext);
- dcmd(kick, 4, cmdtext);
- dcmd(slap, 4, cmdtext);
- dcmd(mute, 4, cmdtext);
- dcmd(goto, 4, cmdtext);
- dcmd(spec, 4, cmdtext);
- dcmd(adm, 3, cmdtext);
- dcmd(ann, 3, cmdtext);
- dcmd(get, 3, cmdtext);
- // Level 2 cmds
- dcmd(explode, 7, cmdtext);
- dcmd(setskin, 7, cmdtext);
- dcmd(rename, 6, cmdtext);
- dcmd(akill, 5, cmdtext);
- dcmd(ban, 3, cmdtext);
- // Level 3 cmds
- dcmd(setweather, 10, cmdtext);
- dcmd(setarmour, 9, cmdtext);
- dcmd(sethealth, 9, cmdtext);
- dcmd(restart, 7, cmdtext);
- // Level 4 cmds
- dcmd(makeadmin, 9, cmdtext);
- if (strcmp(cmdtext, "/admins", true) == 0)
- {
- new C = 0;
- SendClientMessage(playerid, COLOUR_BAMSG, "Online Admins:");
- for(new i = 0; i < MAX_PLAYERS; 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,"ShoBot: There are no admins online!");
- SendClientMessage(playerid, COLOUR_BAMSG, "- - - - - - - - - - - - - - - - - - -");
- return 1;
- }
- if (strcmp(cmdtext, "/acmds", true) == 0)
- {
- 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, "> /restart [reason]");
- 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, "> /restart [reason], /makeadmin [id] [level]");
- return 1;
- }
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- 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(restart, 7, cmd);
- rcmd(makeadmin, 9, cmd);
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- 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][bLogged] = 1;
- PlayerData[playerid][bSpec] = -1;
- PlayerData[playerid][bIsMuted] = 0;
- return 1;
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- // Level 1 cmds
- dcmd_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;
- }
- dcmd_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", GetPlayerMoney(pid), health, armour, pIp(pid), GetPlayerPing(pid), GetPlayerSkin(pid));
- SendClientMessage(playerid, COLOUR_WHITE, string2);
- }
- return 1;
- }
- dcmd_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[pid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- PlayerData[pid][bIsMuted] = 1;
- }
- return 1;
- }
- dcmd_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[pid][bAdmin]], PlayerName(playerid), PlayerName(pid));
- SendClientMessageToAll(COLOUR_BAMSG, string);
- PlayerData[pid][bIsMuted] = 0;
- }
- return 1;
- }
- dcmd_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;
- }
- dcmd_adm(playerid, params[])
- {
- new string[256];
- if(PlayerData[playerid][bAdmin] >= 1)
- {
- format(string, sizeof(string), "@| %s %s: %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), params);
- SendClientMessageToAdmin(COLOUR_ADM, string);
- }
- return 1;
- }
- dcmd_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;
- }
- dcmd_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;
- }
- dcmd_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;
- }
- dcmd_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
- dcmd_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;
- }
- dcmd_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;
- }
- dcmd_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;
- }
- dcmd_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;
- }
- dcmd_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
- dcmd_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;
- }
- dcmd_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 set %s's health to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), health);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": %s %s has set %s's health to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), health);
- SetPlayerHealth(pid, health);
- }
- return 1;
- }
- dcmd_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 set %s's armour to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), armour);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": %s %s has set %s's armour to %s", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), PlayerName(pid), armour);
- SetPlayerArmour(pid, armour);
- }
- return 1;
- }
- dcmd_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 %s's armour to %0.1f)", AdminRankNames[PlayerData[playerid][bAdmin]], PlayerName(playerid), wid);
- SetWeather(wid);
- }
- return 1;
- }
- // Level 4 cmds
- dcmd_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 set %s's health to %s", PlayerName(pid), health);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You have set %s's health to %s", PlayerName(pid), health);
- 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 set %s's armour to %s", PlayerName(pid), armour);
- SendClientMessageToAll(COLOUR_BAMSG, string);
- printf(BOTNAME ": You have set %s's armour to %s)", PlayerName(pid), armour);
- 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_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;
- }
- public sRestart()
- {
- SendRconCommand("gmx");
- return 1;
- }
- public SendClientMessageToAdmin(color, 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