Help me to make /kick and /ban -
kemppis_ - 27.03.2011
Please someone, i need /kick & /ban command..
can you make it for me?
Re: Help me to make /kick and /ban -
sansko - 27.03.2011
there is already one examlpe in the server package
look in the fs base and baseaf
Re: Help me to make /kick and /ban -
[ProX]BlueFire - 27.03.2011
Kick
Код:
if(strcmp(cmd, "/kick", true) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, BLUE, "USAGE: /kick [playerid] [reason]");
return 1;
}
new player;
player = strval(tmp);
if(!IsPlayerConnected(player) || player == INVALID_PLAYER_ID)
{
SendClientMessage(playerid,HOMER,"Player disconnected, or its yourself!");
return 1;
}
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(AdminLvl[playerid] >= 2)
{
tmp = strtok(cmdtext, idx);
GetPlayerName(player, pName, sizeof(pName));
GetPlayerName(playerid, aName, sizeof(aName));
format(string,256," %s has been kicked by admin %s. Reason: %s",pName,aName,(result));
SendClientMessageToAll(ORANGE,string);
//Kick(player);
}else{
SendClientMessage(playerid,HOMER," You are not an higher level to use this command");
}
return 1;
}
Ban:
Код:
if(strcmp(cmd, "/ban", true) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, BLUE, "USAGE: /ban [playerid] [reason]");
return 1;
}
new player;
player = strval(tmp);
if(!IsPlayerConnected(player) || player == INVALID_PLAYER_ID)
{
SendClientMessage(playerid,HOMER,"Player disconnected, or its yourself!");
return 1;
}
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(AdminLvl[playerid] >= 3)
{
tmp = strtok(cmdtext, idx);
GetPlayerName(player, pName, sizeof(pName));
GetPlayerName(playerid, aName, sizeof(aName));
format(string,256,"%s has been banned by admin %s. Reason: %s",pName,aName,(result));
SendClientMessageToAll(ORANGE,string);
//Ban(player);
}else{
SendClientMessage(playerid,HOMER,"You are not an higher level to use this command");
}
return 1;
}
Re: Help me to make /kick and /ban -
HyperZ - 27.03.2011
I suggest you to use
Zcmd +
Sscanf2:
Kick:
pawn Код:
CMD:kick( playerid, params[ ] )
{
new ID, string[128], reason[66];
if( !IsPlayerAdmin( playerid ) ) return 0;
if(sscanf(params, "uS(No Reason Given)[65]", ID, reason)) return SendClientMessage(playerid, -1, "USAGE: /kick [PlayerID] [reason]");
if(IsPlayerConnected(ID) && ID != INVALID_PLAYER_ID && ID != playerid)
{
format(string,sizeof(string), "You are kicked by Administrator \"%s\" Reason: %s", pName(playerid),reason);
SendClientMessage(ID , -1, string);
format(string, sizeof(string), "You have kicked \"%s\" Reason: %s", pName(ID), reason);
SendClientMessage(playerid, -1 , string);
format(string, sizeof(string), "Administrator \"%s\" has kicked \"%s\" Reason: %s",pName(playerid),pName(ID),reason);
SendClientMessageToAll( -1 , string );
TogglePlayerControllable(ID, false);
Kick(ID);
printf(string);
}
else return SendClientMessage(playerid, -1, "Player is not connected or is yourself");
return 1;
}
Ban:
pawn Код:
CMD:ban( playerid, params[ ] )
{
new ID, string[128], reason[66];
if( !IsPlayerAdmin( playerid ) ) return 0;
if(sscanf(params, "uS(No Reason Given)[65]", ID, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [PlayerID] [reason]");
if(IsPlayerConnected(ID) && ID != INVALID_PLAYER_ID && ID != playerid)
{
format(string,sizeof(string), "You are Banned by Administrator \"%s\" Reason: %s", pName(playerid),reason);
SendClientMessage(ID , -1, string);
format(string, sizeof(string), "You have Banned \"%s\" Reason: %s", pName(ID), reason);
SendClientMessage(playerid, -1 , string);
format(string, sizeof(string), "Administrator \"%s\" has Banned \"%s\" Reason: %s",pName(playerid),pName(ID),reason);
SendClientMessageToAll( -1 , string );
TogglePlayerControllable(ID, false);
Ban(ID);
printf(string);
}
else return SendClientMessage(playerid, -1, "Player is not connected or is yourself");
return 1;
}
Somewhere in your script:
pawn Код:
stock pName(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}
Re: Help me to make /kick and /ban -
Mr_Scripter - 27.03.2011
Both
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
//Kick Command
if(strcmp("/kick", cmd, true) == 0)
{
if(IsPlayerAdmin(playerid)) {
tmp = strtok(cmdtext,idx);
if(!strlen(tmp) || strlen(tmp) > 5) {
return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /kick (id) [reason]");
}
new id = strval(tmp);
if(!IsPlayerConnected(id)) {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/kick : Bad player ID");
return 1;
}
gMessage = strrest(cmdtext,idx);
GetPlayerName(id,iName,sizeof(iName));
SendClientMessage(id,ADMINFS_MESSAGE_COLOR,"-- You have been kicked from the server.");
if(strlen(gMessage) > 0) {
format(Message,sizeof(Message),"Reason: %s",gMessage);
SendClientMessage(id,ADMINFS_MESSAGE_COLOR,Message);
}
format(Message,sizeof(Message),">> %s(%d) has been kicked.",iName,id);
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,Message);
Kick(id);
return 1;
} else {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/kick : You are not an admin");
return 1;
}
}
//Ban Command
if(strcmp("/ban", cmd, true) == 0)
{
if(IsPlayerAdmin(playerid)) {
tmp = strtok(cmdtext,idx);
if(!strlen(tmp) || strlen(tmp) > 5) {
return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /ban (id) [reason]");
}
new id = strval(tmp);
if(!IsPlayerConnected(id)) {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/ban : Bad player ID");
return 1;
}
gMessage = strrest(cmdtext,idx);
GetPlayerName(id,iName,sizeof(iName));
SendClientMessage(id,ADMINFS_MESSAGE_COLOR,"-- You have been banned from the server.");
if(strlen(gMessage) > 0) {
format(Message,sizeof(Message),"Reason: %s",gMessage);
SendClientMessage(id,ADMINFS_MESSAGE_COLOR,Message);
}
format(Message,sizeof(Message),">> %s(%d) has been banned.",iName,id);
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,Message);
Ban(id);
return 1;
} else {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/ban : You are not an admin");
return 1;
}
}
return 0;
}
Re: Help me to make /kick and /ban -
[ProX]BlueFire - 27.03.2011
xD
choose 1!
Re: Help me to make /kick and /ban -
kemppis_ - 27.03.2011
Oww
Thanks guys