sscanf help
#1

hello, i tried to do a job system just to test but i know i did something wrong with the sscanf i dont understand it much

here

pawn Код:
COMMAND:job(playerid, params[])
{
    if(GetPlayerInterior(playerid) == 1)
    if(sscanf(params, "d", params)) return SendClientMessage(playerid, Yellow, "Usage: /job <job name>");
    if (!strcmp("Police", params, true)) if(GetPlayerJobID(playerid) == 0)
    {
        new name[MAX_PLAYER_NAME], file[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
    RemoveJob(playerid);
    SetJob(playerid,1);
        PlayerInfo[playerid][pJob] = dini_Int(file, "Job");
    }
    return 1;
}
please tell me how
Reply
#2

'd' is used for integers. Use 's' for strings.
Reply
#3

so i just need to change the "d" to "s" and the code is fixed?

edit: not working
Reply
#4

Try this:
pawn Код:
COMMAND:job(playerid, params[])
{
    if(GetPlayerInterior(playerid) == 1)
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, Yellow, "Usage: /job <job name>");
    if (!strcmp("Police", params, true)) if(GetPlayerJobID(playerid) == 0)
    {
        new name[MAX_PLAYER_NAME], file[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        RemoveJob(playerid);
        SetJob(playerid,1);
        PlayerInfo[playerid][pJob] = dini_Int(file, "Job");
    }
    return 1;
}
Reply
#5

code not working
Reply
#6

Try this:
pawn Код:
COMMAND:job(playerid, params[])
{
    if(GetPlayerInterior(playerid) == 1)
    {
        if(!sscanf(params, "s[128]", params))
        {
            if (!strcmp("police", params, true))
            {
                if(GetPlayerJobID(playerid) == 0)
                {
                    new name[MAX_PLAYER_NAME], file[128];
                    GetPlayerName(playerid, name, sizeof(name));
                    format(file, sizeof(file), SERVER_USER_FILE, name);
                    RemoveJob(playerid);
                    SetJob(playerid,1);
                    PlayerInfo[playerid][pJob] = dini_Int(file, "Job");
                }
            }
        }
        else return SendClientMessage(playerid, Yellow, "Usage: /job <job name>");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)