PDA

View Full Version : /ban command [REP +]


Dare Devil.....
19/07/2012, 12:53 PM
Ca any one help me with ban command I use YCMD some command that can ban a player and another command /ipban that can ban a ip help please
this is my kick command


YCMD:kick(playerid, params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;

if(PlayerInfo[playerid][Admin] >= 1) {
new player, reason[126];

if(sscanf(params, "us[126]", player, reason)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /kick [Part of Name/Player ID] [Reason]");

if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
new string[126];

if(PlayerInfo[playerid][Admin] < PlayerInfo[player][Admin]) {
format(string, sizeof(string), "AdmWarning: %s has been kicked because they attempted to kick a higher admin!", PlayerName(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
}

format(string, sizeof(string), "AdmWarning: %s has been kicked by %s, reason: %s", PlayerName(player), PlayerName(playerid), reason);
SendClientMessageToAll(COLOR_LIGHTRED, string);
Kick(player);

}
return 1;
}


But I need a /ban and /ipban

XStormiest
19/07/2012, 01:03 PM
YCMD:ipban(playerid,params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;

if(PlayerInfo[playerid][Admin] >= 1) {
new player, reason[126];

if(sscanf(params, "us[126]", player, reason)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /ipban [Part of Name/Player ID] [Reason]");

if(PlayerInfo[playerid][Admin] < PlayerInfo[player][Admin]) {
format(string, sizeof(string), "AdmWarning: %s has been kicked because they attempted to ipban a higher admin!", PlayerName(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);

format(string, sizeof(string), "AdmWarning: %s has been ipbanned by %s, reason: %s", PlayerName(player), PlayerName(playerid), reason);
SendClientMessageToAll(COLOR_LIGHTRED, string);
Ban(player);
}
return 1;
}

Matz
19/07/2012, 01:03 PM
YCMD:ban(playerid, params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;

if(PlayerInfo[playerid][Admin] >= 1) {
new player, reason[126];

if(sscanf(params, "us[126]", player, reason)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /ban [Part of Name/Player ID] [Reason]");

if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
new string[126];

if(PlayerInfo[playerid][Admin] < PlayerInfo[player][Admin]) {
format(string, sizeof(string), "AdmWarning: %s has been kicked because they attempted to ban a higher admin!", PlayerName(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
}

format(string, sizeof(string), "AdmWarning: %s has been banned by %s, reason: %s", PlayerName(player), PlayerName(playerid), reason);
SendClientMessageToAll(COLOR_LIGHTRED, string);
PlayerInfo[player][Banned] = 1;
Kick(playerd);

}
return 1;
}


You have to add " Banned " into your pInfo.



YCMD:banip(playerid, params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;

if(PlayerInfo[playerid][Admin] >= 1) {
new player, reason[126];

if(sscanf(params, "us[126]", player, reason)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /banip [Part of Name/Player ID] [Reason]");

if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
new string[126];

if(PlayerInfo[playerid][Admin] < PlayerInfo[player][Admin]) {
format(string, sizeof(string), "AdmWarning: %s has been kicked because they attempted to ban a higher admin!", PlayerName(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
}

format(string, sizeof(string), "AdmWarning: %s's ip adress has been banned by %s, reason: %s", PlayerName(player), PlayerName(playerid), reason);
SendClientMessageToAll(COLOR_LIGHTRED, string);
Ban(player);

}
return 1;
}

Dare Devil.....
19/07/2012, 01:09 PM
/ban dont works ipban works fine.

Dare Devil.....
19/07/2012, 01:27 PM
Any how I repped + you sice /banip worked and please I will give you another rep if you can make me /jail and /unjail player please

Matz
19/07/2012, 01:50 PM
Try these;


new IsPlayerJailed[MAX_PLAYERS]; // This is for top of script

YCMD:jail(playerid, params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;

if(PlayerInfo[playerid][Admin] >= 1) {
new player, reason[126];

if(sscanf(params, "us[126]", player, reason)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /jail [Part of Name/Player ID] [Reason]");

if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
if(IsPlayerJailed[player] == 1) return SendClientMessage(playerid, COLOR_GREY, "Player is jailed already.");
new string[126];

if(PlayerInfo[playerid][Admin] < PlayerInfo[player][Admin]) {
format(string, sizeof(string), "AdmWarning: %s has been kicked because they attempted to jail a higher admin!", PlayerName(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
}

format(string, sizeof(string), "AdmWarning: %s has been jailed by %s, reason: %s", PlayerName(player), PlayerName(playerid), reason);
SendClientMessageToAll(COLOR_LIGHTRED, string);
IsPlayerJailed[player] = 1;
SetPlayerPos(playerid,-221.059051,1408.984008,27.773437); //jail position
SetPlayerInterior(playerid,18); //interior id
TogglePlayerControllable(playerid,0); // Frozen
}
return 1;
}

YCMD:unjail(playerid, params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;

if(PlayerInfo[playerid][Admin] >= 1) {
new player;

if(sscanf(params, "u", player)) return SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /unjail [Part of Name/Player ID]");

if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
if(IsPlayerJailed[player] == 0) return SendClientMessage(playerid, COLOR_GREY, "Player is not jailed.");
new string[126];

format(string, sizeof(string), "AdmWarning: %s has been unjailed by %s", PlayerName(player), PlayerName(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
IsPlayerJailed[player] = 0;
SpawnPlayer(player);
}
return 1;
}

[MM]RoXoR[FS]
19/07/2012, 02:02 PM
#define SCM SendClientMessage
new ReleaseJail[MAX_PLAYERS];
YCMD:jail(playerid,params[])
{
new id,reason[30],time=1;
//if(!IsPlayerAdmin(playerid) && pInfo[playerid][Admin] == 0) return SCM(playerid,-1,"You do have sufficient power");
if(sscanf(params,"uIS[30]",id,time,reason)) return SCM(playerid,-1,"Correct Usage : /jail [id] [time(minutes)] [reason]");
if(!IsPlayerConnected(id)||id == INVALID_PLAYER_ID) return SCM(playerid,-1,"Player is not connected | Invalid Player");
SetPVarInt(id,"OLDINTERIOR",GetPlayerInterior(id));
SetPlayerPos(id,197.6661,173.8179,1003.0234);
SetPlayerInterior(id,3);
ReleaseJail[id]= SetTimerEx("ReleaseFromJail",time*60000,false,"i",id);
//And SendMessage To All
return 1;
}

YCMD:unjail(playerid,params[])
{
new id;
//if(!IsPlayerAdmin(playerid) && pInfo[playerid][Admin] == 0) return SCM(playerid,-1,"You do have sufficient power");
if(sscanf(params,"u",id)) return SCM(playerid,-1,"Correct Usage : /unjail [id]");
if(!IsPlayerConnected(id)||id == INVALID_PLAYER_ID) return SCM(playerid,-1,"Player is not connected | Invalid Player");
SpawnPlayer(id);
SetPlayerInterior(id,GetPVarInt(id,"OLDINTERIOR"));
KillTimer(ReleaseJail[id]);
//And SendMessage To All
return 1;
}

forward ReleaseFromJail(playerid);

public ReleaseFromJail(playerid)
{
if(IsPlayerConnected(playerid))
{
SpawnPlayer(playerid);
SetPlayerInterior(playerid,GetPVarInt(playerid,"OLDINTERIOR"));
//SendMessageToAll
}
return 1;
}