SA-MP Forums Archive
Need help with Aduty - 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: Need help with Aduty (/showthread.php?tid=444588)



Need help with Aduty - Biess - 17.06.2013

[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.


Re: Need help with Aduty - AldoT - 17.06.2013

Say me waht Error he give you?


Re: Need help with Aduty - Dragonsaurus - 17.06.2013

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;


Re: Need help with Aduty - Jeffry - 17.06.2013

Post your OnPlayerStateChange, the problem is in there.


Re: Need help with Aduty - DetoNater - 17.06.2013

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