AFK System - String problem
#1

Hii there.
I've a problem :
PHP код:
//new GODAFK;
new PlayerAfkName[MAX_PLAYERS][MAX_PLAYER_NAME+1];
CMD:afk(playeridparams[])
{
    if(
afk[playerid] == && PlayerInfo[playerid][pAdminlvl] == 5)
    {
        if(
ZDM[playerid] != && Dming[playerid] != 2)
        {
            new 
Float:xFloat:yFloat:z;
            
GetPlayerName(playeridPlayerAfkName[playerid][MAX_PLAYER_NAME], sizeof(PlayerAfkName[playerid][MAX_PLAYER_NAME])); // THIS LINE GET A ERROR
            
TogglePlayerControllable(playerid0);
            
GetPlayerHealth(playeridafkHealth[playerid]);
            
SetPlayerHealth(playerid9999999.0);
            
//GODAFK = SetTimerEx("GodMode", 100, true, "i", playerid);
            
GameTextForPlayer(playerid"AFK"40003);
            
GetPlayerPos(playeridxyz);
            new 
Text3D:afk3D Create3DTextLabel("[AFK]",red1xyz4000);
            
Attach3DTextLabelToPlayer(afk3Dplayerid0.00.00.0);
            
afk[playerid] = 2;
            
afkDraw TextDrawCreate(285.00000018.000000,"~r~AFK");
            
TextDrawShowForPlayer(playeridafkDraw);
            return 
1;
        }
        return 
1;
    }
    else if(
afk[playerid] == && ZDM[playerid] != && Dming[playerid] != 2)
    {
        
TogglePlayerControllable(playerid1);
        
//DeletePlayer3DTextLabel(playerid,
        
SetPlayerHealth(playeridafkHealth[playerid]);
        
//KillTimer(GODAFK);
        
TextDrawHideForPlayer(playeridafkDraw);
        
afk[playerid] = 1;
        return 
1;
    }
    else return 
1;

I have an error. I don't know how to resolve it.

PHP код:
C:\--(5807) : error 001expected token"]"but found "-identifier-"
C:\--(5807) : warning 215expression has no effect
C
:\--(5807) : error 001expected token";"but found "]"
C:\--(5807) : error 029invalid expressionassumed zero
C
:\--(5807) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

Reply
#2

Код:
GetPlayerName(playerid, PlayerAfkName[playerid], MAX_PLAYER_NAME);
And what's the +1 for? The name limit is 24 characters.
Код:
new PlayerAfkName[MAX_PLAYERS][MAX_PLAYER_NAME+1];
Reply
#3

To prevent the error :
pawn Код:
032 - array index out of bounds
The array index is larger than the highest valid entry of the array.
Reply
#4

PHP код:
new PlayerAfkName[MAX_PLAYER_NAME+1]; 
PHP код:
GetPlayerName(playeridPlayerAfkNameMAX_PLAYER_NAME); 
Reply
#5

working - sizeof(PlayerAfkName)

BUT, the value sizeof is 500. (Get MAX_PLAYERS value, not recommended)
Reply
#6

Quote:
Originally Posted by luke49
Посмотреть сообщение
PHP код:
new PlayerAfkName[MAX_PLAYER_NAME+1]; 
PHP код:
GetPlayerName(playeridPlayerAfkNameMAX_PLAYER_NAME); 
Not at all. The variable PlayerAfkName will take the name of the last player typed the command.

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
working - sizeof(PlayerAfkName)

BUT, the value sizeof is 500. (Get MAX_PLAYERS value, not recommended)
Alright, I get the problem thanks by you. +rep

PHP код:
new PlayerAfkName[MAX_PLAYERS][MAX_PLAYER_NAME+1];  » new PlayerAfkName[MAX_PLAYER_NAME+1][MAX_PLAYERS]; 
But now, I have an another weird problem. The Gametext is showing the name of the player.
PHP код:
GameTextForPlayer(playerid"AFK"40003); 
If I delete this line, the problem comes here
PHP код:
afkDraw TextDrawCreate(285.00000018.000000,"~r~AFK"); 
Reply
#7

Код:
new PlayerAfkName[MAX_PLAYER_NAME+1][MAX_PLAYERS];
That is not the correct thing to use.

I already gave the correct solution to the name problem.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)