SA-MP Forums Archive
Command help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command help (/showthread.php?tid=264778)



Command help - Wesley221 - 27.06.2011

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


Re: Command help - Raimis_R - 27.06.2011

You using strcmp?


Re: Command help - Wesley221 - 27.06.2011

Zcmd + sscanf


Re: Command help - Raimis_R - 27.06.2011

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


Re: Command help - Wesley221 - 27.06.2011

Ooh didnt know that
Thanks

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


Re: Command help - Raimis_R - 27.06.2011

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

/akill smith

You need enter or

/akill lemmy

or /akill Lemmy_Smith

or id


Re: Command help - Markx - 27.06.2011

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'


Re: Command help - Wesley221 - 27.06.2011

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