SA-MP Forums Archive
I have a sscanf warning please help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: I have a sscanf warning please help (/showthread.php?tid=272098)



I have a sscanf warning please help - Shockey HD - 27.07.2011

So i get these warning's

Код:
[02:08:57] sscanf warning: 'z' is deprecated, consider using 'S' instead.
[02:08:57] sscanf warning: No default value found.
[02:08:57] sscanf warning: Format specifier does not match parameter count.
So heres the code that its happening at.


PHP код:
CMD:freeze(playerid,params[])
    {
        if(
PlayerInfo[playerid][pAdminLevel] >=1)
        {
            new 
id,n[MAX_PLAYER_NAME],reason[35], on[MAX_PLAYER_NAME], string[128], string2[128];
            if(
sscanf(params,"uz",idreason)) return SendClientMessage(playerid,COLOR_RED,"Usage:/freeze [ID] [reason]");
            else if(
playerid == INVALID_PLAYER_IDSendClientMessage(playerid,COLOR_RED,"System: Invalid ID");
            if (
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"System: Invalid ID");
            else
            {
            
GetPlayerName(playerid,n,sizeof(n));
            
GetPlayerName(id,on,sizeof(on));
            
format(string,sizeof(string),"You have been freezed by Admin: %s for %s",n,reason);
            
SendClientMessage(playerid,COLOR_RED,string);//
            
format(string2sizeof(string), "Admin Action: %s has freezed %s because: %s",n,on,reason);
            
SendClientMessageToAll(COLOR_RED,string2);
            
TogglePlayerControllable(playerid,0);
            }
        }
        else return 
SendClientMessage(playerid,COLOR_RED,"  You are not allowed to use this command!");
        return 
1;
    }
CMD:unfreeze(playerid,params[])
    {
        if(
PlayerInfo[playerid][pAdminLevel] >=1)
        {
            new 
id,n[MAX_PLAYER_NAME],reason[35], on[MAX_PLAYER_NAME], string[128], string2[128];
            if(
sscanf(params,"uz",idreason)) return SendClientMessage(playerid,COLOR_RED,"Usage:/unfreeze [ID] [reason]");
            else if(
playerid == INVALID_PLAYER_IDSendClientMessage(playerid,COLOR_RED,"System: Invalid ID");
            if (
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"System: Invalid ID");
            else
            {
            
GetPlayerName(playerid,n,sizeof(n));
            
GetPlayerName(id,on,sizeof(on));
            
format(string,sizeof(string),"You have been unfreezed by Admin: %s for %s",n,reason);
            
SendClientMessage(playerid,COLOR_RED,string);//
            
format(string2sizeof(string), "Admin Action: %s has unfreezed %s because: %s",n,on,reason);
            
SendClientMessageToAll(COLOR_RED,string2);
            
TogglePlayerControllable(playerid,1);
            }
        }
        else return 
SendClientMessage(playerid,COLOR_RED,"  You are not allowed to use this command!");
        return 
1;
    } 



Re: I have a sscanf warning please help - iggy1 - 27.07.2011

pawn Код:
sscanf(params,"uS[35](no reason)",id, reason)
Use that. In place of your own. Reason is now optional. If you don't give a reason in the command, the default reason will be "no reason".


Re: I have a sscanf warning please help - Shockey HD - 27.07.2011

Quote:
Originally Posted by iggy1
Посмотреть сообщение
pawn Код:
sscanf(params,"uS[35](no reason)",id, reason)
Use that. In place of your own. Reason is now optional. If you don't give a reason in the command, the default reason will be "no reason".
Im not understanding


Re: I have a sscanf warning please help - Ironboy - 27.07.2011

See this warning
pawn Код:
[02:08:57] sscanf warning: 'z' is deprecated, consider using 'S' instead.
You put "z" insted of "s" like this and it is wrong
pawn Код:
sscanf(params,"uZ[35](no reason)",id, reason)
The correct code is
pawn Код:
sscanf(params,"uS[35](no reason)",id, reason)



Re: I have a sscanf warning please help - Shockey HD - 27.07.2011

PHP код:
CMD:unfreeze(playerid,params[])
    {
        if(
PlayerInfo[playerid][pAdminLevel] >=1)
        {
            new 
id,n[MAX_PLAYER_NAME],reason[35], on[MAX_PLAYER_NAME], string[128], string2[128];
            
sscanf(params,"uS[35](no reason)",idreason) return SendClientMessage(playerid,COLOR_RED,"Usage:/unfreeze [ID] [reason]");
            else if(
playerid == INVALID_PLAYER_IDSendClientMessage(playerid,COLOR_RED,"System: Invalid ID");
            if (
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"System: Invalid ID");
            else
            {
            
GetPlayerName(playerid,n,sizeof(n));
            
GetPlayerName(id,on,sizeof(on));
            
format(string,sizeof(string),"You have been unfreezed by Admin: %s for %s",n,reason);
            
SendClientMessage(playerid,COLOR_RED,string);//
            
format(string2sizeof(string), "Admin Action: %s has unfreezed %s because: %s",n,on,reason);
            
SendClientMessageToAll(COLOR_RED,string2);
            
TogglePlayerControllable(playerid,1);
            }
        }
        else return 
SendClientMessage(playerid,COLOR_RED,"  You are not allowed to use this command!");
        return 
1;
    } 
And im getting the error

Код:
C:\Documents and Settings\Chris\Desktop\Desktop\Mastalol\Grand Theft Auto San Andreas Samp Server\filterscripts\SideShock.pwn(224) : error 001: expected token: ";", but found "return"
C:\Documents and Settings\Chris\Desktop\Desktop\Mastalol\Grand Theft Auto San Andreas Samp Server\filterscripts\SideShock.pwn(225) : warning 225: unreachable code
C:\Documents and Settings\Chris\Desktop\Desktop\Mastalol\Grand Theft Auto San Andreas Samp Server\filterscripts\SideShock.pwn(225) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Chris\Desktop\Desktop\Mastalol\Grand Theft Auto San Andreas Samp Server\filterscripts\SideShock.pwn(225) : warning 215: expression has no effect
C:\Documents and Settings\Chris\Desktop\Desktop\Mastalol\Grand Theft Auto San Andreas Samp Server\filterscripts\SideShock.pwn(225) : error 001: expected token: ";", but found "if"



Re: I have a sscanf warning please help - Burridge - 27.07.2011

pawn Код:
sscanf(params,"uS[35](no reason)",id, reason) return SendClientMessage(playerid,COLOR_RED,"Usage:/unfreeze [ID] [reason]");
Should be

pawn Код:
if(sscanf(params,"uS[35](no reason)",id, reason)) return SendClientMessage(playerid,COLOR_RED,"Usage:/unfreeze [ID] [reason]");



Re: I have a sscanf warning please help - Shockey HD - 27.07.2011

Quote:
Originally Posted by Burridge
Посмотреть сообщение
pawn Код:
sscanf(params,"uS[35](no reason)",id, reason) return SendClientMessage(playerid,COLOR_RED,"Usage:/unfreeze [ID] [reason]");
Should be

pawn Код:
if(sscanf(params,"uS[35](no reason)",id, reason)) return SendClientMessage(playerid,COLOR_RED,"Usage:/unfreeze [ID] [reason]");
Thank you, fixed, Thanks everyone i just didnt understand it fully. Thanks Burridge


Re: I have a sscanf warning please help - Burridge - 27.07.2011

No problem. Glad I could help.


Re: I have a sscanf warning please help - Shockey HD - 27.07.2011

Quote:
Originally Posted by Burridge
Посмотреть сообщение
No problem. Glad I could help.
I +Reped xD