[solved] clear function's global variable
I have a function and I send it a variable, a global one, and I was wondering how I get what variable name I sent to the function in order to clear it inside the function ?
Code:
new g_iTest[3] |
Re: clear function's global variable
Code:
stock clearVar(&var) |
Re: clear function's global variable
You would have to make something like this :
PHP Code:
|
Re: clear function's global variable
Quote:
Code:
new g_iVar1 = 0I'm using them for entitiy ID reset, so I would not need to write in every function "if is_valid_ent -> remove entity then set var to 0" instead just a function :} |
Re: clear function's global variable
I don't think so :
clearVar(g_iVar1) doesn't pass a var but it's value The way i showed you pass something that lets you identify the var, should be other/better ways though. |
Re: clear function's global variable
@Hunting-Digital : G-Dog's method is perfectly fine with your exemple. But depending you want to do, using an enum could be more readable.
|
Re: clear function's global variable
PHP Code:
Following output: Code:
g_Test was randomized: 34 |
Re: clear function's global variable
Quote:
Anyway, why don't you directly do : g_var = 0 ? |
Re: clear function's global variable
Quote:
Code:
if(is_valid_ent(g_iAnEnt))Code:
clear(g_iAnEnt) |
Re: clear function's global variable
Yeah, for that, & is fine. No need to use enum and such. :)
|
| All times are GMT -4. The time now is 02:24. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.