SA-MP Forums Archive
Array Must Be Indexed - 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 (/showthread.php?tid=637670)



Array Must Be Indexed - Speaker - 19.07.2017

Код:
		new file[122];
        format(file,sizeof(file),"/ladmin/users/%s.sav",PlayerName2(playerid));
        PlayerInfo[playerid][Banned_By] = dini_Get(file, "Banned_By");
        PlayerInfo[playerid][Ban_Reason] = dini_Get(file, "Ban_Reason");
Errors
Код:
error 006: must be assigned to an array
error 006: must be assigned to an array
Error Line
Код:
     PlayerInfo[playerid][Banned_By] = dini_Get(file, "Banned_By");
        PlayerInfo[playerid][Ban_Reason] = dini_Get(file, "Ban_Reason");



Re: Array Must Be Indexed - Hansrutger - 19.07.2017

I haven't done much dini but oh' well.

Inside your enum declaration you should be having something like this:

enum e_PlayerInfo {
Banned_By,
Ban_Reason
};

Have you made those two into arrays? Should be looking like this if you want it to be correct:
enum e_PlayerInfo {
Banned_By[MAX_PLAYER_NAME],
Ban_Reason[128]
};

EDIT:
Nevermind I was stupid, it should maybe work like if you put it into a format.

Код:
format(PlayerInfo[playerid][Banned_By], MAX_PLAYER_NAME, "%s", dini_Get(file, "Banned_By");



Re: Array Must Be Indexed - Kaperstone - 19.07.2017

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
I haven't done much dini but oh' well.

Inside your enum declaration you should be having something like this:

enum e_PlayerInfo {
Banned_By,
Ban_Reason
};

Have you made those two into arrays? Should be looking like this if you want it to be correct:
enum e_PlayerInfo {
Banned_By[MAX_PLAYER_NAME],
Ban_Reason[128]
};

EDIT:
Nevermind I was stupid, it should maybe work like if you put it into a format.

Код:
format(PlayerInfo[playerid][Banned_By], MAX_PLAYER_NAME, "%s", dini_Get(file, "Banned_By");
Banned_By[MAX_PLAYER_NAME + 1]
for the termination \0 cell

also, I suggest to use memcpy or strcat at least instead of format
Код:
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2);
strcpy(dest, str[], length);
for this reason


Re: Array Must Be Indexed - Speaker - 19.07.2017

Quote:
Код:
format(PlayerInfo[playerid][Banned_By], MAX_PLAYER_NAME, "%s", dini_Get(file, "Banned_By");
Thanks Well U Made A Mistake
It Should Be
Код:
format(PlayerInfo[playerid][Banned_By], 256, "%s", dini_Get(file, "Banned_By"));



Re: Array Must Be Indexed - Kaperstone - 19.07.2017

Quote:
Originally Posted by Speaker
Посмотреть сообщение
Thanks Well U Made A Mistake
It Should Be
Код:
format(PlayerInfo[playerid][Banned_By], 256, "%s", dini_Get(file, "Banned_By"));
He didnt' make a mistake, MAX_PLAYER_NAME is defined to equal to 24, which is the maximum length a nickname on samp can be.
Why do you set it to 256?
I thought Banned_By holds the name of the player who bans the other player.

If so, it should be 24 at max. because nicknames on samp cannot be longer than this.


Re: Array Must Be Indexed - Hansrutger - 19.07.2017

Aye I forget about the \ thanks, should probably fix this in my own gamemode since I never really thought about it.

Ї\_(ツ)_/Ї