SA-MP Forums Archive
undefined symbol. - 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: undefined symbol. (/showthread.php?tid=662420)



undefined symbol. - KinxpIn - 31.12.2018

guys... what's wrong with this code? :3

PHP код:
CheckPlayerFactName(playerid)
{
    new 
fact pInfo[playerid][pFaction];
    new 
noneSAPDSAMDSANASAGS;
    if(
fact 1)
    {
        return 
none;
    }
    if(
fact == 1)
    {
        return 
SAPD;
    }
    if(
fact == 2)
    {
        return 
SAMD;
    }
    if(
fact == 3)
    {
        return 
SANA;
    }
    if(
fact == 4)
    {
        return 
SAGS;
    }
    return 
0;
}
CMD:locker(playeridparams[])
{
    new 
fname CheckPlayerFactName(playerid);
    if(!
IsPLogged(playerid)) return Error(playerid4);
    switch(
fname)
    {
        case 
none// error: UNDEFINED SYMBOL
        
{
            
SCM(playeridCOLOR_LIGHTBLUE"SERVER: {FFFFFF}You're not joined in any faction");
        }
        case 
SAPD// error: UNDEFINED SYMBOL
        
{
            
SCM(playeridCOLOR_LIGHTBLUE"Faction: {FFFFFF}You've opened SAPD locker");
        }
        case 
SAMD// error: UNDEFINED SYMBOL
        
{
            
SCM(playeridCOLOR_LIGHTBLUE"Faction: {FFFFFF}You've opened SAMD locker");
        }
        case 
SANA// error: UNDEFINED SYMBOL
        
{
            
SCM(playeridCOLOR_LIGHTBLUE"Faction: {FFFFFF}You've opened SANA locker");
        }
        case 
SAGS// error: UNDEFINED SYMBOL
        
{
            
SCM(playeridCOLOR_LIGHTBLUE"Faction: {FFFFFF}You've opened SAGS locker");
        }
    }
    return 
1;

I can't think again xD


Re: undefined symbol. - RogueDrifter - 31.12.2018

:3 Its because :3 you defined a variable :3 locally :3 and tried using it :3 globally :3 so instead :3 you should move the line :3
Код:
new none, SAPD, SAMD, SANA, SAGS;
from under :3 the cmd :3 to the top of the script :3 like so :3
instead of :3
Код:
CheckPlayerFactName(playerid) 
{ 
    new fact = pInfo[playerid][pFaction]; 
    new none, SAPD, SAMD, SANA, SAGS;
it should be :3

Код:
new none, SAPD, SAMD, SANA, SAGS; // Top of the script
CheckPlayerFactName(playerid) 
{ 
    new fact = pInfo[playerid][pFaction];



Re: undefined symbol. - KinxpIn - 31.12.2018

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
:3 Its because :3 you defined a variable :3 locally :3 and tried using it :3 globally :3 so instead :3 you should move the line :3
Код:
new none, SAPD, SAMD, SANA, SAGS;
from under :3 the cmd :3 to the top of the script :3 like so :3
instead of :3
Код:
CheckPlayerFactName(playerid) 
{ 
    new fact = pInfo[playerid][pFaction]; 
    new none, SAPD, SAMD, SANA, SAGS;
it should be :3

Код:
new none, SAPD, SAMD, SANA, SAGS; // Top of the script
CheckPlayerFactName(playerid) 
{ 
    new fact = pInfo[playerid][pFaction];
XDDDDD


Re: undefined symbol. - RogueDrifter - 31.12.2018

Quote:
Originally Posted by KinxpIn
Посмотреть сообщение
XDDDDD
XD LoL ^~^


Re: undefined symbol. - KinxpIn - 31.12.2018

But, in this case isn't it if "fname = CheckPlayerFactName(playerid);"
The fname should match the faction name right? (SAPD, SAMD, etc)

I can just use "if", but I'm trying to use the "switch" method
So, I'd better use "switch, case" or "if"?

example
Код:
switch (string)
{
*     case SAPD:
}
//OR
if (string == SAPD)
{
    do something;
}