Strings without a length are deprecated, please add a destination size.
#1

Time doesn't require a destination size since an integer is required. How can I fix this?
pawn Код:
YCMD:cage(playerid, params[], help)
{
    if( PlayerInfo[playerid][pAdmin] > 2 )
    {
        new
            TargetID,
            time,
            tReason[50];
        if( !sscanf(params, "uiS(No reason specified)[50]", TargetID, time, tReason) )
        {
            if( strlen( tReason ) > 50 )        return SendClientMessage( playerid, -1, "SERVER: Maximum reason size: 50" );
            if( !IsPlayerConnected(TargetID) ) return SendClientMessage( playerid, -1, "SERVER: Invalid playerid! Please try again" );
            if( time  < 10 )        return SendClientMessage( playerid, -1, "SERVER: Minimum time required: 10" );
            if( PlayerInfo[TargetID][pCaged] == 1 )         return SendClientMessage( playerid, -1, "SERVER: Player is already in the cage!" );
            new MyString[128],
                TargetString[128],
                Float:Pos[3];
            format( MyString, sizeof MyString, "SERVER: Caged %s (ID: %i) with the reason: %s (Caged: %d seconds)", GetName(TargetID), TargetID, tReason, time );
            format( TargetString, sizeof TargetString, "SERVER: %s (ID: %i) has been Caged by %s (ID: %i) with the reason: %s (Caged: %d seconds)", GetName(TargetID), TargetID, GetName(playerid), playerid, tReason, time );
            SendClientMessageToAll( -1, TargetString );
            SendClientMessage( playerid, -1, MyString );
            TogglePlayerControllable(TargetID, 0);
            PlayerInfo[TargetID][pCageTime] = time;
            PlayerInfo[TargetID][pCaged] = 1;
            GetPlayerPos(TargetID, Pos[0], Pos[1], Pos[2]);
            SetTimerEx("CagePlayer", 1000, 0, "i", TargetID);
            SetTimerEx("UnCagePlayer", PlayerInfo[TargetID][pCageTime]*1000, 0, "i", TargetID);
        }
        else
            return SendClientMessage(playerid, -1, "SERVER: /cage [targetid] [time] [reason]");
    }
    else
        return SendClientMessage( playerid, -1, "SERVER: You have to be an admin to perform this command!" );
    return 1;
}
EDIT: I'm also getting this...
Код:
sscanf warning: Unknown format specifier '[', skipping
sscanf warning: Unknown format specifier '3', skipping
sscanf warning: Unknown format specifier ']', skipping
sscanf warning: Unknown format specifier '[', skipping
sscanf warning: Unknown format specifier '3', skipping
sscanf warning: Unknown format specifier ']', skipping
sscanf warning: Unknown format specifier '[', skipping
sscanf warning: Unknown format specifier '3', skipping
sscanf warning: Unknown format specifier ']', skipping
sscanf warning: Unknown format specifier '[', skipping
sscanf warning: Unknown format specifier '3', skipping
sscanf warning: Unknown format specifier ']', skipping
Reply
#2

pawn Код:
format(str, sizeof(str), "%d", time);
if(strlen(str) != 7)
Is this what you wanted?

This simply formats it into a string, and then checks the length of the string

If not, what did you want again? I'm tired, so don't blame me. It looks like you already made it so if time is less than 10 it returns a message, shouldn't that work?
Reply
#3

Quote:
Originally Posted by Kindred
Посмотреть сообщение
pawn Код:
format(str, sizeof(str), "%d", time);
if(strlen(str) != 7)
Is this what you wanted?

This simply formats it into a string, and then checks the length of the string

If not, what did you want again? I'm tired, so don't blame me. It looks like you already made it so if time is less than 10 it returns a message, shouldn't that work?
Thanks for the quick reply, but I realized sscanf was warning me about a missing string. Thanks anyway!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)