if(!strcmp(playername, "James_Willowfield"))
#1

Okay, so i'm getting this error:

Код:
C:\Users\****\Desktop\IRP739.pwn(60469) : error 017: undefined symbol "playername"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
pawn Код:
if(!strcmp(playername, "James_Willowfield"))
            {
                SendClientMessage(playerid, COLOR_GREY, "You cannot ban the big boss, even when he's offline. You were banned instead.");
                new year, month,day;
                getdate(year, month, day);
                new playerip[32];
                format(reason, sizeof(reason), "Trying to ban James Willowfield.");
                GetPlayerIp(playerid, playerip, sizeof(playerip));
                format(string, sizeof(string), "AdmCmd: %s(IP:%s) was automatically banned, reason: %s (%d-%d-%d)", GetPlayerNameEx(playerid), playerip,reason,month,day,year);
                Log("logs/ban.log", string);
                format(string, sizeof(string), "AdmCmd: %s was banned by the system, reason: %s", GetPlayerNameEx(playerid), reason);
                SendClientMessageToAllEx(COLOR_LIGHTRED, string);
                PlayerInfo[playerid][pBanned] = 1;
                format(PlayerInfo[playerid][pFlag], 128, "");
                new ip[32];
                GetPlayerIp(playerid,ip,sizeof(ip));
                AddBan(ip);
                Kick(playerid);
            return 1;
            }
Reply
#2

EDIT: Figured out what you were trying to do, can you post the whole command please?
Reply
#3

pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminDuty] == 0) return SendClientMessage(playerid, -1, "You must be on Admin Duty to use this Command!");
    if (PlayerInfo[playerid][pAdmin] >= 4 && PlayerInfo[playerid][pAdmin] != -1)
    {
        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;
            }
                if(!strcmp(playername, "James_Willowfield"))
            {
                SendClientMessage(playerid, COLOR_GREY, "You cannot ban the big boss, even when he's offline. You were banned instead.");
                new year, month,day;
                getdate(year, month, day);
                new playerip[32];
                format(reason, sizeof(reason), "Trying to ban James Willowfield.");
                GetPlayerIp(playerid, playerip, sizeof(playerip));
                format(string, sizeof(string), "AdmCmd: %s(IP:%s) was automatically banned, reason: %s (%d-%d-%d)", GetPlayerNameEx(playerid), playerip,reason,month,day,year);
                Log("logs/ban.log", string);
                format(string, sizeof(string), "AdmCmd: %s was banned by the system, reason: %s", GetPlayerNameEx(playerid), reason);
                SendClientMessageToAllEx(COLOR_LIGHTRED, string);
                PlayerInfo[playerid][pBanned] = 1;
                format(PlayerInfo[playerid][pFlag], 128, "");
                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;
}
Reply
#4

Add this on top of your command
pawn Код:
new playername;
playername = GetPlayerName(giveplayerid);
Reply
#5

The command you have at the moment, it bans online users only. You should make a ban command for offline players too and then check if the banned name is "James_Willowfield", then ban otherwise if the player exists to your files/database then ban him/her.

Or you can use what the user above said, but editing the parameters because it'll give errors.
pawn Код:
new
    playername[ MAX_PLAYER_NAME]
;
GetPlayerName(giveplayerid, playername, MAX_PLAYER_NAME);

if(!strcmp(playername, "James_Willowfield"))
{
    // code;
}
Reply
#6

After that I got:

Код:
C:\Users\Ashley Smith\Desktop\IRP739.pwn(3686) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(3722) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(8870) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(12288) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(12365) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(12382) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(26866) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(26953) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(27450) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(30854) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(30972) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(31039) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(32574) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(32683) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(43222) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(43967) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(44326) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(44468) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(49908) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(52566) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(60451) : error 021: symbol already defined: "GetPlayerName"
C:\Users\Ashley Smith\Desktop\IRP739.pwn(60452) : error 010: invalid function or declaration
C:\Users\Ashley Smith\Desktop\IRP739.pwn(60519) : error 054: unmatched closing brace ("}")
C:\Users\Ashley Smith\Desktop\IRP739.pwn(65964) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(66192) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(74295) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(74393) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(77629) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(77644) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(77701) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(84720) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(84742) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(84771) : warning 219: local variable "playername" shadows a variable at a preceding level
C:\Users\Ashley Smith\Desktop\IRP739.pwn(84804) : warning 219: local variable "playername" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#7

You've defined playername in global, remove it.
C:\Users\Ashley Smith\Desktop\IRP739.pwn(60519) : error 054: unmatched closing brace ("}") that error you failed at brackets, re-check.
Reply
#8

You have defined it as a golbal variable. Delete this
pawn Код:
new
    playername[ MAX_PLAYER_NAME]
;
Or rename it
pawn Код:
new
    playername_[ MAX_PLAYER_NAME]
;

GetPlayerName(giveplayerid, playername_, MAX_PLAYER_NAME);

if(!strcmp(playername_, "James_Willowfield"))
{
    // code;
}
Reply
#9

try this
pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminDuty] == 0) return SendClientMessage(playerid, -1, "You must be on Admin Duty to use this Command!");
    else if(PlayerInfo[playerid][pAdmin] < 4 || PlayerInfo[playerid][pAdmin] == -1) return SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    else
    {
        new string[128], giveplayerid, reason[64], name__[MAX_PLAYER_NAME];
        if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");
        else if(giveplayerid != INVALID_PLAYER_ID)
        {
            GetPlayerName(giveplayerid, name__, MAX_PLAYER_NAME);
            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 (true);
            }
            else if(strcmp(name__, "James_Willowfield", false) == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "You cannot ban the big boss, even when he's offline. You were banned instead.");
                new year, month,day;
                getdate(year, month, day);
                new playerip[32];
                format(reason, sizeof(reason), "Trying to ban James Willowfield.");
                GetPlayerIp(playerid, playerip, sizeof(playerip));
                format(string, sizeof(string), "AdmCmd: %s(IP:%s) was automatically banned, reason: %s (%d-%d-%d)", GetPlayerNameEx(playerid), playerip,reason,month,day,year);
                Log("logs/ban.log", string);
                format(string, sizeof(string), "AdmCmd: %s was banned by the system, reason: %s", GetPlayerNameEx(playerid), reason);
                SendClientMessageToAllEx(COLOR_LIGHTRED, string);
                PlayerInfo[playerid][pBanned] = 1;
                format(PlayerInfo[playerid][pFlag], 128, "");
                new ip[32];
                GetPlayerIp(playerid,ip,sizeof(ip));
                AddBan(ip);
                Kick(playerid);
                return (true);
            }
            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 (true);
            }

        }
    }
    return (true);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)