Admin Name / ADuty Problem
#1

I have no errors.. but when I use /aduty to go off duty the name is not changing to the normal name.

pawn Код:
new NormalName[MAX_PLAYERS];
enum pInfo
{
        pAdminDuty,
    pAdminName[MAX_PLAYER_NAME]
}

new PlayerInfo[MAX_PLAYERS+1][pInfo];

// public OnPlayerConnect

NormalName[playerid] = GetPlayerNameEx(playerid);

CMD:setaname(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not an admin!");
    if(PlayerInfo[playerid][pAdminDuty] != 0) return SendClientMessage(playerid, COLOR_GREY, "You must off duty to change your admin name!");
    if(isnull(params)) return SendClientMessageEx(playerid, COLOR_WHITE, "{6347AA}[Error]:{FFFFFF} /setaname [name]");
    new str[128];
    format(PlayerInfo[playerid][pAdminName], 128, params);
    format(str, sizeof(str), "%s has changed his admin name to %s.", GetPlayerNameEx(playerid), params);
    ABroadCast(COLOR_YELLOW, str, 2);
    return 1;
}

// ADMIN DUTY
CMD:aduty(playerid, params[])
{
        if(IsPlayerConnected(playerid))
        {
            new id;
            if(PlayerInfo[playerid][pAdmin] > 2 && PlayerInfo[playerid][pAdminDuty] == 0)
            {
                SetPlayerName(playerid, PlayerInfo[playerid][pAdminName]);
                SendClientMessage(playerid, COLOR_WHITE, "You are now on admin duty.");
                PlayerInfo[playerid][pAdminDuty] = 1;
                //ADUTYText[playerid] = Create3DTextLabel("I'm on Admin Duty",0xCCCC00FF,30.0,40.0,50.0,40.0,0);
                //Attach3DTextLabelToPlayer(ADUTYText[playerid], playerid, 0.0, 0.0, 0.4);
                IsADUTY[id] = true;
                SetPlayerHealth(playerid, 999999);
                SetPlayerArmour(playerid, 999999);

            }
            else if(PlayerInfo[playerid][pAdmin] > 2 && PlayerInfo[playerid][pAdminDuty] != 0)
            {
                SetPlayerName(playerid, NormalName[playerid]);
                SendClientMessage(playerid, COLOR_WHITE, "You are now off admin duty.");
                //Delete3DTextLabel(ADUTYText[playerid]);
                IsADUTY[id] = false;
                SetPlayerHealth(playerid, 100);
                SetPlayerArmour(playerid, 0);
                PlayerInfo[playerid][pAdminDuty] = 0;
            }
        }
        return 1;
}
Reply
#2

what is NormalName[playerid] = GetPlayerNameEx(playerid);

GetPlayerNameex?
Reply
#3

pawn Код:
new NormalName[MAX_PLAYERS];
This needs to be used as a name correct?
pawn Код:
new NormalName[MAX_PLAYER_NAME];
Reply
#4

Quote:
Originally Posted by kamzaf
Посмотреть сообщение
what is NormalName[playerid] = GetPlayerNameEx(playerid);

GetPlayerNameex?
pawn Код:
GetPlayerNameEx(playerid) {

    new
        sz_playerName[MAX_PLAYER_NAME],
        i_pos;

    GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
    while ((i_pos = strfind(sz_playerName, "_", false, i_pos)) != -1) sz_playerName[i_pos] = ' ';
    return sz_playerName;
}
Reply
#5

Quote:
Originally Posted by Sade
Посмотреть сообщение
pawn Код:
GetPlayerNameEx(playerid) {

    new
        sz_playerName[MAX_PLAYER_NAME],
        i_pos;

    GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
    while ((i_pos = strfind(sz_playerName, "_", false, i_pos)) != -1) sz_playerName[i_pos] = ' ';
    return sz_playerName;
}
That code is correct, and should work. Have you checked my response? That should fix it i'm pretty sure
Reply
#6

Quote:
Originally Posted by iMads
Посмотреть сообщение
That code is correct, and should work. Have you checked my response? That should fix it i'm pretty sure
I did it.. But I get 'No Array Assigned' on:

pawn Код:
//OnPlayerConnect
NormalName[playerid] = GetPlayerNameEx(playerid);
Reply
#7

pawn Код:
NormalName[MAX_PLAYER_NAME][MAX_PLAYERS];
Reply
#8

May i ask, don't you want to set their name to the real one with the "_", since it's their real name and it uses around the map i guess?

So shoulden't you just use normal GetPlayerName instead of your version?
Reply
#9

Quote:
Originally Posted by iMads
Посмотреть сообщение
May i ask, don't you want to set their name to the real one with the "_", since it's their real name and it uses around the map i guess?

So shoulden't you just use normal GetPlayerName instead of your version?
seems smart
Reply
#10

Quote:
Originally Posted by Sade
Посмотреть сообщение
seems smart
Try using the GetPlayerName function instead, and check if it works
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)