[HELP] making reasons with sscanf -
AK47317 - 19.04.2011
hey guys.. i had a little problem making reason for giving cookies for my cookie system using sscanf made by ******. Anyone who would explain this i may thank him for helping

.
pawn Код:
CMD:givecookies ( playerid , params [ ] ) {
if ( Account [ playerid ] [ Cookies ] < 1 )
return SendClientMessage ( playerid , -1 , ""#RED"ERROR: "#YELLOW"You don't have enough "#RED"Cookies "#YELLOW" to give to other players" ) ;
if ( sscanf ( params , "ui" , params [ 0 ] , params [ 1 ] ) )
return SendClientMessage ( playerid , -1 , ""#ORANGE"USAGE: "#YELLOW"/givecookies "#RED" [ playerid ] [ amount ] [ reasons ]" ) ;
if ( !IsPlayerConnected ( params [ 0 ] ) )
return SendClientMessage ( playerid , -1 , ""#RED"ERROR: "#YELLOW"No player "#LIGHTBLUE"connected" ) ;
Account [ params [ 0 ] ] [ Cookies ] += params [ 1 ] ;
Account [ playerid ] [ Cookies ] -= params [ 1 ] ;
SaveFileInINI ( playerid ) ;
if ( sscanf ( params [ 2 ] , "s" ) ) {
new
str [ MAX_STRINGS ] ;
format ( str , sizeof ( str ) , ""#PURPLE"%s "#YELLOW" has give you "#RED"%i Cookies. "#LIGHTBLUE"[ "#YELLOW"Reasons: "#RED"%s "#LIGHTBLUE"]" , iName ( playerid ) , params [ 1 ] , params [ 2 ] ) ;
SendClientMessage ( params [ 0 ] , -1 , str ) ;
}
else {
new
str [ MAX_STRINGS ] ;
format ( str , sizeof ( str ) , ""#PURPLE"%s "#YELLOW" has give you "#RED"%i Cookies. "#LIGHTBLUE"[ "#YELLOW"Reasons: "#RED"Not Specified "#LIGHTBLUE"]" , iName ( playerid ) , params [ 1 ] ) ;
SendClientMessage ( params [ 0 ] , -1 , str ) ;
}
return 1 ;
}
Re: [HELP] making reasons with sscanf -
Gh0sT_ - 19.04.2011
if ( sscanf ( params [ 2 ] , "s" ) )
>
if ( ! sscanf ( params [ 2 ] , "s" ) )
Re: [HELP] making reasons with sscanf -
AK47317 - 19.04.2011
it gave me this
Код:
/givecookies [ id ] 10 test
Mubarrak48 has gave you 10 cookies. [ reasons: 10 test ]
Код:
/givecookies [ id ] 10
Mubarrak has gave you 10 cookies. [ reasons: 10 ]
how could be that happen?
Re: [HELP] making reasons with sscanf -
AK47317 - 20.04.2011
bump this sscanf with reason were very hard.. come on for those pro scripters help the newbie

. if you kind plz help me for solving this little bit case of problem.
Re: [HELP] making reasons with sscanf -
Haydz - 20.04.2011
Firstly you need to create your reason, for example
new reason[100]; //You can make the string length whatever you want but as small as possible for efficiency.
then in the sscanf line put 's[100]' once again [100] is the string length use the same as you have above, you also need to put the reason after the quote marks like.
pawn Код:
if(ssacnf(params,"s[100]",reason))
Then you can use 'reason' wherever you want and it will display the params which the player entered.
you can use this command below as an example.
pawn Код:
command(reason,playerid,params[])
{
new reason[75],string[90]
if(sscanf(params,"s[100]",reason)) return usage... /reason [reason]
format(string,sizeof(string),"Your reason was: %s",reason);
SendClientMessage(playerid, COLOR,string);
return 1;
}
EDIT: I think i may have read your questions incorrectly, sorry about that.
Re: [HELP] making reasons with sscanf -
AK47317 - 20.04.2011
Quote:
Originally Posted by ******
Are you using the plugin or the include?
|
the plugin one of-course
Re: [HELP] making reasons with sscanf -
Babul - 20.04.2011
Код:
CMD:givecookies(playerid,params[]){
new TargetID,Amount,Reason[64];
if(sscanf(params,"udS(Not Specified)[64]",TargetID,Amount,Reason)
{
return SendClientMessage(playerid,-1,"/givecookies <ID/Name> <Amount> [reason]");
}
if(Account[playerid][Cookies]<Amount)
{
return SendClientMessage(playerid,-1,""#RED"ERROR: "#YELLOW"You don't have enough "#RED"Cookies "#YELLOW" to give to other players");
}
Account[TargetID][Cookies]+=Amount;
Account[playerid][Cookies]-=Amount;
SaveFileInINI(playerid);
new str[MAX_STRINGS];
format(str,sizeof(str),""#PURPLE"%s "#YELLOW" has give you "#RED"%i Cookies. "#LIGHTBLUE"[ "#YELLOW"Reasons: "#RED"%s "#LIGHTBLUE"]",iName(playerid),Amount,Reason);
SendClientMessage(playerid,-1,str);
return 1 ;
}
...not tested, i never used (default values) for an optional string yet...