24.02.2009, 14:50
i will unconfuse it for you
put the define line at the top of your script with the variables
goto OnPlayerCommandText
type in
than goto the bottom of your script and make a function called, and with the paramaters of
now about sscanf, this can be used in many places, not just in cmds, but i will teach you for commands.(put sscanf in your script)
the usage is like this
so you could do it in an if like this
so i will convert your command so you can understand.
this could be easily be converted so reason is optional, and almost as easy to make it not say Reason: than nothing here
hope i could help
put the define line at the top of your script with the variables
goto OnPlayerCommandText
type in
pawn Код:
dcmd(kick, 4, cmdtext); //command name without '/', length of command, and cmdtext(in case you renamed cmdtext to something else, you would change that)
pawn Код:
dcmd_kick(playerid, params[])
the usage is like this
pawn Код:
sscanf(params, "us", pid, reason) //u is a userid or name, s is a string, z is optional string
pawn Код:
if (sscanf(params, "us", pid, reason)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /kick [playerid] [reason]");
pawn Код:
dcmd_kick(playerid, params[])
{
new pid, reason;
if (sscanf(params, "us", pid, reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /kick [playerid] [reason]
if(Level[playerid] == 0) return 0;
new pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME] string[128];
GetPlayerName(playerid, pname1, 24);
GetPlayerName(pid, pname2, 24);
format(string, sizeof(string), "**KICK [ADMIN KICK] %s Has Been Kicked From The Server By Admin %s Reason:%s.", pname2, pname1, reason);
SendClientMessageToAll(pink, string);
Kick(pid);
return 1;
hope i could help