SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 30/08/2017, 06:12 PM   #1
timsosa09
Little Clucker
 
Join Date: Feb 2012
Posts: 12
Reputation: 3
Default My gm only kick ,no ban players

My server only kick players does not ban them because?

Code:
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

Code:
Password=344907E89B981CAF221D05F597EB57A6AF408F15F4DD7895BBD1B96A2938EC24A7DCF23ACB94ECE0B6D7B0640358BC56BDB448194B9305311AFF038A834A079F
Level=0
Weather=0
Time=10
ChatChannel=-1
timsosa09 is offline   Reply With Quote
Old 01/09/2017, 05:18 PM   #2
mongi
Big Clucker
 
Join Date: Jun 2015
Location: Earth
Posts: 110
Reputation: 11
Default Re: My gm only kick ,no ban players

Show OnPlayerBan function

Also showing the user IP is a real BAD idea. You should remove it
__________________
______________________________________________

Offering programming/scripting services. PM for more info.

______________________________________________
[Tool]Server Control Panel
[Tool]Server Control Panel Version 2
[Tool]ChatLog Saver
mongi is offline   Reply With Quote
Old 01/09/2017, 05:33 PM   #3
ISmokezU
Gangsta
 
Join Date: Aug 2016
Posts: 543
Reputation: 73
Default Re: My gm only kick ,no ban players

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

PHP Code:
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;

ISmokezU is online now   Reply With Quote
Old 01/09/2017, 05:51 PM   #4
mongi
Big Clucker
 
Join Date: Jun 2015
Location: Earth
Posts: 110
Reputation: 11
Default Re: My gm only kick ,no ban players

Quote:
Originally Posted by ISmokezU View Post
Your code could be compressed. Probably even more than how I compressed it

PHP Code:
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 Code:
    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);
    }

__________________
______________________________________________

Offering programming/scripting services. PM for more info.

______________________________________________
[Tool]Server Control Panel
[Tool]Server Control Panel Version 2
[Tool]ChatLog Saver
mongi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I kick players who have over 200 ping Markhoss Scripting Help 9 29/07/2015 08:53 AM
TogglePlayerSpectating bug (KICK PLAYERS!) adri1 Bug Reports 3 29/08/2014 07:52 AM
Bug tuning - Server kick players FL3GM4 Scripting Help 4 07/01/2013 01:07 AM
Kick all players? acade Help Archive 4 27/10/2009 10:20 AM
Message to all players when doing /kick Jakku Help Archive 5 10/05/2009 02:40 PM


All times are GMT. The time now is 02:18 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.