SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 27/07/2011, 06:12 AM   #1
Shockey HD
Gangsta
 
Shockey HD's Avatar
 
Join Date: Jul 2011
Posts: 684
Reputation: 14
Default I have a sscanf warning please help

So i get these warning's

Code:
[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 Code:
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;
    } 
__________________
Shockey HD is offline  
Old 27/07/2011, 06:15 AM   #2
iggy1
High-roller
 
iggy1's Avatar
 
Join Date: Mar 2009
Location: One past the end.
Posts: 2,421
Reputation: 273
Default Re: I have a sscanf warning please help

pawn Code:
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".
iggy1 is offline  
Old 27/07/2011, 06:40 AM   #3
Shockey HD
Gangsta
 
Shockey HD's Avatar
 
Join Date: Jul 2011
Posts: 684
Reputation: 14
Default Re: I have a sscanf warning please help

Quote:
Originally Posted by iggy1 View Post
pawn Code:
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
__________________
Shockey HD is offline  
Old 27/07/2011, 06:49 AM   #4
Ironboy
High-roller
 
Ironboy's Avatar
 
Join Date: Nov 2010
Location: Isle of Man
Posts: 1,935
Reputation: 433
Default Re: I have a sscanf warning please help

See this warning
pawn Code:
[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 Code:
sscanf(params,"uZ[35](no reason)",id, reason)
The correct code is
pawn Code:
sscanf(params,"uS[35](no reason)",id, reason)
Ironboy is offline  
Old 27/07/2011, 06:54 AM   #5
Shockey HD
Gangsta
 
Shockey HD's Avatar
 
Join Date: Jul 2011
Posts: 684
Reputation: 14
Default Re: I have a sscanf warning please help

PHP Code:
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

Code:
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"
__________________
Shockey HD is offline  
Old 27/07/2011, 06:55 AM   #6
Burridge
High-roller
 
Join Date: Nov 2008
Location: England
Posts: 1,842
Reputation: 52
Default Re: I have a sscanf warning please help

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

Should be

pawn Code:
if(sscanf(params,"uS[35](no reason)",id, reason)) return SendClientMessage(playerid,COLOR_RED,"Usage:/unfreeze [ID] [reason]");
Burridge is offline  
Old 27/07/2011, 06:57 AM   #7
Shockey HD
Gangsta
 
Shockey HD's Avatar
 
Join Date: Jul 2011
Posts: 684
Reputation: 14
Default Re: I have a sscanf warning please help

Quote:
Originally Posted by Burridge View Post
pawn Code:
sscanf(params,"uS[35](no reason)",id, reason) return SendClientMessage(playerid,COLOR_RED,"Usage:/unfreeze [ID] [reason]");

Should be

pawn Code:
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
__________________
Shockey HD is offline  
Old 27/07/2011, 06:57 AM   #8
Burridge
High-roller
 
Join Date: Nov 2008
Location: England
Posts: 1,842
Reputation: 52
Default Re: I have a sscanf warning please help

No problem. Glad I could help.
Burridge is offline  
Old 27/07/2011, 06:59 AM   #9
Shockey HD
Gangsta
 
Shockey HD's Avatar
 
Join Date: Jul 2011
Posts: 684
Reputation: 14
Default Re: I have a sscanf warning please help

Quote:
Originally Posted by Burridge View Post
No problem. Glad I could help.
I +Reped xD
__________________
Shockey HD is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sscanf warning Runedog48 Help Archive 23 23/07/2011 01:56 AM
Sscanf warning ColdIce Help Archive 3 15/07/2011 01:01 PM
sscanf warning. Gh0sT_ Help Archive 5 11/04/2011 12:53 PM
sscanf warning [L3th4l] Help Archive 2 14/06/2010 03:38 AM
Warning sscanf Zafire2008 Help Archive 2 28/01/2010 09:56 PM


All times are GMT. The time now is 06:21 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.