SA-MP Forums Archive
stock problem - 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: stock problem (/showthread.php?tid=540290)



stock problem - Dangjai - 03.10.2014

I'm getting errors on this line.
pawn Код:
stock GetAdminName(playerid)
{
    new adminname[129];
    if ( PlayerInfo [ playerid ] [ Level ] > 0)
    {
        case 1: adminname = "Admininstrator";
        case 2: adminname = "General Admininstrator";
        case 3: adminname = "Senior Admininstrator";
        case 4: adminname = "Head Admininstrator";
        case 5: adminname = "Chief";
        case 6: adminname = "Server Owner";
    }
    return adminname;
}
pawn Код:
C:\Users\Dell\Desktop\Stunt Evolution v4\gamemodes\SEv4.pwn(3393) : error 014: invalid statement; not in switch
C:\Users\Dell\Desktop\Stunt Evolution v4\gamemodes\SEv4.pwn(3393) : warning 215: expression has no effect
C:\Users\Dell\Desktop\Stunt Evolution v4\gamemodes\SEv4.pwn(3393) : error 001: expected token: ";", but found ":"
C:\Users\Dell\Desktop\Stunt Evolution v4\gamemodes\SEv4.pwn(3393) : error 029: invalid expression, assumed zero
C:\Users\Dell\Desktop\Stunt Evolution v4\gamemodes\SEv4.pwn(3393) : fatal error 107: too many error messages on one line
Help please.


Re: stock problem - EnforcerDon - 03.10.2014

which line is it pointing to?


Re: stock problem - EnforcerDon - 03.10.2014

don't worry, I see where you went wrong. You can only use the "case:" thing inside of a "switch".

_________

If I've helped you, please rep++ to show your appreciation.


Re: stock problem - Dangjai - 03.10.2014

Quote:
Originally Posted by EnforcerDon
Посмотреть сообщение
don't worry, I see where you went wrong. You can only use the "case:" thing inside of a "switch".

_________

If I've helped you, please rep++ to show your appreciation.
Give me full code please.


Re: stock problem - IceCube! - 03.10.2014

Quote:
Originally Posted by Kinglee
Посмотреть сообщение
Give me full code please.
pawn Код:
stock GetAdminName(playerid)
{
    new adminname[129];
    switch(PlayerInfo [ playerid ] [ Level ])
    {
        case 0: return 1; // not an admin level.
        case 1: adminname = "Admininstrator";
        case 2: adminname = "General Admininstrator";
        case 3: adminname = "Senior Admininstrator";
        case 4: adminname = "Head Admininstrator";
        case 5: adminname = "Chief";
        case 6: adminname = "Server Owner";
    }
    return adminname;
}



Re: stock problem - EnforcerDon - 03.10.2014

pawn Код:
stock GetAdminName(playerid)
{
    new adminname[129];
    if ( PlayerInfo [ playerid ] [ Level ] > 0)
    {
        case 1: adminname = "Admininstrator";                // can't do this
        case 2: adminname = "General Admininstrator";
        case 3: adminname = "Senior Admininstrator";
        case 4: adminname = "Head Admininstrator";
        case 5: adminname = "Chief";
        case 6: adminname = "Server Owner";
    }
    return adminname;
}
You have to do this instead

pawn Код:
stock GetAdminName(playerid)
{
    new adminname[129];
    switch ( PlayerInfo [ playerid ] [ Level ] ) // change "if" to "switch
    {
        case 1: adminname = "Admininstrator";
        case 2: adminname = "General Admininstrator";
        case 3: adminname = "Senior Admininstrator";
        case 4: adminname = "Head Admininstrator";
        case 5: adminname = "Chief";
        case 6: adminname = "Server Owner";
        default: adminname = "None";        // if none of the above cases are executed, execute this case
    }
    return adminname;
}



Re: stock problem - Dangjai - 03.10.2014

Worked thanks!