Command help
#1

Hey guys,
Im trying to make a command to a player. Like, /akill
But the problem is, if i do /akill lemmylusion[nl] (my name), it just kills playerid 0. How would i make this possible to kill a target by name, and not by their id
~Wesley
Reply
#2

You using strcmp?
Reply
#3

Zcmd + sscanf
Reply
#4

Example

pawn Код:
command(kill, playerid, params[])
{
    new id;
    if (sscanf(params,"r", id))
    {
        return SendClientMessage(playerid, -1, "* USAGE: /kill [Nick/ID]");
    }
    SetPlayerHealth(id, -1);
    return 1;
}
And you can use ID or Name
Reply
#5

Ooh didnt know that
Thanks

--Edit:
Does this also work with just a part of a name? Like: /akill lemmy
Reply
#6

Yes with first name working but don't working with:

/akill smith

You need enter or

/akill lemmy

or /akill Lemmy_Smith

or id
Reply
#7

Quote:
Originally Posted by Raimis_R
Посмотреть сообщение
Example

pawn Код:
command(kill, playerid, params[])
{
    new id;
    if (sscanf(params,"r", id))
    {
        return SendClientMessage(playerid, -1, "* USAGE: /kill [Nick/ID]");
    }
    SetPlayerHealth(id, -1);
    return 1;
}
And you can use ID or Name
pawn Код:
command(kill, playerid, params[])
{
    new id;
    if (sscanf(params,[b]"u"[/b], id))
    {
        return SendClientMessage(playerid, -1, "* USAGE: /kill [Nick/ID]");
    }
    SetPlayerHealth(id, -1);
    return 1;
}
'r' doesnt exist in sscanf... use 'u'
Reply
#8

Quote:
Originally Posted by Markx
Посмотреть сообщение
pawn Код:
command(kill, playerid, params[])
{
    new id;
    if (sscanf(params,[b]"u"[/b], id))
    {
        return SendClientMessage(playerid, -1, "* USAGE: /kill [Nick/ID]");
    }
    SetPlayerHealth(id, -1);
    return 1;
}
'r' doesnt exist in sscanf... use 'u'
Код:
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
It actually does exist. I totally forgot about sscanf for this
And thanks again btw
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)