[HELP] String in Enum
#1

Hello, I am currently working on a TDM mode and I want to make a PlayerInfo variable to store data as admin level and such... well I succedd stroing admin levels but when I try to store data as team name or something like that I get errors...
this is what i've done:

enum pInfo {
admin,
level,
kills,
team[256]
};

new PlayerInfo[MAX_PLAYERS][pInfo];

---------
but when I try to do:
PlayerInfo[playerid][team] = "none";
for example, I get some errors like array sizes does not much and more....
someone gave me the following code to write in this variable that works:
strmid(PlayerInfo[playerid][team], "none", 0, strlen("none"), 256);


but when I try to read:
if (PlayerInfo[playerid][team] = "agent") { AgentRandomSpawnPlayer(playerid); }
I get these errors:

warning 211: possibly unintended assignment
error 047: array sizes do not match, or destination array is too small

someone knows what's the problem?
Reply
#2

You forgot an "=" sign in there:

if (PlayerInfo[playerid][team] = "agent") { ElvisRandomSpawnPlayer(playerid); }

change to:

if (PlayerInfo[playerid][team] == "agent") { ElvisRandomSpawnPlayer(playerid); }

but just doing this will not work I dont think, you need to use strmid.
Reply
#3

damn i'm stupid...
but yet there's a new error:
array must be indexed (variable "-unknown-")
Reply
#4

ah sorry you replied to quick read my post again I edited
Reply
#5

ok I've read.... I'll try to use strmid and i'll check if it works...

EDIT:
i'm so damn stupid, I should have used strcmp in the start -.- I used string = string instead of strcmp....
this works without strmid and stuff like that:
if (!strcmp(PlayerInfo[playerid][team],"agent",true)) { AgentRandomSpawnPlayer(playerid); }
Reply
#6

yep good job
Reply
#7

enum pInfo[][amount of vars in the enum]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)