SA-MP Forums Archive
what's wrong? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: what's wrong? (/showthread.php?tid=275914)



what's wrong? - omer5198 - 11.08.2011

i got no errors and no warnings... but it doesn't work..: (i putted it on "OnPlayerSpawn" public)
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[playerid][AdminLevel] == 1)
        {
            admin[playerid] = Create3DTextLabel("Admin Level 1", COLOUR_RED, 30.0,40.0,50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
        }
        else if(PlayerInfo[playerid][AdminLevel] == 2)
        {
            admin[playerid] = Create3DTextLabel("Admin Level 2", COLOUR_GREEN, 30.0,40.0,50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
        }
        else if(PlayerInfo[playerid][AdminLevel] == 3)
        {
            admin[playerid] = Create3DTextLabel("Admin Level 3", COLOUR_GREEN, 30.0,40.0,50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
        }
        else if(PlayerInfo[playerid][AdminLevel] == 4)
        {
            admin[playerid] = Create3DTextLabel("Admin Level 4", COLOUR_GREEN, 30.0,40.0,50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
        }
        else if(PlayerInfo[playerid][AdminLevel] == 5)
        {
            admin[playerid] = Create3DTextLabel("Main Admin[Admin Level 5]", COLOUR_GREEN, 30.0,40.0,50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
        }
        else if(IsPlayerAdmin(playerid))
        {
            admin[playerid] = Create3DTextLabel("Owner[Admin Level 5]", COLOUR_GREEN, 30.0,40.0,50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
        }
        else continue;
    }



Re: what's wrong? - JaTochNietDan - 11.08.2011

From what I can tell you're never doing anything with the loop, so why do you have one in the first place? Also please use switch statements in a case like this, as it is much cleaner and more effecient, for example:

pawn Код:
switch(PlayerInfo[playerid][AdminLevel])
{
    case 1:
    {
        // Do something here for adminlevel 1
    }
    case 2:
    {
        // You get the point
    }
}
Regardless, your code doesn't make a lot of sense, what are you trying to achieve exactly?


Re: what's wrong? - Jeffry - 11.08.2011

Just:

pawn Код:
if(IsPlayerAdmin(playerid))
{
    admin[playerid] = Create3DTextLabel("Owner[Admin Level 5]", COLOUR_GREEN, 30.0,40.0,50.0, 40.0, 0);
    Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
}
else
{
    switch (PlayerInfo[playerid][AdminLevel])
    {
        case 1:
        {
            admin[playerid] = Create3DTextLabel("Admin Level 1", COLOUR_RED, 30.0,40.0,50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
        }
        case 2:
        {
            admin[playerid] = Create3DTextLabel("Admin Level 2", COLOUR_GREEN, 30.0,40.0,50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
        }
        case 3:
        {
            admin[playerid] = Create3DTextLabel("Admin Level 3", COLOUR_GREEN, 30.0,40.0,50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
        }
        case 4:
        {
            admin[playerid] = Create3DTextLabel("Admin Level 4", COLOUR_GREEN, 30.0,40.0,50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
        }
        case 5:
        {
            admin[playerid] = Create3DTextLabel("Main Admin[Admin Level 5]", COLOUR_GREEN, 30.0,40.0,50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(admin[playerid], playerid, 0.0, 0.0, 0.7);
        }
    }
}
at OnPlayerSpawn.