Raised This Month: $ Target: $400
 0% 

how can i check does array field was already set


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
orglee
Member
Join Date: Dec 2005
Old 12-03-2007 , 22:36   how can i check does array field was already set
Reply With Quote #1

Hello.
I'm creating a menu which player can disable.
Player settings are being stored in multi-dimensional
Code:
enum E_PLAYER {   menu_on = 1 } new g_players[32][E_PLAYER]
But when player connects to the server this variable isn't set and I want it to be set on 1 or...
I want the plugin to recognize empty var as 1
Now I'm checking it using function below.
Code:
public menuStatusGet(id) {   new out   if(equal(g_players[id][menu_on], "") || g_players[id][menu_on] == 1) {     client_print(id, print_chat, "MENU: its on")     out = 1   } else {     client_print(id, print_chat, "MENU: its off")     out = 0   }   client_print(id, print_chat, "menu_on equals: %d", g_players[id][menu_on])   return out }
It is probably cause I'm using equal to check does its empty.
How should I check it so its will return correct value ?
Regards.
orglee is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-03-2007 , 22:57   Re: how can i check does array field was already set
Reply With Quote #2

I don't understand why you're using an 'enum()' for that.

new g_players[33]; is sufficient.

And if you want to fill with 1 by default, just do that:

new g_players[33] = { 1, ... };
__________________
Arkshine is offline
orglee
Member
Join Date: Dec 2005
Old 12-04-2007 , 00:53   Re: how can i check does array field was already set
Reply With Quote #3

Quote:
Originally Posted by arkshine View Post
I don't understand why you're using an 'enum()' for that.
Darn my bad. I'm using this to store two informations.
enum E_PLAYER {
menu_on = 1,
rifle_page = 2
}
I need to store somehow pagination info about current menu page thats why I'm using enum its not that I'm only storing one info in that array.
Please tell me how can do thing I have written in first post.
edit>
besides I think using enum makes code more clean and understandable
edit>>
And on more thing I know how to set default value for a var but do you know how to set default var for all players in that array, with enum of course ?

Last edited by orglee; 12-04-2007 at 00:57.
orglee is offline
Old 12-04-2007, 06:47
ConnorMcLeod
This message has been deleted by ConnorMcLeod. Reason: my bad
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode