Ban, Kick etc - 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: Ban, Kick etc (
/showthread.php?tid=177185)
Ban, Kick etc -
Garc1a - 16.09.2010
I searched 'kick' and 'ban' on SAMP Wiki and it told me how to ban/kick myself, but I want it to be like this: /kick [playerid] [reason], and then when it kicks/bans them it says to all players
'AdmCmd: Adminname has kicked/banned playername, Reason: reason'
Also must be logged into RCON.
Any ideas?
Re: Ban, Kick etc -
Virtual1ty - 16.09.2010
I suggest you to use
zcmd+
sscanf2
The example code will look like:
pawn Код:
CMD:kick(playerid, params[])
{
new
string[128],
reason[64],
sendername[MAX_PLAYER_NAME],
giveplayername[MAX_PLAYER_NAME],
giveplayerid;
if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessage(playerid, 0xBFC0C2FF, "USAGE: /kick [playerid/PartOfName] [reason]");
if(IsPlayerAdmin(playerid)
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "-| Administrator %s kicked %s. [Reason: %s ] |-", sendername, giveplayername, reason);
//SendClientMessageToAdmins(ADMIN_RED, string, 1);
SendClientMessageToAll(0x00000FF, string);
Kick(giveplayerid);
}
}
else
{
SendClientMessage(playerid, 0x00000FF, "You must be logged in to RCON !");
}
return 1;
}
Re: Ban, Kick etc -
Garc1a - 16.09.2010
Quote:
Originally Posted by Virtual1ty
I suggest you to use zcmd+ sscanf2
The example code will look like:
pawn Код:
CMD:kick(playerid, params[]) { new string[128], reason[64], sendername[MAX_PLAYER_NAME], giveplayername[MAX_PLAYER_NAME], giveplayerid; if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessage(playerid, 0xBFC0C2FF, "USAGE: /kick [playerid/PartOfName] [reason]"); if(IsPlayerAdmin(playerid) { if(giveplayerid != INVALID_PLAYER_ID) { GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername)); GetPlayerName(playerid, sendername, sizeof(sendername)); format(string, sizeof(string), "-| Administrator %s kicked %s. [Reason: %s ] |-", sendername, giveplayername, reason); //SendClientMessageToAdmins(ADMIN_RED, string, 1); SendClientMessageToAll(0x00000FF, string); Kick(giveplayerid); } } else { SendClientMessage(playerid, 0x00000FF, "You must be logged in to RCON !"); } return 1; }
|
But my whole server uses strcmp
Re: Ban, Kick etc -
Virtual1ty - 16.09.2010
Well then if your GameMode does not have many lines, I strongly suggest you to start using zcmd+sscanf in combination with foreach, as speed and efficiency wins!
Re: Ban, Kick etc -
Garc1a - 16.09.2010
Quote:
Originally Posted by Virtual1ty
Well then if your GameMode does not have many lines, I strongly suggest you to start using zcmd+sscanf in combination with foreach, as speed and efficiency wins!
|
It's got alot of lines, I can't just switch now, can you help me using strcmp?
Re: Ban, Kick etc -
BO$$ - 23.10.2010
that is good to male your own admin system
Re: Ban, Kick etc -
pushingmyluck - 23.10.2010
WONT WORK HE WANTS TO BE LOGGED IN TO RCON
Respuesta: Ban, Kick etc -
The_Moddler - 23.10.2010
You should switch to sscanf and zcmd.. with strcmp and strok is more difficult and less efficient.