[HELP] 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: [HELP] Command... (
/showthread.php?tid=119226)
[HELP] Command... -
waza75 - 07.01.2010
Hiya, I am trying to make a kick command with sscanf for some practise but now I am stuck. Could anyone help out? Thanks.
Code so far:
Код:
COMMAND:kick(playerid, params[])
{
new kickid, reason[64];
if (!sscanf(params, "uz", kickid, reason;)) SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /kick <playerid> <reason>");
else if (kickid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFFFFFFFF, "Player not found");
else if (!IsPlayerAdmin(playerid)) SendClientMessage(playerid, 0xFFFFFFFF, "You need to be admin");
else
{
Kick(kickid, reason);
// What do I need to do here?
}
return 1;
}
See the comment in the code up.
Is this the right way or should it be like:
Код:
COMMAND:kick(playerid, params[])
{
new kickid, reason;
if(sscanf(params, "uz", kickid, reason)) SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /ban <playerid> <reason>");
{
if(kickid != INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFFFFFFFF, "Player not found");
else if(!IsPlayerAdmin(playerid)) SendClientMessage(playerid, 0xFFFFFFFF, "You need to be admin");
else
{
Kick(kickid, reason);
// Same as the other code, what do I need to do here?
}
return 1;
}
Thanks, any help will be appreciated. ;o
Re: /kick -
waza75 - 07.01.2010
I made this now, is it any good?
Код:
COMMAND:kick(playerid, params[])
{
new kickid, reason;
if(sscanf(params, "uz", kickid, reason)) SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /ban <playerid> <reason>");
{
if(kickid != INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFFFFFFFF, "Player not found");
else if(!IsPlayerAdmin(playerid)) SendClientMessage(playerid, 0xFFFFFFFF, "You need to be admin");
else
{
new string[64];
Kick(kickid, reason);
GetPlayerName(kickid, Pname, sizeof(Pname);
format(reason, sizeof,(reason),
format(string, sizeof(string), "%s has been kicked reason: %d" Pname, reason);
SendClientMessageToAll(0xFFFFFFFF, string, reason);
SendClientMessage(playerid, 0xFFFFFFFF, "Player kicked");
}
return 1;
}