//new GODAFK;
new PlayerAfkName[MAX_PLAYERS][MAX_PLAYER_NAME+1];
CMD:afk(playerid, params[])
{
if(afk[playerid] == 1 && PlayerInfo[playerid][pAdminlvl] == 5)
{
if(ZDM[playerid] != 2 && Dming[playerid] != 2)
{
new Float:x, Float:y, Float:z;
GetPlayerName(playerid, PlayerAfkName[playerid][MAX_PLAYER_NAME], sizeof(PlayerAfkName[playerid][MAX_PLAYER_NAME])); // THIS LINE GET A ERROR
TogglePlayerControllable(playerid, 0);
GetPlayerHealth(playerid, afkHealth[playerid]);
SetPlayerHealth(playerid, 9999999.0);
//GODAFK = SetTimerEx("GodMode", 100, true, "i", playerid);
GameTextForPlayer(playerid, "AFK", 4000, 3);
GetPlayerPos(playerid, x, y, z);
new Text3D:afk3D = Create3DTextLabel("[AFK]",red1, x, y, z, 40, 0, 0);
Attach3DTextLabelToPlayer(afk3D, playerid, 0.0, 0.0, 0.0);
afk[playerid] = 2;
afkDraw = TextDrawCreate(285.000000, 18.000000,"~r~AFK");
TextDrawShowForPlayer(playerid, afkDraw);
return 1;
}
return 1;
}
else if(afk[playerid] == 2 && ZDM[playerid] != 2 && Dming[playerid] != 2)
{
TogglePlayerControllable(playerid, 1);
//DeletePlayer3DTextLabel(playerid,
SetPlayerHealth(playerid, afkHealth[playerid]);
//KillTimer(GODAFK);
TextDrawHideForPlayer(playerid, afkDraw);
afk[playerid] = 1;
return 1;
}
else return 1;
}
C:\--(5807) : error 001: expected token: "]", but found "-identifier-"
C:\--(5807) : warning 215: expression has no effect
C:\--(5807) : error 001: expected token: ";", but found "]"
C:\--(5807) : error 029: invalid expression, assumed zero
C:\--(5807) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
4 Errors.
GetPlayerName(playerid, PlayerAfkName[playerid], MAX_PLAYER_NAME);
new PlayerAfkName[MAX_PLAYERS][MAX_PLAYER_NAME+1];
032 - array index out of bounds
The array index is larger than the highest valid entry of the array.
new PlayerAfkName[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, PlayerAfkName, MAX_PLAYER_NAME);
PHP код:
PHP код:
|
working - sizeof(PlayerAfkName)
BUT, the value sizeof is 500. (Get MAX_PLAYERS value, not recommended) |
new PlayerAfkName[MAX_PLAYERS][MAX_PLAYER_NAME+1]; » new PlayerAfkName[MAX_PLAYER_NAME+1][MAX_PLAYERS];
GameTextForPlayer(playerid, "AFK", 4000, 3);
afkDraw = TextDrawCreate(285.000000, 18.000000,"~r~AFK");
new PlayerAfkName[MAX_PLAYER_NAME+1][MAX_PLAYERS];