SA-MP Forums Archive
SSCANF Problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SSCANF Problem (/showthread.php?tid=161450)



SSCANF Problem - Dudits - 20.07.2010

I'm trying to make a clan system, but there's a problem with the way I'm setting parameters.
What happens is, what ever I type after the /clan command, it takes it as the "create" one, disregarding any other thing.

pawn Код:
CMD:clan(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
            // Non sscanf stuff, new's
        if(sscanf(params, "s", clanrelated)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /clan [parameter]") && SendClientMessage(playerid, COLOR_WHITE, "PARAMETERS: create, show, hide, invite, acceptinvite");
        if(sscanf(clanrelated, "create"))
        {
            // Stuff
        }
        else if(sscanf(clanrelated, "show"))
        {
            // Stuff
        }
        else if(sscanf(clanrelated, "hide"))
        {
            // Stuff
        }
        else if(sscanf(clanrelated, "invite"))
        {
            // Stuff
        }
        else if(sscanf(clanrelated, "acceptinvite"))
        {
            // Stuff
        }
    }
    return 1;
}



Re: SSCANF Problem - bigcomfycouch - 20.07.2010

use strcmp to compare strings, not sscanf


Re: SSCANF Problem - Dudits - 20.07.2010

Alright, works, thanks.


Re: SSCANF Problem - Dudits - 20.07.2010

Alright, another sscanf related problem.

I want to have a command called /clan invite [playerid]

pawn Код:
if(!strcmp(clanrelated, "invite", true, 6))
        {
            if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /clan invite [id]");
            //stuff
        }
This one gives me "SERVER: Unknown Command".


Re: SSCANF Problem - bigcomfycouch - 20.07.2010

try
pawn Код:
if(sscanf(clanrelated, "u", playerb))



Re: SSCANF Problem - Extremo - 20.07.2010

It will always give "Unknown Command" no matter what you are doing if you do not return. What I am saying is that you maybe didn't return 1 at all anywhere which makes it say Unknown Command. Also, which already pointed out by the above poster, you need to have params to be defined. clanrelated will also include invite, so you need to use strdel to delete the invite off the string.


Re: SSCANF Problem - Dudits - 20.07.2010

Didn't work big, still same error.
Mind explaining in an easier, Extremo?


Re: SSCANF Problem - Carlton - 20.07.2010

pawn Код:
if(!strcmp(clanrelated, "invite", true, 6))
{
            if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /clan invite [id]");
            //stuff
            return 1;
}



Re: SSCANF Problem - Dudits - 20.07.2010

Quote:
Originally Posted by Carlton
Посмотреть сообщение
pawn Код:
if(!strcmp(clanrelated, "invite", true, 6))
{
            if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /clan invite [id]");
            //stuff
            return 1;
}
Still Unknown command.


Re: SSCANF Problem - Carlton - 20.07.2010

If you don't want to show the whole command PM me it, i'll fix it, I have no clue what you're doing in the code to be honest.