Raised This Month: $32 Target: $400
 8% 

#define variable variable2


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 03-06-2013 , 19:06   #define variable variable2
Reply With Quote #1

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?
.Dare Devil. is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-06-2013 , 19:09   Re: #define variable variable2
Reply With Quote #2

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.
__________________
Arkshine is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 03-06-2013 , 19:16   Re: #define variable variable2
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
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 )
.Dare Devil. is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-07-2013 , 00:07   Re: #define variable variable2
Reply With Quote #4

If you need to make a macro function specific, you can do it like:
Code:
function()
{
   #define my_macro macro_code

   //...

   #undef my_macro
}
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-07-2013 , 02:01   Re: #define variable variable2
Reply With Quote #5

Stuff like this throws up a red flag for me. There has got to be a better way to do what you want.
__________________
fysiks is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 03-07-2013 , 13:08   Re: #define variable variable2
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
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.

Last edited by .Dare Devil.; 03-07-2013 at 17:16.
.Dare Devil. is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 03-07-2013 , 14:58   Re: #define variable variable2
Reply With Quote #7

Write down the full variable name.
__________________
hleV is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-07-2013 , 15:23   Re: #define variable variable2
Reply With Quote #8

Avoid stupid stuff.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-07-2013 , 15:35   Re: Re: #define variable variable2
Reply With Quote #9

Quote:
Originally Posted by .Dare Devil. View Post
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
Doc-Holiday is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 03-07-2013 , 17:11   Re: #define variable variable2
Reply With Quote #10

Quote:
Originally Posted by ConnorMcLeod View Post
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 View Post
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 View Post
Write down the full variable name.
This is just an idea.

Last edited by .Dare Devil.; 03-07-2013 at 17:19.
.Dare Devil. is offline
Reply



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 18:58.


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