Using strings/variables in #define definitive
#1

Heya long time that i have not posted in this section
But i need a help today
So is it possible that we use a string/variables in a definitve #define
for example --
pawn Код:
CMD:test(playerid, params[])
{
//now params is a string
//now how i use the variable "params" in #define line
//it will give me an error if i do like #define something params
}
Reply
#2

As arguments or as a symbol name? An example would be helpful to understand for what you want it and plus the errors you get.
Reply
#3

well i was testing something
for example this
pawn Код:
#define SetHook:%1(%2) \
  #define zzz %1  \
  CallLocalFunction("Set")
errors
Код:
: error 029: invalid expression, assumed zero
: error 017: undefined symbol "zzz"
: error 076: syntax error in the expression, or invalid function call
: fatal error 107: too many error messages on one line
Reply
#4

That code doesn't make any sense and plus the arguments in CallLocalFunction are wrong.

I'll assume the parameters are "playerid" and "params" and you want to call public function "Set" with those arguments (but still doesn't make sense).

pawn Код:
// just an example of using "params" (a string as a parameter):
#define SetHook:%1(%2) CallLocalFunction("Set", "is", (%1), (isnull(%2)) ? ("\1") : (%2))
That would call "Set" public function with "playerid" and "params" (from the command) as arguments.

---

Would you mind to explain what exactly you want to do?
Reply
#5

i was just testing a function for hooking functions in one line i
ik that calllocal has more parameters but i was just tessting something so i didnt put
"Set" Contains the code to undefine ALS
for example i want to do like this--
pawn Код:
#define SetHook:%1(%2) \
  #define zzz %1  

CMD:test(playerid, params[])
{
SetHook:params(...);//ignore the arguments of this
//now when i type /test BLA i want to set zzz value as "BLA" not "params"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)