SA-MP Forums Archive
sscanf - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sscanf (/showthread.php?tid=481218)



sscanf - Ivan25 - 14.12.2013

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?


Re: sscanf - dominik523 - 14.12.2013

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.


Re: sscanf - ReD_HunTeR - 14.12.2013

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



Re: sscanf - Ivan25 - 14.12.2013

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


Re: sscanf - dominik523 - 14.12.2013

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


Re: sscanf - ReD_HunTeR - 14.12.2013

ok