Defines
#1

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
pawn Code:
if(AdMsg == 1)
nut it still doesn't work..
Reply
#2

You defined it as an integer, you you're trying to use strcmp (designed for strings).

You just need to do if(AdMsg == 1)
Reply
#3

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
pawn Code:
if(AdMsg == 1)
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
Reply
#4

You don't need #define AdMsg 1; -> #define AdMsg 1
Reply
#5

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.
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)