Defines - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Defines (
/showthread.php?tid=87595)
Defines -
SiJ - 21.07.2009
hey,
I have this in my script:
pawn Code:
#define AdMsg 1; //At the top
//This doesn't work:
public FoundBug(playerid) //Timer
{
if(strcmp(AdMsg,"1",true)==0) //Error
{
//MSG
}
else if(strcmp(AdMsg,"2",true)==0) //Error
{
//MSG
}
else if(strcmp(AdMsg,"3",true)==0) //Error
{
//MSG
}
}
And I get these errors:
error 017: undefined symbol "AdMsg"
error 017: undefined symbol "AdMsg"
error 017: undefined symbol "AdMsg"
I also tried
nut it still doesn't work..
Re: Defines -
Weirdosport - 21.07.2009
You defined it as an integer, you you're trying to use strcmp (designed for strings).
You just need to do if(AdMsg == 1)
Re: Defines -
SiJ - 21.07.2009
Quote:
Originally Posted by Justas [SiJ
]
hey,
I have this in my script:
pawn Code:
#define AdMsg 1; //At the top
//This doesn't work: public FoundBug(playerid) //Timer { if(strcmp(AdMsg,"1",true)==0) //Error { //MSG } else if(strcmp(AdMsg,"2",true)==0) //Error { //MSG } else if(strcmp(AdMsg,"3",true)==0) //Error { //MSG } }
And I get these errors:
error 017: undefined symbol "AdMsg"
error 017: undefined symbol "AdMsg"
error 017: undefined symbol "AdMsg"
I also tried
but it still doesn't work..
|
I get these
warnings:
warning 206: redundant test: constant expression is non-zero
warning 206: redundant test: constant expression is non-zero
warning 206: redundant test: constant expression is non-zero
On same lines as before
Re: Defines -
woot - 21.07.2009
You don't need #define AdMsg 1
; -> #define AdMsg 1
Re: Defines -
Weirdosport - 21.07.2009
pawn Code:
#define AdMsg 1 //At the top
//This doesn't work:
public FoundBug(playerid) //Timer
{
switch(AdMsg)
{
case 1: //msg
case 2: //msg
case 3: //msg
}
}
Looking at your code though, you're always going to get 1. You can't change a define (Well you can using #undef but that's silly). You'd be better off having AdMsg as a variable, that way you can easily change it to another value to alternate between messages.
Re: Defines -
SiJ - 21.07.2009
Quote:
Originally Posted by //exora
You don't need #define AdMsg 1; -> #define AdMsg 1
|
Oops.. typo.. It's
#define AdMsg 1 in my script..
Quote:
Originally Posted by Weirdosport
pawn Code:
#define AdMsg 1 //At the top
//This doesn't work: public FoundBug(playerid) //Timer { switch(AdMsg) { case 1: //msg case 2: //msg case 3: //msg } }
|
Thanks.. Hope it works