SA-MP Forums Archive
Array must be indexed (name[MAX_PLAYER_NAME]) - 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: Array must be indexed (name[MAX_PLAYER_NAME]) (/showthread.php?tid=607788)



Array must be indexed (name[MAX_PLAYER_NAME]) - andrejc999 - 23.05.2016

So guys I'm having a problem with my event system... So when the player that finished first enters the last race checkpoint I want to send a client message to whole server that he finished 1st. So I tried to get players name by command GetPlayerName(playerid, name, sizeof(name)); but it doesn't work idk why.

Error:

Код:
D:\Samp server\gamemodes\grandlarc.pwn(3834) : error 033: array must be indexed (variable "name")
Here is code where the problem is:

Код:
public OnPlayerEnterRaceCheckpoint(playerid)
{
    //I cut out a part of code that comes here.. :)
    	if(EventCheck[playerid] == 6)
    	{
            EventCheck[playerid] = 0;
            new msg1[128], name[MAX_PLAYER_NAME];
            name = GetPlayerName(playerid, name, sizeof(name));
            if(zavrsili == 1)
            {
                if(zavrsili == 2)
                {
                    if(zavrsili == 3)
                    {
						SetPlayerHealth(playerid, 0);
                        return 1;
                    }
                    format(msg1, sizeof(msg1), "Igrac %s je zavrsio event na trecem mestu! | Nagrada:$1000", name);
                    SCMALL(COLOR_INFO, msg1);
                    treci[playerid] = 1;
					zavrsili = 3;
					GivePlayerMoney(playerid, 1000);
					for(new id=0;id<MAX_PLAYERS;id++)
					{
					    if(OnEvent[id] == 1)
					    {
							SetPlayerHealth(id, 0);
							OnEvent[id] = 0;
							poceo = 0;
							eventid = 0;
					    }
					}
                    return 1;
                }
                format(msg1, sizeof(msg1), "Igrac %s je zavrsio event na drugom mestu! | Nagrada:$2000", name);
                SCMALL(COLOR_INFO, msg1);
                drugi[playerid] = 1;
                zavrsili = 2;
                GivePlayerMoney(playerid, 2000);
                return 1;
            }
            format(msg1, sizeof(msg1), "Igrac %s je zavrsio event na prvom mestu! | Nagrada:$3000", name);
            SCMALL(COLOR_INFO, msg1);
            prvi[playerid] = 1;
            zavrsili = 1;
            GivePlayerMoney(playerid, 3000);
    	    return 1;
    	}
    return 1;
}
Can anybody help me and why is this CODE option messing up my code when I paste it?

And idk why is my gamemode still called grandlarc but ok.. :/


Re: Array must be indexed (name[MAX_PLAYER_NAME]) - Jefff - 23.05.2016

Remove 'name = ' part


Re: Array must be indexed (name[MAX_PLAYER_NAME]) - andrejc999 - 23.05.2016

Oh omg I'm dumb thx m8...


Re: Array must be indexed (name[MAX_PLAYER_NAME]) - CSLangdale - 24.05.2016

Change the name of your game modes in ongamemodeinit you should see it in there saying grandlarc or just do the simple things search grandlarc and change it