Need help with Aduty
#1

[07:22:03] [debug] Run time error 4: "Array index out of bounds"
[07:22:03] [debug] Accessing element at index 999 past array upper bound 500
[07:22:03] [debug] AMX backtrace:
[07:22:03] [debug] #0 0007730c in public OnPlayerStateChange (0x00000003, 0x00000001, 0x0000000 from EXRPu19.amx

pawn Код:
CMD:aduty(playerid, params[])
{
        if(IsPlayerConnected(playerid))
        {
            new string[120];
            if(PlayerInfo[playerid][pAdmin] >= 1 && PlayerInfo[playerid][pAdminDuty] == 0)
            {
                SendClientMessage(playerid, COLOR_GREEN, "   You are now on admin duty.");
                SetPlayerName(playerid, PlayerInfo[playerid][pAdminName]);
                format(string, sizeof(string), "** Administrator %s is now on admin duty. (/report for assistance) **", GetPlayerNameEx(playerid));
                SendClientMessageToAllEx(COLOR_YELLOW, string);
                PlayerInfo[playerid][pAdminDuty] = 1;
                SetPlayerHealth(playerid, 9999);
                SetPlayerArmour(playerid, 9999);

            }
            else if(PlayerInfo[playerid][pAdmin] >= 1 && PlayerInfo[playerid][pAdminDuty] != 0)
            {
                SetPlayerColor(playerid,COLOR_WHITE);
                SendClientMessageEx(playerid, COLOR_GREEN, "   You are now off admin duty.");
                format(string, sizeof(string), "** Administrator %s is now off admin duty. **", GetPlayerNameEx(playerid));
                SendClientMessageToAllEx(COLOR_YELLOW, string);
                SetPlayerName(playerid, PlayerInfo[playerid][pNormalName]);
                SetPlayerHealth(playerid, 100);
                SetPlayerArmour(playerid, 0);
                PlayerInfo[playerid][pAdminDuty] = 0;
            }
        }
        return 1;
}
I got that error.
Reply
#2

Say me waht Error he give you?
Reply
#3

Dude, why are you checking if the player who typed the command is connected or not? If he typed it, means he is connected. Remove "if(IsPlayerConnected(playerid))" and the "}" bracket before return 1;
Reply
#4

Post your OnPlayerStateChange, the problem is in there.
Reply
#5

pawn Код:
CMD:aduty(playerid, params[])
{
            new string[120];
            if(PlayerInfo[playerid][pAdmin] >= 1 && PlayerInfo[playerid][pAdminDuty] == 0)
            {
                SendClientMessage(playerid, COLOR_GREEN, "   You are now on admin duty.");
                SetPlayerName(playerid, PlayerInfo[playerid][pAdminName]);
                format(string, sizeof(string), "** Administrator %s is now on admin duty. (/report for assistance) **", GetPlayerNameEx(playerid));
                SendClientMessageToAllEx(COLOR_YELLOW, string);
                PlayerInfo[playerid][pAdminDuty] = 1;
                SetPlayerHealth(playerid, 9999);
                SetPlayerArmour(playerid, 9999);

            }
            else
            {
                SetPlayerColor(playerid,COLOR_WHITE);
                SendClientMessageEx(playerid, COLOR_GREEN, "   You are now off admin duty.");
                format(string, sizeof(string), "** Administrator %s is now off admin duty. **", GetPlayerNameEx(playerid));
                SendClientMessageToAllEx(COLOR_YELLOW, string);
                SetPlayerName(playerid, PlayerInfo[playerid][pNormalName]);
                SetPlayerHealth(playerid, 100);
                SetPlayerArmour(playerid, 0);
                PlayerInfo[playerid][pAdminDuty] = 0;
            }
        return 1;
}
as dragon said the player who typed the cmd must be connected, try the above hope it helps
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)