Convert strtok and strcmp to sscanf and zcmd
#1

I really would like to go a step forward and a major update with my script convering strcmp and strok commands to the most efficent way.
Can anybody convert this, for example? It will work as a base.
pawn Код:
if(strcmp("/kick", cmd, true) == 0)
    {
        if(PlayerInfo[playerid][pAdminLevel] >= 1)
        {
            tmp = strtok(cmdtext,idx);
            if(!strlen(tmp))
            {
                return SendClientMessage(playerid,COLOR_LIGHTRED,"USAGE: /kick [id] [reason]");
            }
            new id = strval(tmp);
            new pid = playerid;
            new reason[128];
            reason = strrest(cmdtext, idx);
            if (!strlen(reason)) return SendClientMessage(playerid,COLOR_LIGHTRED,"USAGE: /kick [id] [reason]");
            if(!IsPlayerConnected(id))
            {
                return SendClientMessage(playerid,COLOR_GRAY,"AdmCmd This player is not online!");
            }
           
            PlayHintSoundAtPos(playerid);
            new globalmsg[100];
            new adminid[MAX_PLAYERS], victimid[MAX_PLAYERS];
            GetPlayerName(pid, adminid, sizeof(victimid));
            GetPlayerName(id, victimid, sizeof(victimid));
            format(globalmsg,sizeof(globalmsg),"AdmWarn: Administrator %s has kicked player %s [%s]",adminid,victimid,reason);
            SendClientMessageToAll(COLOR_LIGHTBLUE,globalmsg);
            Kick(id);
            return 1;
        }
        else
        {
            SendClientMessage(playerid,COLOR_GRAY,"You don't have authorization.");
            return 1;
        }
    }
A guide to convert commands and use sscanf as their parameters is deeply appreciated
Regards,
Reply


Messages In This Thread
Convert strtok and strcmp to sscanf and zcmd - by admantis - 21.01.2011, 02:12
Re: Convert strtok and strcmp to sscanf and zcmd - by PeteShag - 21.01.2011, 03:15
Respuesta: Convert strtok and strcmp to sscanf and zcmd - by ipsBruno - 21.01.2011, 03:19
Re: Convert strtok and strcmp to sscanf and zcmd - by PeteShag - 21.01.2011, 03:23
Re: Convert strtok and strcmp to sscanf and zcmd - by Marty_Alex - 21.01.2011, 04:39
Re: Convert strtok and strcmp to sscanf and zcmd - by HyperZ - 21.01.2011, 04:39

Forum Jump:


Users browsing this thread: 2 Guest(s)