CLass Selection
#1

i made this code if time >275 than player can change class..otherwise if time <275 set class for next spawn..but its not working plz see what i forgot in this code
PHP код:
case DIALOG_CLASS_1:
        {
        if(
response)
            {
                if(
time >= 275)
                    {
                    switch(
listitem)
                    {
                        case 
0: if(pInfo[playerid][pXP] >= 0pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = CIVILIAN,setClass(playerid); else { SendXPError(playerid,0); }
                          case 
1: if(pInfo[playerid][pXP] >= 500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = POLICEMAN,setClass(playerid); else { SendXPError(playerid,500); }
                        case 
2: if(pInfo[playerid][pXP] >= 1000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = MEDIC,setClass(playerid); else { SendXPError(playerid,1000); }
                        case 
3: if(pInfo[playerid][pXP] >= 1500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SCOUT,setClass(playerid); else { SendXPError(playerid,1500); }
                        case 
4: if(pInfo[playerid][pXP] >= 5000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = HEAVYMEDIC,setClass(playerid); else { SendXPError(playerid,5000); }
                        case 
5: if(pInfo[playerid][pXP] >= 6000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = FARMER,setClass(playerid); else { SendXPError(playerid,6000); }
                        case 
6: if(pInfo[playerid][pXP] >= 6500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SOLDIER,setClass(playerid); else { SendXPError(playerid,6500); }
                        case 
7: if(pInfo[playerid][pXP] >= 7500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = ENGINEER,setClass(playerid); else { SendXPError(playerid,7500); }
                        case 
8: if(pInfo[playerid][pXP] >= 15000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SWAT,setClass(playerid); else { SendXPError(playerid,15000); }
                        case 
9: if(pInfo[playerid][pXP] >= 20000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = HEAVYSHOTGUN,setClass(playerid); else { SendXPError(playerid,20000); }
                        case 
10: if(pInfo[playerid][pXP] >= 30000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = ADVANCEDENGINEER,setClass(playerid); else { SendXPError(playerid,30000); }
                           }
                    }
                          else if    (
pInfo[playerid][pXP] >= 0pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = CIVILIAN;
                          else if (
pInfo[playerid][pXP] >= 500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = POLICEMAN;
                        else if (
pInfo[playerid][pXP] >= 1000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = MEDIC;
                        else if (
pInfo[playerid][pXP] >= 1500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SCOUT;
                        else if (
pInfo[playerid][pXP] >= 5000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = HEAVYMEDIC;
                        else if (
pInfo[playerid][pXP] >= 6000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = FARMER;
                        else if (
pInfo[playerid][pXP] >= 6500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SOLDIER;
                        else if (
pInfo[playerid][pXP] >= 7500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = ENGINEER;
                        else if (
pInfo[playerid][pXP] >= 15000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SWAT;
                        else if (
pInfo[playerid][pXP] >= 20000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = HEAVYSHOTGUN;
                        else if (
pInfo[playerid][pXP] >= 30000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = ADVANCEDENGINEER;
                        else return 
SendClientMessage(playerid,-1,""chat""COL_RED" Class Set Will Change on Next Round");
                        }
                    } 
Reply
#2

Should use 4 space tabs, then you'd see a bit clearer.

As for the problem, I think it relates to your braces.


Re-formatted your code, same code, simply tabbed out correctly. Tabs, using 4 space. Avoid using spaces.

PHP код:
case DIALOG_CLASS_1
    { 
        if(
response
        { 
            if(
time >= 275
            { 
                switch(
listitem
                { 
                    case 
0: if(pInfo[playerid][pXP] >= 0pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = CIVILIAN,setClass(playerid); else { SendXPError(playerid,0); } 
                    case 
1: if(pInfo[playerid][pXP] >= 500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = POLICEMAN,setClass(playerid); else { SendXPError(playerid,500); } 
                    case 
2: if(pInfo[playerid][pXP] >= 1000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = MEDIC,setClass(playerid); else { SendXPError(playerid,1000); } 
                    case 
3: if(pInfo[playerid][pXP] >= 1500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SCOUT,setClass(playerid); else { SendXPError(playerid,1500); } 
                    case 
4: if(pInfo[playerid][pXP] >= 5000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = HEAVYMEDIC,setClass(playerid); else { SendXPError(playerid,5000); } 
                    case 
5: if(pInfo[playerid][pXP] >= 6000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = FARMER,setClass(playerid); else { SendXPError(playerid,6000); } 
                    case 
6: if(pInfo[playerid][pXP] >= 6500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SOLDIER,setClass(playerid); else { SendXPError(playerid,6500); } 
                    case 
7: if(pInfo[playerid][pXP] >= 7500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = ENGINEER,setClass(playerid); else { SendXPError(playerid,7500); } 
                    case 
8: if(pInfo[playerid][pXP] >= 15000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SWAT,setClass(playerid); else { SendXPError(playerid,15000); } 
                    case 
9: if(pInfo[playerid][pXP] >= 20000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = HEAVYSHOTGUN,setClass(playerid); else { SendXPError(playerid,20000); } 
                    case 
10: if(pInfo[playerid][pXP] >= 30000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = ADVANCEDENGINEER,setClass(playerid); else { SendXPError(playerid,30000); } 
                } 
            } 
            else if    (
pInfo[playerid][pXP] >= 0pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = CIVILIAN
            else if (
pInfo[playerid][pXP] >= 500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = POLICEMAN
            else if (
pInfo[playerid][pXP] >= 1000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = MEDIC
            else if (
pInfo[playerid][pXP] >= 1500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SCOUT
            else if (
pInfo[playerid][pXP] >= 5000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = HEAVYMEDIC
            else if (
pInfo[playerid][pXP] >= 6000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = FARMER
            else if (
pInfo[playerid][pXP] >= 6500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SOLDIER
            else if (
pInfo[playerid][pXP] >= 7500pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = ENGINEER
            else if (
pInfo[playerid][pXP] >= 15000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SWAT
            else if (
pInfo[playerid][pXP] >= 20000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = HEAVYSHOTGUN
            else if (
pInfo[playerid][pXP] >= 30000pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = ADVANCEDENGINEER
            else return 
SendClientMessage(playerid,-1,""chat""COL_RED" Class Set Will Change on Next Round"); 
        } 
    } 
Because of it being formatted nicely, now I can read it, and really, the problem is that in the first portion you check the time, and listitem. Second part, you don't.

You're not checking after 275, what item they even selected.

Need to be a bit more patient, and work on your structure.
Reply
#3

see this code
Quote:

case DIALOG_CLASS_1:
{
if(response)
{
if(time >= 275)
{
switch(listitem)
{
case 0: if(pInfo[playerid][pXP] >= 0) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = CIVILIAN,setClass(playerid);
else if(pInfo[playerid][pXP] >= 0) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = CIVILIAN;
else { SendXPError(playerid,0); }
case 1: if(pInfo[playerid][pXP] >= 500) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = POLICEMAN,setClass(playerid);
else if(time <= 275) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = POLICEMAN;
else { SendXPError(playerid,500); }
case 2: if(pInfo[playerid][pXP] >= 1000) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = MEDIC,setClass(playerid);
else if(time <= 275) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = MEDIC;
else { SendXPError(playerid,1000); }
case 3: if(pInfo[playerid][pXP] >= 1500) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SCOUT,setClass(playerid);
else if(time <= 275) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = SCOUT;
else { SendXPError(playerid,1500); }
case 4: if(pInfo[playerid][pXP] >= 5000) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = HEAVYMEDIC,setClass(playerid);
else if(time <= 275) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = HEAVYMEDIC;
else { SendXPError(playerid,5000); }
case 5: if(pInfo[playerid][pXP] >= 6000) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = FARMER,setClass(playerid);
else if(time <= 275) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = FARMER;
else { SendXPError(playerid,6000); }
case 6: if(pInfo[playerid][pXP] >= 6500) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SOLDIER,setClass(playerid);
else if(time <= 275) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = SOLDIER;
else { SendXPError(playerid,6500); }
case 7: if(pInfo[playerid][pXP] >= 7500) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = ENGINEER,setClass(playerid);
else if(time <= 275) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = ENGINEER;
else { SendXPError(playerid,7500); }
case 8: if(pInfo[playerid][pXP] >= 15000) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = SWAT,setClass(playerid);
else if(time <= 275) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = SWAT;
else { SendXPError(playerid,15000); }
case 9: if(pInfo[playerid][pXP] >= 20000) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = HEAVYSHOTGUN,setClass(playerid);
else if(time <= 275) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = HEAVYSHOTGUN;
else { SendXPError(playerid,20000); }
case 10: if(pInfo[playerid][pXP] >= 30000) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][SkinChanges] -= 0,pInfo[playerid][pHumanClass] = ADVANCEDENGINEER,setClass(playerid);
else if(time <= 275) pInfo[playerid][pHumanClass] = 0,pInfo[playerid][pHumanClass] = ADVANCEDENGINEER;
else { SendXPError(playerid,30000); }
}
}
else return SendClientMessage(playerid,-1,""chat""COL_RED" Class Set Will Change on Next Round");
}
}

Reply
#4

gah, my eyes...

Please, tab it out, 4 spaces, and edit your post.


(I think you'll need to restruture the way you are doing the checks)


Like, let them choose it, set it, and then decide whether it is time <275 and then set or deny in a seperate portion.
Reply
#5

sorry but i not understand..can u edit this
Reply
#6

If you are just learning to script, you should really work on structure before getting into actual code.
Reply
#7

i said before i m new..so i cant work on structure.else.i dont know what is structure in pawno..anyone edit my code.. i will learn so much from it...if anyone helps
Reply
#8

Formatting is where you've put up...

PHP код:
functionname
{
code
{
morecode
}

where it should be
PHP код:
functionname
{
    
code
    
{
        
morecode
    
}

Structure comes in the form of

PHP код:
functionname
{
    if 
structure
    
{
        if 
time is XXX
        
{
            if 
listitem is CC
            
{
                
code
            
}
        }
        
code that should be in another if statement here
        
else return code that won't be encountered under most circumstances
    }

PHP код:
functionname
{
    if 
structure
    
{
        if 
listitem is CC
        
{
            
code
        
}
        if 
time 275
        
{
            
SendMessage Skin changed
            SkinChange
            Putting a 
return here will end the checks.
        }
        if 
time 275
        
{
            
SendMessage Skin will change next round
            
return
        }
    }

Don't pin me for accuracy, but this is simply trying to explain what we're mentioning.
Reply
#9

thanks friend ... u nice teaching ,,and my problem solved +1 for u
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)