SSCANF Problem
#1

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;
}
Reply
#2

use strcmp to compare strings, not sscanf
Reply
#3

Alright, works, thanks.
Reply
#4

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".
Reply
#5

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

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.
Reply
#7

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

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

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)