AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set all array to true (https://forums.alliedmods.net/showthread.php?t=147262)

fmfs10 01-07-2011 11:01

Set all array to true
 
Hello! I'm trying to do a plugin with this array:

PHP Code:

new bool:g_playerFirstEnter_Menu[33][MAX_PAGES_MENU-1// Where 33 is the id of player and MAX_PAGES_MENU a define that sets max pages of a menu 

I tried to set every slot to true. But I don't know exactly how to do this, so I tried 2 ways:

PHP Code:

//client_putinserver(id)...
for(new 0MAX_PAGES_MENU-1i++)
    
g_playerFirstEnter_Menu[id][i] = true 

and:

PHP Code:

new bool:g_playerFirstEnter_Menu[33][MAX_PAGES_MENU-1] = {true, ...} 

But none of them works... What can I do?

ARES[ro] 01-07-2011 11:17

Re: Set all array to true
 
You can use it as false lol... its a boolean. Just call it new bool:g_playerNotFirstEnter_Menu[33][MAX_PAGES_MENU-1]

fmfs10 01-07-2011 11:23

Re: Set all array to true
 
Yeah but I need it to start already true... All the slots. Bools starts as false

And I think it's unnecessary set each slot to one by one.

There is no way to set all the slots to true in one time?

ARES[ro] 01-07-2011 11:33

Re: Set all array to true
 
I am just saying that by doing that its less optimized code. Just use it as defaulted to 0 cuz man a boolean only has 2 values 1 and 0 so it doesnt change anything in ur code. I suggest u use it as false from the start never start as true.
PHP Code:

for(new 033e++)
    for(new 
0MAX_PAGES_MENU-1i++)
        
g_playerFirstEnter_Menu[e][i] = true 

Yes it is unnecessary just start as false... Its impossible to give it a constant value from the definition because its a 2 dimension array.

fmfs10 01-07-2011 11:43

Re: Set all array to true
 
I tried again the putinserver thing and it worked now. LOL
I don't now why o.O

Thanks anyway... I discovered a new think now ^^

drekes 01-07-2011 12:25

Re: Set all array to true
 
try
Code:

public client_putinserver(id)
    arrayset(g_playerFirstEnter_Menu[id], true, MAX_PAGES_MENU - 1);



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

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