SSCANF + STRCMP.
#1

I want to make a command with sscanf, something about this: /admin [kick/ban] [id]
I had some issues with my vehicle sys, so can somebody show me example similiar to this ^?
Thanks in advance.
Reply
#2

Just a example:
pawn Код:
if(sscanf(params,"us[64]",targetid, reason))
Reply
#3

Sscanf:
Код:
Specifier(s)			Name				Example values
	i, d			Integer				1, 42, -10
	c			Character			a, o, *
	l			Logical				true, false
	b			Binary				01001, 0b1100
	h, x			Hex				1A, 0x23
	o			Octal				045 12
	n			Number				42, 0b010, 0xAC, 045
	f			Float				0.7, -99.5
	g			IEEE Float			0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
	u			User name/id (bots and players)	******, 0
	q			Bot name/id			ShopBot, 27
	r			Player name/id			******, 42
Reply
#4

pawn Код:
COMMAND:admin(playerid, params[])
{
    new
        id,
        str[128];
    if(sscanf(params, "s[128]u", str, id)) return SendClientMessage(playerid, -1, "Usage: /admin [kick/ban] [id/name]");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "No connected player");
    if(strcmp(str, "ban", true) == 0)
    {
        Ban(id);
    }
    else if(strcmp(str, "kick", true) == 0)
    {
        Kick(id);
    }
    return 1;
}
No tested.
Reply
#5

I think I got it, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)