Using strings/variables in #define definitive - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Using strings/variables in #define definitive (
/showthread.php?tid=526408)
Using strings/variables in #define definitive -
BroZeus - 17.07.2014
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
}
Re: Using strings/variables in #define definitive -
Konstantinos - 17.07.2014
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.
Re: Using strings/variables in #define definitive -
BroZeus - 17.07.2014
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
Re: Using strings/variables in #define definitive -
Konstantinos - 17.07.2014
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?
Re: Using strings/variables in #define definitive -
BroZeus - 17.07.2014
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"