My ban command won't work.
#1

I am using ZCMD and I can't get my /ban command to work.
Код:
#define CMD:%1(%2)          \
            forward cmd_%1(%2); \
            public cmd_%1(%2)
Код:
#define <zcmd>
Код:
CMD:ban(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 2)
	{
		new string[128], giveplayerid, reason[64];
		if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");

		if(IsPlayerConnected(giveplayerid))
		{
			if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
			{
				format(string, sizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin.", GetPlayerNameEx(playerid));
				ABroadCast(COLOR_YELLOW,string,2);
				PlayerInfo[playerid][pBanned] = 1;
				new ip[32];
				GetPlayerIp(playerid,ip,sizeof(ip));
				AddBan(ip);
				Kick(playerid);
				return 1;
			}
			else
			{
				new year, month,day;
				getdate(year, month, day);
				new playerip[32];
				GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
				format(string, sizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason,month,day,year);
				Log("logs/ban.log", string);
				format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
				SendClientMessageToAllEx(COLOR_LIGHTRED, string);
				PlayerInfo[giveplayerid][pBanned] = 1;
				format(PlayerInfo[giveplayerid][pFlag], 128, "");
				new ip[32];
				GetPlayerIp(giveplayerid,ip,sizeof(ip));
				AddBan(ip);
				Kick(giveplayerid);
				return 1;
			}

		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
	return 1;
}
Thanks in advance.
Reply
#2

This is my /ban command:
Код:
CMD:ban(playerid, params[]) {
	if(playerVariables[playerid][pAdminLevel] >= 1) {
	    new
	        playerBanID,
	        playerBanReason[60];

	    if(sscanf(params, "us[60]", playerBanID, playerBanReason))
	    	return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/ban [playerid] [reason]");

		if(playerVariables[playerBanID][pAdminLevel] >= playerVariables[playerid][pAdminLevel])
			return SendClientMessage(playerid, COLOR_GREY, "You can't ban a higher (or equal) level administrator.");

        if(playerBanID == INVALID_PLAYER_ID)
			return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");

		new

            playerIP[32],
            playerNameBanned[MAX_PLAYER_NAME],
            aString[384]; // Due to the fact that we'll be dealing with a large query after the ban announcement...

		GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
		GetPlayerName(playerBanID, playerNameBanned, MAX_PLAYER_NAME);

		GetPlayerIp(playerBanID, playerIP, sizeof(playerIP));

		playerVariables[playerBanID][pBanned] = 1;

       	format(aString, sizeof(aString), "Ban: %s has been banned by %s, reason: %s", playerNameBanned, playerVariables[playerid][pAdminName], playerBanReason);
       	SendClientMessageToAll(COLOR_LIGHTRED, aString);
       	mysql_real_escape_string(aString, aString);
       	adminLog(aString);

       	mysql_real_escape_string(szPlayerName, szPlayerName);
       	mysql_real_escape_string(playerNameBanned, playerNameBanned);

       	format(aString, sizeof(aString), "INSERT INTO bans (playerNameBanned, playerBannedBy, playerBanReason, IPBanned) VALUES('%s', '%s', '%s', '%s')", playerNameBanned, szPlayerName, playerBanReason, playerIP);
		mysql_query(aString, THREAD_BAN_PLAYER, playerBanID);
	}
	return 1;
}
Try it and tell me if it works.
Reply
#3

Same errors:
Код:
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(13) : warning 201: redefinition of constant/macro (symbol "CMD:%1(%2)")
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : error 029: invalid expression, assumed zero
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : error 017: undefined symbol "cmd_ban"
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : error 029: invalid expression, assumed zero
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#4

PHP код:
CMD:ban(playeridparams[])
{
    if (
PlayerInfo[playerid][pAdmin] >= 2)
    {
        new 
string[128], giveplayeridreason[64];
        if(
sscanf(params"us[64]"giveplayeridreason)) return SendClientMessageEx(playeridCOLOR_SYN"[Syntax:]{FFFFFF}  /ban [playerid] [reason]");

        if(
IsPlayerConnected(giveplayerid))
        {
            if(
PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
            {
                
format(stringsizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin."GetPlayerNameEx(playerid));
                
ABroadCast(COLOR_YELLOW,string,2);
                
PlayerInfo[playerid][pBanned] = 1;
                new 
ip[32];
                
GetPlayerIp(playerid,ip,sizeof(ip));
                
AddBan(ip);
                
Kick(playerid);
                return 
1;
            }
            else
            {
                new 
yearmonth,day;
                
getdate(yearmonthday);
                new 
playerip[32];
                
GetPlayerIp(giveplayeridplayeripsizeof(playerip));
                
format(stringsizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s (%d-%d-%d)"GetPlayerNameEx(giveplayerid), playeripGetPlayerNameEx(playerid), reason,month,day,year);
                
Log("logs/ban.log"string);
                
format(stringsizeof(string), "AdmCmd: %s was banned by %s, reason: %s"GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
                
SendClientMessageToAllEx(COLOR_LIGHTREDstring);
                
PlayerInfo[giveplayerid][pBanned] = 1;
                
format(PlayerInfo[giveplayerid][pFlag], 128"");
                new 
ip[32];
                
GetPlayerIp(giveplayerid,ip,sizeof(ip));
                
AddBan(ip);
                
Kick(giveplayerid);
                return 
1;
            }

        }
    }
    else 
SendClientMessageEx(playeridCOLOR_GRAD1"Invalid player specified.");
    return 
1;

Reply
#5

Код:
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(13) : warning 201: redefinition of constant/macro (symbol "CMD:%1(%2)")
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : error 029: invalid expression, assumed zero
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : error 017: undefined symbol "cmd_ban"
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : error 029: invalid expression, assumed zero
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Still
Reply
#6

Quote:
Originally Posted by Vic1990
Посмотреть сообщение
Код:
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(13) : warning 201: redefinition of constant/macro (symbol "CMD:%1(%2)")
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : error 029: invalid expression, assumed zero
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : error 017: undefined symbol "cmd_ban"
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : error 029: invalid expression, assumed zero
C:\Users\admin\Desktop\Server\gamemodes\Server.pwn(556) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Still
What's the error line ?
Reply
#7

Quote:
Originally Posted by =WoR=G4M3Ov3r
Посмотреть сообщение
What's the error line ?
Код:
CMD:ban(playerid, params[])
Reply
#8

remove

PHP код:
#define CMD:%1(%2)          \
            
forward cmd_%1(%2); \
            public 
cmd_%1(%2
And its probably because you don't have ZCMD included... else it wouldn't give you this error.

Try posting your code at the bottom of your script.
Reply
#9

You know you don't put CMD: under callback OnPlayerCommandText?

EDIT: WTF?
Quote:
Originally Posted by Vic1990
pawn Код:
#define CMD:%1(%2)          \
            forward cmd_%1(%2); \
            public cmd_%1(%2)
Code:
#define <zcmd>
You are kidding, right? Why? Simply
pawn Код:
#include <zcmd>
Reply
#10

I have
Код:
#include <a_samp>
#include <zcmd>
#include <YSI\y_ini>
and I got the accual include in pawno>include
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)