Multiple SSCANF checks not working.
#1

The title really says it all but for note, When i use /company invite it will show the useage but after putting my id in witch is 0 (/company invite 0) none of the code is used after that. EG Messages.

pawn Код:
COMMAND:company(playerid, params[], option[])
{
    if(sscanf(params, "s[10]", option))
    {
        SendClientMessage(playerid, COLOR_WHITE, "{C2A2DA}Usage{FFFFFF}: /company [option]");
        SendClientMessage(playerid,COLOR_YELLOW2,"Actions: members, invite, uninvite, setrank");
        SendClientMessage(playerid,COLOR_YELLOW2,"Actions:");
    }

    if(strcmp(option,"invite",true) == 0)
    {
        new InviteID;
        if(sscanf(params, "d", InviteID))  return SendClientMessage(playerid, COLOR_WHITE, "{C2A2DA}Usage{FFFFFF}: /company invite [playerid]");
        {
            if(!IsPlayerConnected(InviteID)) return SendClientMessage(playerid, COLOR_WHITE, "[{FF6347}Error{FFFFFF}]: This person is not connect or you have provided an invalid id.");

            if(CharacterInfo[InviteID][cCompany] > 0)
            {
                CharacterInfo[InviteID][cCompany] = CharacterInfo[playerid][cCompany];
                format(CharacterInfo[InviteID][cCompanyRank], 32, "No Rank");

                SendClientMessage(InviteID, COLOR_YELLOW2, "You have been invited to a company.");
                SendClientMessage(playerid, COLOR_YELLOW2, "You have invited another player to your company.");
                SendClientMessage(playerid, COLOR_YELLOW2, "Make sure you set this players rank.");

            } else SendClientMessage(playerid, COLOR_WHITE, "[{FF6347}Error{FFFFFF}]: This person is already a member of another company..");
        }
    }
}
Reply
#2

Quote:
Originally Posted by zT KiNgKoNg
Посмотреть сообщение
The title really says it all but for note, When i use /company invite it will show the useage but after putting my id in witch is 0 (/company invite 0) none of the code is used after that. EG Messages.

pawn Код:
COMMAND:company(playerid, params[], option[])
{
    if(sscanf(params, "s[10]", option))
    {
        SendClientMessage(playerid, COLOR_WHITE, "{C2A2DA}Usage{FFFFFF}: /company [option]");
        SendClientMessage(playerid,COLOR_YELLOW2,"Actions: members, invite, uninvite, setrank");
        SendClientMessage(playerid,COLOR_YELLOW2,"Actions:");
    }

    if(strcmp(option,"invite",true) == 0)
    {
        new InviteID;
        if(sscanf(params, "d", InviteID))  return SendClientMessage(playerid, COLOR_WHITE, "{C2A2DA}Usage{FFFFFF}: /company invite [playerid]");
        {
            if(!IsPlayerConnected(InviteID)) return SendClientMessage(playerid, COLOR_WHITE, "[{FF6347}Error{FFFFFF}]: This person is not connect or you have provided an invalid id.");

            if(CharacterInfo[InviteID][cCompany] > 0)
            {
                CharacterInfo[InviteID][cCompany] = CharacterInfo[playerid][cCompany];
                format(CharacterInfo[InviteID][cCompanyRank], 32, "No Rank");

                SendClientMessage(InviteID, COLOR_YELLOW2, "You have been invited to a company.");
                SendClientMessage(playerid, COLOR_YELLOW2, "You have invited another player to your company.");
                SendClientMessage(playerid, COLOR_YELLOW2, "Make sure you set this players rank.");

            } else SendClientMessage(playerid, COLOR_WHITE, "[{FF6347}Error{FFFFFF}]: This person is already a member of another company..");
        }
    }
}
Have you tried using a "i" instead of a "d" in this line?

Код:
 if(sscanf(params, "d", InviteID))  return SendClientMessage(playerid, COLOR_WHITE, "{C2A2DA}Usage{FFFFFF}: /company invite [playerid]");
Cause "i" is integer, try using that, may work.
Reply
#3

"i" and "d" are exactly the same buddy.
Reply
#4

Quote:
Originally Posted by KtotheYle
Посмотреть сообщение
Have you tried using a "i" instead of a "d" in this line?

Код:
 if(sscanf(params, "d", InviteID))  return SendClientMessage(playerid, COLOR_WHITE, "{C2A2DA}Usage{FFFFFF}: /company invite [playerid]");
"i" and "d" are exactly the same buddy.
it doesen't matter if it's 'd' or 'i' in pawn just like you said. That won't change a thing actually cuz both can deal with integers (well, 'i' can also be used for Hexadecimal or Octal integers)

you are scanning params 2 times.
First, you're saying that there should be a string after the "space" in the cmd
and then you're sayin' that there's a number at that same spot where you previously told sscanf that there's a string. Fuck logic

anyways, what you're trying to do is not possible, atleast the way you're trying to do it.
not sure which command-sys that is but i'll try giving you an example:
pawn Код:
COMMAND:company(playerid, params[], option[])
{
    new s[6],x;
    if(sscanf(params, "s[6]d",s,x)) return SendClientMessage(playerid,-1,"USAGE: /company [invite/kick] [ID]");
    if(strcmp(s,"invite",true) == 0)//option is "invite"
    {
        //do some stuff here
        return 1;
    }
    else if(strcmp(s,"kick",true) == 0)//option is "kick"
    {
        //do some stuff here
        return 1;
    }
    else//if the option was INVALID
        //do some stuff, like sending a msg sayin' unknown option or so
    return 1;
}
Reply
#5

https://sampforum.blast.hk/showthread.php?tid=314196 according to this topic it is, I used this back when it was created, and it worked fine but now i've come back to cover it. It doesn't seem like its working.
Reply
#6

Thanks for your reply ****** is there a possible way of doing this in your opinion?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)