sscanf
#1

Hey. When I start my server on local host, sscanf prints in console that something is wrong with my command when I use it. This is it:
pawn Код:
CMD:ban(playerid, params[])
{
    new playerb, string[128], reason[24];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "us", playerb, reason))
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");
// part of the code
Does anyone know what is the problem?
Reply
#2

I think this is your problem:
Код:
if(sscanf(params, "us[24]", playerb, reason))
You haven't set size of your string in sscanf. That's why it was warning you in your console.
Reply
#3

i thing this is right..
Код:
CMD:ban(playerid, params[])
{
    new playerb, string[128], reason[24];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "ds", playerb, reason))
    {        
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");
// part of the code
Reply
#4

oh silly me, I didn't see that one. Thanks.
Reply
#5

Blackbomb, 'U' is used for player IDs, and 'D' is used for integers only. In this case, he has to use specifier 'U'.
Reply
#6

ok
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)