Possibly an sscanf issue?
#1

Hi.

I've been struggling with this bug for like an hour, it wasted time. I have no clue what to do in it..
When I do /setplace 0, it sets it to place 0, cool, it works.
But if I did /setplace 1, nothing happens, not even a message appears.

Variables:
pawn Код:
new DefautlPlace = 0;
new ServerPlace;
pawn Код:
CMD:setplace(playerid, params[])
{
    new placeid, string[128];
    if(IsPlayerAdmin(playerid)|| PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(sscanf(params, "u", placeid)) return SendClientMessage(playerid, GREY, "Usage: /setplace [id] | 0: Area 51 | 1: San Fierro | more soon ");
        //if(placeid == ServerPlace) return SendClientMessage(playerid, RED, "This is the current place!");

        if(placeid != ServerPlace)
        {
            switch(placeid)
            {
                case 0:
                {
                    TextDrawHideForAll(Textdraw1);
                    format(string,sizeof(string),"Admin "COL_PINK"%s (%d)"COL_WHITE" has set playing place to "COL_PINK"0 (Area 51)", GetName(playerid), playerid);
                    SendClientMessageToAll(WHITE, string);
                    TextDrawSetString(Textdraw1, "PLACE: ~r~Area 51");
                    TextDrawShowForAll(Textdraw1);
                    ServerPlace = 0;
                    DefaultPlace = -1;
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    {
                        SpawnPlayer(i);
                    }
                }
                case 1:
                {
                    TextDrawHideForAll(Textdraw1);
                    format(string,sizeof(string),"Admin "COL_PINK"%s (%d)"COL_WHITE" has set playing place to "COL_PINK"1 (San Fierro)", GetName(playerid), playerid);
                    SendClientMessageToAll(WHITE, string);
                    TextDrawSetString(Textdraw1, "PLACE: ~r~San Fierro");
                    TextDrawShowForAll(Textdraw1);
                    ServerPlace = 1;
                    DefaultPlace = -1;
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    {
                        SpawnPlayer(i);
                    }
                }
            }
        }
    }
    else
    {
        SendClientMessage(playerid, RED, "You're not an admin");
    }
    return 1;
}
Note; I've used if statements for placeid 0 and 1, same result.
Reply
#2

the 'u' is to be used for player ID's and user names
try using 'i' for other integer values.
Reply
#3

u is the parameter for playerid, use i (integer) or d (decimal) instead

if(sscanf(params, "i", placeid))
Reply
#4

Oh my God. I'm too dumb, sorry

I think when I was using 'u' it could only process the number 0 because my id was 0.. Thank you guys. Appreciated.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)