Ban and Kick -
nicholas1 - 09.12.2012
Here is the script
if( strcmp( cmdtext, "/banp", true ) == 0 )
{
// Ban the player who types this command.
Ban(playerid);
return 1;
}
if(strcmp(cmdtext, "/kickp", true) == 0)
{
//Kicks the player who the executed this command
Kick(playerid);
return 1;
}
I dont want the player who types /banp get ban.I want it like the person type /banp then id and that person gets ban.For /kickp I want it same as /banp.Not kick the person who types it.Kick the person like /kickp id.
Re: Ban and Kick -
HireMe - 09.12.2012
Most of the admin scripts already got /ban /kick functions
You can check some out with the following link:
https://sampforum.blast.hk/showthread.php?tid=356383
You can get the code from those scripts and then just adjust them to your admin system.
Re: Ban and Kick -
nicholas1 - 10.12.2012
Quote:
Originally Posted by HireMe
|
Thanks.But,nah I will just try to make it basic.By myself and with some friends.I will just work on my own 1.
Re: Ban and Kick -
Devilxz97 - 10.12.2012
move on with zcmd and sscanf2 much better ,
/kick /ban
pawn Код:
CMD:kick(playerid, params[])
{
if(!IsPlayerAdmin(playerid))
{
new reason[24];
new id;
if(sscanf(params, "us[24]", id, reason)) return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}/kick (playerid/partofname) (reason)");
else
{
new str[256];
new Admin[MAX_PLAYER_NAME];
new Target[MAX_PLAYER_NAME];
GetPlayerName(id, Target, sizeof(Target));
GetPlayerName(playerid, Admin, sizeof(Admin));
format(str, sizeof(str), "[{B4B5B7}Admin{FF6347}]{B4B5B7}'%s has kick {FF6347}[{B4B5B7}Player{FF6347}]{B4B5B7}'%s. {FF6347}Reason; {B4B5B7}%s .", Admin, Target, reason);
SendClientMessageToAll(lightred, str);
Kick(id);
}
}
else return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}You aren't authorized to use this command.");
return 1;
}
#define grey 0xB4B5B7FF
#define lightred 0xFF6347AA
CMD:ban(playerid, params[])
{
if(!IsPlayerAdmin(playerid))
{
new id;
new reason[128];
if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}/ban (playerid/partofname) (reason)");
if(PlayerInfo[playerid][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, lightred,"[{B4B5B7}System{FF6347}]: {B4B5B7}You cant ban an Administrator!");
if(id == playerid) return SendClientMessage(playerid, lightred,"[{B4B5B7}System{FF6347}]: {B4B5B7}You cant ban yourself!");
if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}Player not found!");
else
{
new year;
new month;
new day;
new hour;
new minuite;
new second;
new str[1000];
new Admin[MAX_PLAYER_NAME];
new Target[MAX_PLAYER_NAME];
getdate(year, month, day);
gettime(hour,minuite,second);
GetPlayerName(playerid, Admin, sizeof(Admin));
GetPlayerName(id, Target, sizeof(Target));
format(str, sizeof(str), "[{B4B5B7}Admin{FF6347}]{B4B5B7}'%s has ban {FF6347}[{B4B5B7}Player{FF6347}]{B4B5B7}'%s. {FF6347}Reason; {B4B5B7}%s .", Admin, Target, reason);
SendClientMessageToAll(lightred, str);
#define DIALOG_BAN 9706
format(str, sizeof(str), "{FF6347}Admin Name: {B4B5B7}%s .\n{FF6347}Date: {B4B5B7}%d{FF6347}/{B4B5B7}%d{FF6347}/{B4B5B7}%d .\n{FF6347}Time: {B4B5B7}%d{FF6347}:{B4B5B7}%d .\n{FF6347}Reason: {B4B5B7}%s .", Admin, day, month, year, hour, minuite, reason);
ShowPlayerDialog(id, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "Ban Notice", str, "OK", "");
Ban(id);
}
}
else return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}You aren't authorized to use this command.");
return 1;
}
Re: Ban and Kick -
GoldZoroGrab - 10.12.2012
Quote:
Originally Posted by Devilxz97
move on with zcmd and sscanf2 much better ,
/kick /ban
pawn Код:
CMD:kick(playerid, params[]) { if(!IsPlayerAdmin(playerid)) { new reason[24]; new id; if(sscanf(params, "us[24]", id, reason)) return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}/kick (playerid/partofname) (reason)"); else { new str[256]; new Admin[MAX_PLAYER_NAME]; new Target[MAX_PLAYER_NAME];
GetPlayerName(id, Target, sizeof(Target)); GetPlayerName(playerid, Admin, sizeof(Admin));
format(str, sizeof(str), "[{B4B5B7}Admin{FF6347}]{B4B5B7}'%s has kick {FF6347}[{B4B5B7}Player{FF6347}]{B4B5B7}'%s. {FF6347}Reason; {B4B5B7}%s .", Admin, Target, reason); SendClientMessageToAll(lightred, str);
Kick(id); } } else return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}You aren't authorized to use this command."); return 1; }
#define grey 0xB4B5B7FF #define lightred 0xFF6347AA
CMD:ban(playerid, params[]) { if(!IsPlayerAdmin(playerid)) { new id; new reason[128]; if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}/ban (playerid/partofname) (reason)"); if(PlayerInfo[playerid][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, lightred,"[{B4B5B7}System{FF6347}]: {B4B5B7}You cant ban an Administrator!"); if(id == playerid) return SendClientMessage(playerid, lightred,"[{B4B5B7}System{FF6347}]: {B4B5B7}You cant ban yourself!"); if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}Player not found!"); else { new year; new month; new day;
new hour; new minuite; new second;
new str[1000];
new Admin[MAX_PLAYER_NAME]; new Target[MAX_PLAYER_NAME];
getdate(year, month, day); gettime(hour,minuite,second); GetPlayerName(playerid, Admin, sizeof(Admin)); GetPlayerName(id, Target, sizeof(Target));
format(str, sizeof(str), "[{B4B5B7}Admin{FF6347}]{B4B5B7}'%s has ban {FF6347}[{B4B5B7}Player{FF6347}]{B4B5B7}'%s. {FF6347}Reason; {B4B5B7}%s .", Admin, Target, reason); SendClientMessageToAll(lightred, str);
#define DIALOG_BAN 9706 format(str, sizeof(str), "{FF6347}Admin Name: {B4B5B7}%s .\n{FF6347}Date: {B4B5B7}%d{FF6347}/{B4B5B7}%d{FF6347}/{B4B5B7}%d .\n{FF6347}Time: {B4B5B7}%d{FF6347}:{B4B5B7}%d .\n{FF6347}Reason: {B4B5B7}%s .", Admin, day, month, year, hour, minuite, reason); ShowPlayerDialog(id, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "Ban Notice", str, "OK", "");
Ban(id); } } else return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}You aren't authorized to use this command."); return 1; }
|
1- thats wrong, the player won't get the unban when time finish
2- he didn't ask for the time
Code:
Kick:
pawn Код:
command(kick, playerid, params[])
{
new ID, reason[100];
if(sscanf(params, "is", ID, reason)) SendClientMessage(playerid, BLANCO, "USAGE: /kick [id] [reason]");
else if(IsPlayerConnected(ID) == 0) SendClientMessage(playerid, ROJO, "Player is not connected");
else
{
GetPlayerName(ID, name2, 60);
format(string, 256, "[ADMIN-KICK]Roze: %s[%d] Has Been Kicked From The Server - %s", name2, ID, reason);
SendClientMessageToAll(AC, string);
Kick(playerid);
return 1;
}
}
pawn Код:
command(ban, playerid, params[])
{
new ID, reason[100];
if(sscanf(params, "is", ID, reason)) SendClientMessage(playerid, BLANCO, "USAGE: /kick [id] [reason]");
else if(IsPlayerConnected(ID) == 0) SendClientMessage(playerid, ROJO, "Player is not connected");
else
{
GetPlayerName(ID, name2, 60);
format(string, 256, "[ADMIN-KICK]Roze: %s[%d] Has Been Kicked From The Server - %s", name2, ID, reason);
SendClientMessageToAll(AC, string);
Kick(playerid);
return 1;
}
return 1;
}
Re: Ban and Kick -
Konstantinos - 10.12.2012
@nicholas1
- You're using
playerid as a result you'll kick/ban the person who typed the command. You will need strtok for the
id. However, strcmp and strtok are too damn slow and outdated. I'd recomment you to use ZCMD + sscanf as it's an amazing combination and it's really fast/easy.
pawn Код:
CMD:kick( playerid, params[ ] )
{
if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You are not an Admin!" );
new
id,
reason[ 64 ]
;
if( sscanf( params, "rs[64]", id, reason ) ) return SendClientMessage( playerid, -1, "Usage: /kick <ID/Part Of Name>" );
if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "That player is not connected!" );
new
name[ MAX_PLAYER_NAME ],
string[ 128 ]
;
GetPlayerName( id, name, MAX_PLAYER_NAME );
format( string, sizeof( string ), "%s has been kicked by Administrator! (Reason: %s)", name, reason );
SendClientMessageToAll( -1, string );
Kick( id );
return 1;
}
CMD:ban( playerid, params[ ] )
{
if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You are not an Admin!" );
new
id,
reason[ 64 ]
;
if( sscanf( params, "rs[64]", id, reason ) ) return SendClientMessage( playerid, -1, "Usage: /ban <ID/Part Of Name>" );
if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "That player is not connected!" );
new
name[ MAX_PLAYER_NAME ],
string[ 128 ]
;
GetPlayerName( id, name, MAX_PLAYER_NAME );
format( string, sizeof( string ), "%s has been banned by Administrator! (Reason: %s)", name, reason );
SendClientMessageToAll( -1, string );
Ban( id );
return 1;
}
Quote:
Originally Posted by GoldZoroGrab
1- thats wrong, the player won't get the unban when time finish
2- he didn't ask for the time
Code:
Kick:
pawn Код:
command(kick, playerid, params[]) { new ID, reason[100]; if(sscanf(params, "is", ID, reason)) SendClientMessage(playerid, BLANCO, "USAGE: /kick [id] [reason]"); else if(IsPlayerConnected(ID) == 0) SendClientMessage(playerid, ROJO, "Player is not connected"); else { GetPlayerName(ID, name2, 60); format(string, 256, "[ADMIN-KICK]Roze: %s[%d] Has Been Kicked From The Server - %s", name2, ID, reason); SendClientMessageToAll(AC, string); Kick(playerid); return 1; } }
pawn Код:
command(ban, playerid, params[]) { new ID, reason[100]; if(sscanf(params, "is", ID, reason)) SendClientMessage(playerid, BLANCO, "USAGE: /kick [id] [reason]"); else if(IsPlayerConnected(ID) == 0) SendClientMessage(playerid, ROJO, "Player is not connected"); else { GetPlayerName(ID, name2, 60); format(string, 256, "[ADMIN-KICK]Roze: %s[%d] Has Been Kicked From The Server - %s", name2, ID, reason); SendClientMessageToAll(AC, string); Kick(playerid); return 1; } return 1; }
|
That's also wrong.
Sscanf specifiers: "is". It's "r" or "u" for ID/Part Of Name and "s[size]". Otherwise, it will give you error by sscanf in the server window. The messages are wrong and you kick player in both. And Player name's limit is 24, not 60..
Re: Ban and Kick -
nicholas1 - 11.12.2012
Man this admin thing is hard.I still dont get where to add it.
I already tried it.I already have lots of commands I made for my server and stuff.