SSCANF Help
#1

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
Reply
#2

pawn Код:
if(sscanf(params, "us" playerid, dollar, cent))
Reply
#3

Not working bro.

Quote:
Originally Posted by UltraScripter
Посмотреть сообщение
pawn Код:
if(sscanf(params, "us" playerid, dollar, cent))
Reply
#4

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
Reply
#5

I will test it . .
Reply
#6

You can use Float (f), can't you?
Reply
#7

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;
}
Reply
#8

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;
}
Reply
#9

wait let me think
Reply
#10

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 !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)