y_ini saved item problem
#1

I dont know how to use it as a If statement
My code
pawn Код:
enum pInfo
{
    pPass[129],
    pFirstStart
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("StartPackage",PlayerInfo[playerid][pFirstStart]);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"Player Data");
    INI_WriteInt(File,"StartPackage",PlayerInfo[playerid][pFirstStart]);
    INI_Close(File);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(gPlayerClass[playerid] == Blah1)
    {
        if(FirstStart[playerid][pFirstStart] == 0)//problem here
        {
            //does something
        }
        else
        {
        if(FirstStart[playerid][pFirstStart] == 1)//problem here
        {
            //does something
        }
    }
    else if(gPlayerClass[playerid] == Blah2)
    {
        if(FirstStart[playerid][pFirstStart] == 0)//problem here
        {
            //does something
        }
        else
        {
        if(FirstStart[playerid][pFirstStart] == 1)//problem here
        {
            //does something
        }
    }
    return 1;
}
Errors that I get...
Код:
(769) : error 001: expected token: ")", but found "["
(769) : error 029: invalid expression, assumed zero
(769) : warning 215: expression has no effect
(769) : error 001: expected token: ";", but found "]"
(769) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Reply
#2

PHP код:
public OnPlayerSpawn(playerid)
{
    if(
gPlayerClass[playerid] == Blah1)
    {
        if(
FirstStart[playerid][pFirstStart] == 0)//problem here
        
{
            
//does something
        
}
        if(
FirstStart[playerid][pFirstStart] == 1)//problem here
        
{
            
//does something
        
}
    }
    else if(
gPlayerClass[playerid] == Blah2)
    {
        if(
FirstStart[playerid][pFirstStart] == 0)//problem here
        
{
            
//does something
        
}
        if(
FirstStart[playerid][pFirstStart] == 1)//problem here
        
{
            
//does something
        
}
    }
    return 
1;

or:

PHP код:
public OnPlayerSpawn(playerid)
{
    if(
gPlayerClass[playerid] == Blah1)
    {
        switch(
FirstStart[playerid][pFirstStart])
        {
            case 
0:
            {
                
//does something
            
}
            case 
1:
            {
                
//does something
            
}
        }
    }
    else if(
gPlayerClass[playerid] == Blah2)
    {
        switch(
FirstStart[playerid][pFirstStart])
        {
            case 
0:
            {
                
//does something
            
}
            case 
1:
            {
                
//does something
            
}
        }
    }
    return 
1;

Reply
#3

Oh I see,I dont need else :P thank you
Reply
#4

else
Reply
#5

Again thank you very much for helping me,this is also prob why my messages are not showing :P cause I got if's like there in other places :P
Reply
#6

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(gPlayerClass[playerid] == Blah1)
    {
        if(FirstStart[playerid][pFirstStart] == 0) //Line 797
        {
            //does something
        }
        if(FirstStart[playerid][pFirstStart] == 1)
        {
            //does something
        }
    }
    else if(gPlayerClass[playerid] == Blah2)
    {
        if(FirstStart[playerid][pFirstStart] == 0)
        {
            //does something
        }
        if(FirstStart[playerid][pFirstStart] == 1)
        {
            //does something
        }
    }
    return 1;
}
or:

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(gPlayerClass[playerid] == Blah1)
    {
        switch(FirstStart[playerid][pFirstStart]) //Same Error here as first code
        {
            case 0:
            {
                //does something
            }
            case 1:
            {
                //does something
            }
        }
    }
    else if(gPlayerClass[playerid] == Blah2)
    {
        switch(FirstStart[playerid][pFirstStart])
        {
            case 0:
            {
                //does something
            }
            case 1:
            {
                //does something
            }
        }
    }
    return 1;
}
I got these errors upon using this code
Код:
(797) : error 001: expected token: ")", but found "["
(797) : error 029: invalid expression, assumed zero
(797) : warning 215: expression has no effect
(797) : error 001: expected token: ";", but found "]"
(797) : fatal error 107: too many error messages on one line
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)