My gm only kick ,no ban players
#1

My server only kick players does not ban them because?

Код:
CMD:ban(playerid, params[])
{
    if(Player[playerid][Level] < 3) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}You need to be a higher admin level.");
	if(AllowStartBase == false) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}Can't kick now. Please wait.");

	new Params[2][128], iString[180];
	#if PLUGINS == 1
		sscanf(params, "s[128]s[128]", Params[0], Params[1]);
	#else
	    sscanf(params, "ss", Params[0], Params[1]);
	#endif
	if(isnull(Params[0]) || !IsNumeric(Params[0])) return SendClientMessage(playerid,-1,"{FFFFFF}USAGE: {0099FF}/ban [Player ID] [Reason]");
	new pID = strval(Params[0]);

	if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}That player isn't connected.");
	if(Player[pID][Level] >= Player[playerid][Level]) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}Can't ban someone of same or higher admin level.");
	
	new IP[50];
	GetPlayerIp(pID, IP, sizeof(IP));

	new bool:GiveReason;
	if(isnull(Params[1])) GiveReason = false;
	else GiveReason = true;


	if(GiveReason == false) {
		format(iString, sizeof(iString), "{FFFFFF}%s {0099FF}has banned {FFFFFF}%s (IP: %s) {0099FF}| Reason: {FFFFFF}No Reason Given", Player[playerid][Name], Player[pID][Name], IP);
		SendClientMessageToAll(-1, iString);
		Ban(pID);///
	} else {
		format(iString, sizeof(iString), "{FFFFFF}%s {0099FF}has banned {FFFFFF}%s (IP: %s) {0099FF}| Reason: {FFFFFF}%s", Player[playerid][Name], Player[pID][Name], IP, Params[1]);
		SendClientMessageToAll(-1, iString);
		BanEx(pID, Params[1]);///
	}

    SetTimerEx("OnPlayerBan", 1000, false, "i", pID);

	return 1;
}
Users

Код:
Password=344907E89B981CAF221D05F597EB57A6AF408F15F4DD7895BBD1B96A2938EC24A7DCF23ACB94ECE0B6D7B0640358BC56BDB448194B9305311AFF038A834A079F
Level=0
Weather=0
Time=10
ChatChannel=-1
Reply
#2

Show OnPlayerBan function

Also showing the user IP is a real BAD idea. You should remove it
Reply
#3

Your code could be compressed. Probably even more than how I compressed it

PHP код:
CMD:ban(playeridparams[])
{
    new 
targetstring[144], reason[78];
    if(
Player[playerid][Level] < 3) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}You need to be a higher admin level.");
    if(
AllowStartBase == false) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}Can't kick now. Please wait.");// ...
    
if(sscanf(params"us[78]"targetreason)) return SendClientMessage(playerid,-1,"{FFFFFF}USAGE: {0099FF}/ban [Player ID] [Reason]");
    if(
target == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}That player isn't connected.");
    if(
Player[target][Level] >= Player[playerid][Level]) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}Can't ban someone of same or higher admin level.");

    new 
IP[16];
    
GetPlayerIp(targetIPsizeof(IP));

    if(
isnull(params)) {
        
format(stringsizeof string"{FFFFFF}%s {0099FF}has banned {FFFFFF}%s (IP: %s) {0099FF}| Reason: {FFFFFF}No Reason Given"Player[playerid][Name], Player[target][Name], IP);
        
SendClientMessageToAll(-1iString);
    } else {
        
format(stringsizeof string"{FFFFFF}%s {0099FF}has banned {FFFFFF}%s (IP: %s) {0099FF}| Reason: {FFFFFF}%s"Player[playerid][Name], Player[target][Name], IPParams[1]);
        
SendClientMessageToAll(-1string);
    }
    
SetTimerEx("OnPlayerBan"10false"i"target);
    return 
true;

Reply
#4

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Your code could be compressed. Probably even more than how I compressed it

PHP код:
CMD:ban(playeridparams[])
{
    new 
targetstring[144], reason[78];
    if(
Player[playerid][Level] < 3) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}You need to be a higher admin level.");
    if(
AllowStartBase == false) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}Can't kick now. Please wait.");// ...
    
if(sscanf(params"us[78]"targetreason)) return SendClientMessage(playerid,-1,"{FFFFFF}USAGE: {0099FF}/ban [Player ID] [Reason]");
    if(
target == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}That player isn't connected.");
    if(
Player[target][Level] >= Player[playerid][Level]) return SendClientMessage(playerid,-1,"{FFFFFF}Error: {0099FF}Can't ban someone of same or higher admin level.");
    new 
IP[16];
    
GetPlayerIp(targetIPsizeof(IP));
    if(
isnull(params)) {
        
format(stringsizeof string"{FFFFFF}%s {0099FF}has banned {FFFFFF}%s (IP: %s) {0099FF}| Reason: {FFFFFF}No Reason Given"Player[playerid][Name], Player[target][Name], IP);
        
SendClientMessageToAll(-1iString);
    } else {
        
format(stringsizeof string"{FFFFFF}%s {0099FF}has banned {FFFFFF}%s (IP: %s) {0099FF}| Reason: {FFFFFF}%s"Player[playerid][Name], Player[target][Name], IPreason);
        
SendClientMessageToAll(-1string);
    }
    
SetTimerEx("OnPlayerBan"10false"i"target);
    return 
true;

I guess you mean this ( isnull(reason) instead of isnull(params) )

PHP код:
    if(isnull(reason)) {
        
format(stringsizeof string"{FFFFFF}%s {0099FF}has banned {FFFFFF}%s (IP: %s) {0099FF}| Reason: {FFFFFF}No Reason Given"Player[playerid][Name], Player[target][Name], IP);
        
SendClientMessageToAll(-1iString);
    } else {
        
format(stringsizeof string"{FFFFFF}%s {0099FF}has banned {FFFFFF}%s (IP: %s) {0099FF}| Reason: {FFFFFF}%s"Player[playerid][Name], Player[target][Name], IPParams[1]);
        
SendClientMessageToAll(-1string);
    }

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)