sscanf and OnRconCommand
#4

You can make use of the silent SSCANF parameter. (Optional Strings)

For example:
pawn Код:
public OnRconCommand(cmd[])
{
    new command[30], params[128];
    if(sscanf(cmd, "s[30]S()[128]", command, params)) return print("[RCON] Invalid Command.");
   
    if(!strcmp(command, "customhelp", true))
    {
        print("JaKe's custom RCON commands @ 2015");
        print("/b, /admins, /a, /admin, /c, /v, /w, /fakea, /fakec");
    }

    // command /b
    if(!strcmp(command, "b", true))
    {
        new targetid, message[128];
        if(sscanf(params, "is[128]", targetid, message)) return print("USAGE: /rcon b [playerid] [message]");
        if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return print("NOTE: Player not connected.");

        new string[144];
        format(string, sizeof(string), "(( [X] RCON Admin: %s ))", message);
        print(string); //Print or SendClientMessage?

        new Float:f_Radius = 20.0, Float:f_playerPos[3];
        GetPlayerPos(targetid, f_playerPos[0], f_playerPos[1], f_playerPos[2]);
        foreach(new i : Player)
        {
            if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(targetid))
            {
                if(!IsPlayerInRangeOfPoint(i, f_Radius, f_playerPos[0], f_playerPos[1], f_playerPos[2])) continue;
                if(IsPlayerInRangeOfPoint(i, f_Radius / 2, f_playerPos[0], f_playerPos[1], f_playerPos[2])) SendClientMessageEx(i, COLOR_FADE4, string);
                else if(IsPlayerInRangeOfPoint(i, f_Radius / 4, f_playerPos[0], f_playerPos[1], f_playerPos[2])) SendClientMessageEx(i, COLOR_FADE3, string);
                else if(IsPlayerInRangeOfPoint(i, f_Radius / 8, f_playerPos[0], f_playerPos[1], f_playerPos[2])) SendClientMessageEx(i, COLOR_FADE2, string);
                else if(IsPlayerInRangeOfPoint(i, f_Radius / 16, f_playerPos[0], f_playerPos[1], f_playerPos[2])) SendClientMessageEx(i, COLOR_FADE1, string);
                else SendClientMessageEx(i, COLOR_FADE5, string);
            }
        }
        return 1;
    }
    //etc...
Reply


Messages In This Thread
sscanf and OnRconCommand - by JaKe Elite - 17.03.2015, 01:48
Re: sscanf and OnRconCommand - by arakuta - 17.03.2015, 02:03
Re: sscanf and OnRconCommand - by JaKe Elite - 17.03.2015, 03:46
Re: sscanf and OnRconCommand - by Threshold - 17.03.2015, 10:42

Forum Jump:


Users browsing this thread: 1 Guest(s)