SA-MP Forums Archive
Admin Name / ADuty Problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Admin Name / ADuty Problem (/showthread.php?tid=427380)



Admin Name / ADuty Problem - Sade - 01.04.2013

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;
}



Re: Admin Name / ADuty Problem - kamzaf - 01.04.2013

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

GetPlayerNameex?


Re: Admin Name / ADuty Problem - iMads - 01.04.2013

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



Re: Admin Name / ADuty Problem - Sade - 01.04.2013

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;
}



Re: Admin Name / ADuty Problem - iMads - 01.04.2013

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


Re: Admin Name / ADuty Problem - Sade - 01.04.2013

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);



Re: Admin Name / ADuty Problem - zxc1 - 01.04.2013

pawn Код:
NormalName[MAX_PLAYER_NAME][MAX_PLAYERS];



Re: Admin Name / ADuty Problem - iMads - 01.04.2013

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?


Re: Admin Name / ADuty Problem - Sade - 01.04.2013

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


Re: Admin Name / ADuty Problem - iMads - 01.04.2013

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