SSCANF Help -
Raefal - 09.11.2014
How to create command /pay [Playerid] [dollar.cent] wiht sscanf?
sscanf("up<.>dd",playerid, dollar, cent) // This function will work?
And how to make cent just can have 2 character lengt? like 10-99
Re: SSCANF Help -
UltraScripter - 09.11.2014
pawn Код:
if(sscanf(params, "us" playerid, dollar, cent))
Re: SSCANF Help -
Raefal - 09.11.2014
Not working bro.
Quote:
Originally Posted by UltraScripter
pawn Код:
if(sscanf(params, "us" playerid, dollar, cent))
|
Re: SSCANF Help -
DavidBilla - 09.11.2014
First
sscanf(params,"u",playerid)
Then
sscanf(params,"p<.>{u}i<10-99>i",dollar, cent)
Check it out, I'm not sure if using p specifier in middle of other specifiers would work, so i made use of quiet sections and split the code to two halves
Re: SSCANF Help -
Raefal - 09.11.2014
I will test it . .
Re: SSCANF Help -
biker122 - 09.11.2014
You can use Float (f), can't you?
Re: SSCANF Help -
HY - 09.11.2014
pawn Код:
CMD:pay(playerid,params[])
{
new id;
new dollar;
new string[128];
new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(sscanf(params, "ii", id, dollar)) return SendClientMessage(playerid, -1, "USAGE: /Pay [ID] [Money]");
GivePlayerMoney(id, dollar)
format(string, sizeof(string), "You gave to %s money %i !", id, dollar);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "You received %i money from %s !", dollar, name);
SendClientMessage(id, -1, string);
return 1;
}
Re: SSCANF Help -
Raefal - 09.11.2014
i had, but not working, just make me confused
Quote:
Originally Posted by biker122
You can use Float (f), can't you?
|
I hate that format bro. . .
Quote:
Originally Posted by HY
pawn Код:
CMD:pay(playerid,params[]) { new id; new dollar; new string[128]; new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); if(sscanf(params, "ii", id, dollar)) return SendClientMessage(playerid, -1, "USAGE: /Pay [ID] [Money]"); GivePlayerMoney(id, dollar) format(string, sizeof(string), "You gave to %s money %i !", id, dollar); SendClientMessage(playerid, -1, string); format(string, sizeof(string), "You received %i money from %s !", dollar, name); SendClientMessage(id, -1, string); return 1; }
|
Re: SSCANF Help -
UltraScripter - 09.11.2014
wait let me think
Re: SSCANF Help -
Raefal - 09.11.2014
Hi all, i have fix this problem, if you need it too just copy that code:
Код:
CMD:sscanftest(playerid, params[])
{
new
dollar,
cent,
string[12];
if (sscanf(params, "uS()[12]", playerid, string))
return SendErrorMessage(playerid, "/sscanf [playerid]");
if (sscanf(string, "p<.>dd<10-99>", dollar, cent))
return SendErrorMessage(playerid, "/sscanf [playerid] [dollar.cent]");
printf("%d", playerid); // Will be print playerid
printf("%d", dollar); // Will be print dollar
printf("%d", cent); // Will be print cent
return 1;
}
Error: Show this message : sscanf warning: Format specifier does not match parameter count.
and <10-99> not working
Sorry for my bad english
! Thanks all for help me
!