[Ajuda] Problema com sscanf
#1

Olб, peguei mais ou menos o jeito de usar o sscanf com 2 ou mais parametros, porйm e se os parвmetros forem alternativos? й o caso desse filterscript de gps https://sampforum.blast.hk/showthread.php?tid=107687 . No comando
do FS ou o player digita /gps off OU digita /gps id.
Como transformar isso para ycmd com sscanf?

pawn Код:
new cmd[64],tmp[64],idx;
    cmd = strtok(cmdtext,idx);
    if(!strcmp(cmd, "/gps", true))
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFFAA, "Use: /gps [playerid / off]");
        if(!strcmp(tmp, "off", true)) {
            if(HaveGPS[playerid]) {
                KillTimer(GPSTimer[playerid]);
                HaveGPS[playerid] = false;
                GPSTimer[playerid] = 0;
                DisablePlayerCheckpoint(playerid);
                SendClientMessage(playerid, 0xFFFF00AA, "GPS: Desligado.");
            }else SendClientMessage(playerid, 0xFF0000AA, "GPS: Seu GPS estб desligado !");
            return 1;
        }
        if(IsPlayerConnected(strval(tmp))) {
            if(strval(tmp) != playerid) {
                if(HaveGPS[playerid]) {
                    KillTimer(GPSTimer[playerid]);
                    HaveGPS[playerid] = false;
                    GPSTimer[playerid] = 0;
                }
                GPSTimer[playerid] = SetTimerEx("GPSUpdate", 500, true, "dd", playerid,strval(tmp));
                HaveGPS[playerid] = true;
                new str[128],nick[24];
                GetPlayerName(strval(tmp),nick,24);
                format(str,128,"GPS: Ligado, alvo: %s (ID: %d)",nick,strval(tmp));
                SendClientMessage(playerid, 0xFFFF00AA, str);
            }else SendClientMessage(playerid, 0xFF0000AA, "GPS: Use corretamente o seu GPS !");
        }else SendClientMessage(playerid, 0xFF0000AA, "GPS: Alvo nгo encontrado(ID errado) !");
        return 1;
    }
@edit >>>> seria esse o caminho?

pawn Код:
new id, off;
if( sscanf( params, "us", ID || off) ) return SendClientMessage(playerid, -1, "Uso: /gps (ID / off)]");
Reply


Messages In This Thread
Problema com sscanf - by JackStenzel - 03.12.2014, 22:44
Re: Problema com sscanf - by MultiKill - 03.12.2014, 22:55
Re: Problema com sscanf - by JackStenzel - 03.12.2014, 23:17
Re: Problema com sscanf - by PT - 03.12.2014, 23:26
Re: Problema com sscanf - by JackStenzel - 03.12.2014, 23:33

Forum Jump:


Users browsing this thread: 1 Guest(s)