Enum help - 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: Enum help (
/showthread.php?tid=599876)
Enum help -
adithegman - 31.01.2016
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
Re: Enum help -
BiosMarcel - 31.01.2016
If you want the value of any of these just type ChannelInfo[playerid][cSlot1 / cSlot2 / cSlot3]
Re: Enum help -
adithegman - 31.01.2016
That was just an example, I need it elsewhere in the script... and I can't do it like you said.
Re: Enum help -
Darkwood17 - 31.01.2016
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.
Re: Enum help -
Lucky13 - 31.01.2016
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);
Re: Enum help -
adithegman - 31.01.2016
It seems to be working, thanks man [rep+]
Re: Enum help -
Lucky13 - 31.01.2016
Quote:
Originally Posted by adithegman
It seems to be working, thanks man [rep+]
|
No worries! Glad I could help!