Ban problems -
_GHT_MarK445 - 01.03.2015
Hey guys,
i have another problem and this time, with my ban command, i cant solve it, couse i do not see any problems with it.
This is my /ban command.
Код:
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pALevel] < 2) return SendClientMessage(playerid, colorba, "You do not have enough level to use this command.");
new string[128],userid, reason[48];
if(sscanf(params, "us[48]", userid, reason)) return SendClientMessage(playerid, coloru, "Usage: /ban id reason");
if(userid == INVALID_PLAYER_ID) return SendClientMessage(playerid, colors, "You inserted wrong id!");
if(PlayerInfo[userid][pALevel] > 1) return SendClientMessage(playerid, colorerror, "You cant ban admin.");
format(string,sizeof(string),"Admin %s ban player %s: %s",GetName(playerid),GetName(userid),reason);
SendClientMessageToAll(cadmin,string);
Ban(userid);
return 1;
}
It bans the player correctly, but when i ban him (write the command) after the ban is done, the server crashes and it kind of like lags. Banned user disconnect, i disconnect, but both of us are still enabled to be seen in player list (in client window), so yeah, thanks.
Re: Ban problems -
hamzajaved780 - 01.03.2015
may be here's your problem
SendClientMessageToAll(cadmin,string);
try commenting this statement
Re: Ban problems -
BeesSi - 01.03.2015
pawn Код:
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pALevel] < 2) return SendClientMessage(playerid, colorba, "You do not have enough level to use this command.");
new string[128],userid, reason[48];
if(sscanf(params, "us[48]", userid, reason)) return SendClientMessage(playerid, coloru, "Usage: /ban id reason");
if(userid == INVALID_PLAYER_ID) return SendClientMessage(playerid, colors, "You inserted wrong id!");
if(PlayerInfo[userid][pALevel] > 1) return SendClientMessage(playerid, colorerror, "You cant ban admin.");
format(string,sizeof(string),"Admin %s ban player %s: %s",GetName(playerid),GetName(userid),reason);
SendClientMessageToAll(cadmin,string);
BanEx(userid, reason);
return 1;
}
Try this, if it wont work please tell me .
Re: Ban problems -
HY - 01.03.2015
What exactly it's this problem?
Anyway, 'SendClientMessageToAll(cadmin, ......), looks weird, and I'm not sure if it's good.
Better if you make a stock:
pawn Код:
stock SendMessageToAdmin(color, string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pALevel] >= 1)
{
SendClientMessage(i, color, string);
}
}
}
pawn Код:
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pALevel] < 2) return SendClientMessage(playerid, colorba, "You do not have enough level to use this command.");
new string[128],userid, reason[48];
if(sscanf(params, "us[48]", userid, reason)) return SendClientMessage(playerid, coloru, "Usage: /ban id reason");
if(!IsPlayerConnected(userid)) return SendClientMessage(playerid, colors, "You inserted wrong id!");
if(PlayerInfo[userid][pALevel] > 1) return SendClientMessage(playerid, colorerror, "You cant ban admin.");
format(string,sizeof(string),"Admin %s ban player %s: %s",GetName(playerid),GetName(userid),reason);
SendMessageToAdmin(-1, string);
Ban(userid);
return 1;
}
Re: Ban problems -
BeesSi - 01.03.2015
If our both codes won't work , use my Admin System's Script Advanced Ban System : Code Below
pawn Код:
CMD:ban(playerid, params[])
{
new id, reason[50], string[128], banned[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][pALevel] >= 2)
{
if(sscanf(params, "uz", id, reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /ban [playerid] [reason(optional)]");
GetPlayerName(id, banned, sizeof(banned));
format(string, sizeof(string), "AdmCmd: %s has been banned by %s, reason: %s", banned, GetName(playerid), reason);
SendClientMessageToAll(0xFF0000C8, string);
new str[3600];
new year, month, day;
getdate(year, month, day);
format(str,128,"{FFFFFF}You have been banned by {00FFF2}%s {FFFFFF}for {7C44EB}%s {FFFFFF}on [%d/%d/%d].\nIf you think you were banned unfairly please appeal at [url]www.Your-Web.com.\nIf[/url] you think you were bugged please relog.\nTake a screenshot of this and post at the appeal , you are required to do this.",GetName(playerid), reason, day, month, year);
ShowPlayerDialog(id, DIALOG_SHOW_INFO2, DIALOG_STYLE_MSGBOX, "{FF0000}Banned", str, "Ok", "Cancel");
BanEx(id, reason);
}
else SendClientMessage(playerid,COLOR_GREY,"You are not authorized to use this command");
return 1;
}
The GetName(playerid) stock :
pawn Код:
stock GetName(playerid)
{
new
pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
return pName;
}
I hope i helped.
Re: Ban problems -
_GHT_MarK445 - 01.03.2015
"cadmin" is color, so it has nothing to do with it
Re: Ban problems -
BeesSi - 01.03.2015
Use the Ban System i gave you.
Re: Ban problems -
_GHT_MarK445 - 01.03.2015
No I cant, it will be messy, i have my own administration system and it looks itself. I cant throw the dialog to the middle of admin commands, i need to have it the same, as other commands.
Re: Ban problems -
hamzajaved780 - 01.03.2015
Match your syntax with this it works perfectly
Код:
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 3) {
new PID; //define the playerid we wanna ban
new reason[64]; //the reason, put into a string
new str[128]; //a new message string
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
GetPlayerName(PID, Playername, sizeof(Playername));
if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
SendClientMessageToAll(COLOR_RED, str); //send that message to all
Ban(PID); //Ban the playerid we've defined
}
else //if he has not got the permissions
{
SendClientMessage(playerid, COLOR_GREY, "You have to be level 5 to use that command!"); //return this message
}
return 1;
}