Undefined symbol
#1

My script
pawn Код:
CMD:XXXXXX (playerid, params[])
    {
    if(pVariable=0;
    {
    return 0;
 }
    if(IsPlayerInRangeOfPoint(playerid,XXXXXXXXXXXXX))
    {
    SendClientMessage(playerid, 0xFFFFFFFF, "XXXXXXXXXXXXXX");
    DestroyPlayerObject(playerid, XXXXX);
    CreatePlayerObject(XXXXXXXXXXXXXXXXX);
    CreatePlayerObject(XXXXXXXXXXXXXXXXX);
    CreatePlayerObject(XXXXXXXXXXXXXXXXX);
    CreatePlayerObject(XXXXXXXXXXXXXXXXX);
    CreatePlayerObject(XXXXXXXXXXXXXXXXX);
    }
    return 1;
    }
}
Код:
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\xxx.pwn(245) : error 017: undefined symbol "pVariable"
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\xxx.pwn(245) : warning 215: expression has no effect
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\xxx.pwn(252) : error 017: undefined symbol "pVariable"
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\xxxr.pwn(252) : warning 215: expression has no effect
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\xxx.pwn(256) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Anyone able to help me with these errors? Kind of confused as i have defined the variable..

new pVariable=0;

edit - Edited code/errors as i fixed 1 of the errors
Reply
#2

Choose one option. A global variable for all the players or not?

According to your previous thread, you were using it for all the players, on this not.

In that case;
pawn Код:
// Global variable
new
    gVariable
;

CMD:XXXXXX (playerid, params[])
{
    if(gVariable != 0 && IsPlayerInRangeOfPoint(playerid,XXXXXXXXXXXXX))
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "XXXXXXXXXXXXXX");
        DestroyPlayerObject(playerid, XXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
    }
    return 1;
}
Reply
#3

^^ What that guy said. As for the unreachable code copy and paste this in.

pawn Код:
CMD:XXXXXX (playerid, params[])
{
    if(pVariable != 0 && IsPlayerInRangeOfPoint(playerid,XXXXXXXXXXXXX))
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "XXXXXXXXXXXXXX");
        DestroyPlayerObject(playerid, XXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
    }
    return 1;
}
Reply
#4

Your syntax is incorrect. I find that funny as it is correct for your second if check. Also note that for '=' is assignment while '==' is comparison.
Reply
#5

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Choose one option. A global variable for all the players or not?

According to your previous thread, you were using it for all the players, on this not.

In that case;
pawn Код:
// Global variable
new
    gVariable
;

CMD:XXXXXX (playerid, params[])
{
    if(gVariable != 0 && IsPlayerInRangeOfPoint(playerid,XXXXXXXXXXXXX))
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "XXXXXXXXXXXXXX");
        DestroyPlayerObject(playerid, XXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
        CreatePlayerObject(XXXXXXXXXXXXXXXXX);
    }
    return 1;
}
Thanks for your help, The variable is global as its needed in two of my commands, Basically the players variable value needs to be 1 so can i change

if(gVariable != 0 && IsPlayerInRangeOfPoint(playerid,XXXXXXXXXXXXX))

to

if(gVariable != 1 && IsPlayerInRangeOfPoint(playerid,XXXXXXXXXXXXX))

Will that mean they have to have the value 1 or they can't use the command?
Reply
#6

!= 0 means not equal to 0. So, basically is 1.
Reply
#7

Quote:
Originally Posted by Dwane
Посмотреть сообщение
!= 0 means not equal to 0. So, basically is 1.
Thanks

also now only have these errors

Код:
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\Butcher.pwn(245) : error 017: undefined symbol "pVariable"
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\Butcher.pwn(245) : warning 215: expression has no effect
C:\Users\Scripting.Ash-PC\Desktop\Roleplay\filterscripts\Butcher.pwn(252) : error 017: undefined symbol "pVariable"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
But in my other command after the command is executed it adds the value of 1 to the variable.

Command one is

pVariable++;

Then in the second command it checks if the value is not equal to 0
Reply
#8

You need to define them. I am also a bit confused with pVariable and gVariable . Is this for the same use or different? Moreover, if you need to increase a variable by one per player you need to define it as the following.
pawn Код:
new
    pVariable[ MAX_PLAYERS ]
;

// On command
pVariable[ playerid ]++;

// In case you need to check if it is equal to 1
if( pVariable[ playerid ] == 1 )
{
    // code
}
Reply
#9

Quote:
Originally Posted by Dwane
Посмотреть сообщение
You need to define them. I am also a bit confused with pVariable and gVariable . Is this for the same use or different? Moreover, if you need to increase a variable by one per player you need to define it as the following.
pawn Код:
new
    pVariable[ MAX_PLAYERS ]
;

// On command
pVariable[ playerid ]++;

// In case you need to check if it is equal to 1
if( pVariable[ playerid ] == 1 )
{
    // code
}
Sorry yea, gVariable and pVariable is the same variable, Its not actually named that in my script i was just naming it that because i didn't want any hints of what my script is as i think its quite unique atm, Also it seems everything matches what you just put, However im still getting the undefined symbol error :S
Reply
#10

In my opinion, nothing is unique; it just differs from others! Anyway, on-topic now.

Make sure you define the variable before the part you're using it and not inside any callback.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)