Small Issue with Kick command. - 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: Small Issue with Kick command. (
/showthread.php?tid=163751)
Small Issue with Kick command. -
Toni - 28.07.2010
Hi, I'm still trying to learn 'sscanf' and I'm not to good at it, I am trying to make a kick command with a optional params for reasons.
I'm using zcmd.
pawn Код:
CMD:kick(playerid, params[])
{
new reason[128], str[128], str2[128], player1;
if(PlayerInfo[playerid][LoggedIn] == 1)
{
if(PlayerInfo[playerid][Level] >= 1)
{
if(sscanf(params, "us", player1, reason))
{
return SendClientMessage(playerid, YELLOW, "USAGE: /kick (Name/ID) (Reason)");
}
format(str, sizeof(str), "|- %s has kicked %s. | Reason: %s -|", pName(playerid), pName2(playerid), reason);
SendClientMessageToAll(BLUE, str);
Kick(player1);
}
else return SendClientMessage(playerid, RED, "ERROR: You are not a level 1 admin!");
}
else return SendClientMessage(playerid, RED, "ERROR: You need to be logged in to use these commands!");
return 1;
}
I get no errors when compiling, but I wanted to make it so where if the player doesn't want to include a reason it would say
pawn Код:
format(str2, sizeof(str2), "|- %s has kicked %s. | Reason: No reason. -|", pName(playerid), pName2(playerid));
I know how to do it using strlen(params) but I am trying to get in the habit of using sscanf.