AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   #define variable variable2 (https://forums.alliedmods.net/showthread.php?t=210135)

.Dare Devil. 03-06-2013 19:06

#define variable variable2
 
PHP Code:

new a_test[6]

public 
plugin_init()
{
    new 
a
    
#define b[%1] a_test[%1]
    
b[4] = 12
    a 
6
    test2
(a)
}

test2(a)
{
    if(
== 5b[3] = 16


What i want to is that #define b is only inside of function plugin_init.
[ Some global variables are long and its pretty annoying to write and it also take some time. ]

My question is that how i can do it?

Arkshine 03-06-2013 19:09

Re: #define variable variable2
 
How it does matter a macro would not be only is a specific function ? That's something replace at compilation time, I don't see problems.

.Dare Devil. 03-06-2013 19:16

Re: #define variable variable2
 
Quote:

Originally Posted by Arkshine (Post 1908025)
How it does matter a macro would not be only is a specific function ? That's something replace at compilation time, I don't see problems.

Im sorry, i have a bad english. Didnt understand you.
( First sentence to be precise )

Emp` 03-07-2013 00:07

Re: #define variable variable2
 
If you need to make a macro function specific, you can do it like:
Code:

function()
{
  #define my_macro macro_code

  //...

  #undef my_macro
}


fysiks 03-07-2013 02:01

Re: #define variable variable2
 
Stuff like this throws up a red flag for me. There has got to be a better way to do what you want.

.Dare Devil. 03-07-2013 13:08

Re: #define variable variable2
 
Quote:

Originally Posted by fysiks (Post 1908174)
Stuff like this throws up a red flag for me. There has got to be a better way to do what you want.

Can you please tell me that better way?

Edit: i misunderstood you. I saw that the second sentence was # i have a better way # or something.
Its me, i am sorry.

hleV 03-07-2013 14:58

Re: #define variable variable2
 
Write down the full variable name.

ConnorMcLeod 03-07-2013 15:23

Re: #define variable variable2
 
Avoid stupid stuff.

Doc-Holiday 03-07-2013 15:35

Re: Re: #define variable variable2
 
Quote:

Originally Posted by .Dare Devil. (Post 1908401)
Can you please tell me that better way?

And explain what you want better. What are you using the macro for. Otherwise they can't tell you a better way. Connor does a great job of explaining the best way without knowing what your trying to do

.Dare Devil. 03-07-2013 17:11

Re: #define variable variable2
 
Quote:

Originally Posted by ConnorMcLeod (Post 1908454)
Avoid stupid stuff.

Well, yes you see many stupid things posted by me but its stupid because you dont understand me and i cant explain well.
And also my logic is weird for ohter peoples.

edit: also sometimes, i just dont understand what they say to me.
Its not because i have very bad english, I did not focused enough.

Quote:

Originally Posted by Doc-Holiday (Post 1908462)
And explain what you want better. What are you using the macro for. Otherwise they can't tell you a better way. Connor does a great job of explaining the best way without knowing what your trying to do

uhhh, all i want to do is use variables named in function like a,b,c,f etc...
if the global variable name is long and your function code is long then you lose time by writing every time that long variable name.
for example ( new g_flashlightcolor[33][3] )
there is possible to change global variable to shorter name but the thing is, i dont understand later what this is or what can happen is that 2 variables have the same name.
I try to avoid that.

If you know how to zp work then you see that the creator of it did 9 or more plugins for one mod.
What i do is that my mod will be just 1 sma but with parts ( many .inc-s )
Also each .inc code have different variable tag.

Quote:

Originally Posted by hleV (Post 1908438)
Write down the full variable name.

This is just an idea.


All times are GMT -4. The time now is 21:46.

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