Enum help
#1

If I have this enum:

Код:
enum cData
{
	cSlot1,
	cSlot2,
	cSlot3
}
new ChannelInfo[MAX_PLAYERS][cData];
Is there any way that I can get the value of the first term? Example

Код:
ChannelInfo[playerid][cSlot1] = 123
ChannelInfo[playerid][cSlot2] = 456
ChannelInfo[playerid][cSlot1] = 789

// When a player types /mychannels, can I do this?
for(new i;i<3;i++)
{
     new string[128];
     format(string,sizeof(string),"Slot: %d; Channel: %d",i,ChannelInfo[playerid][j])
     SendClientMessage(playerid,-1,string);
}
Thank you for your time
Reply
#2

If you want the value of any of these just type ChannelInfo[playerid][cSlot1 / cSlot2 / cSlot3]
Reply
#3

That was just an example, I need it elsewhere in the script... and I can't do it like you said.
Reply
#4

Quote:
Originally Posted by adithegman
Посмотреть сообщение
That was just an example, I need it elsewhere in the script... and I can't do it like you said.
Explain more.
Reply
#5

you can try the enum like this:
Код:
enum cData
{
     Channel[3]
}
new ChannelInfo[MAX_PLAYERS][cData];
ChannelInfo[playerid][Channel][0] = Channel 1
ChannelInfo[playerid][Channel][1] = Channel 2
ChannelInfo[playerid][Channel][2] = Channel 3

I hope you understand what I mean.

So you can use now this:
Код:
new string[128];

format(string,sizeof(string),"Slot: 1; Channel: %d",ChannelInfo[playerid][0]) // Slot 1
SendClientMessage(playerid,-1,string);

format(string,sizeof(string),"Slot: 2; Channel: %d",ChannelInfo[playerid][1]) // Slot 2
SendClientMessage(playerid,-1,string);

format(string,sizeof(string),"Slot: 3; Channel: %d",ChannelInfo[playerid][2]) // Slot 3
SendClientMessage(playerid,-1,string);
Reply
#6

It seems to be working, thanks man [rep+]
Reply
#7

Quote:
Originally Posted by adithegman
Посмотреть сообщение
It seems to be working, thanks man [rep+]
No worries! Glad I could help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)