Help on SetColor
#1

Guys this is my code for when a player joins a server and if he is admin his colour sets atuo.but not working.Any help for this?No error in it

PHP код:
if(PlayerInfo[playerid][Level] == 6)
    {
    
SetPlayerColor(playerid,COLOR_BLUE);
    }
    if(
PlayerInfo[playerid][Level] == 5)
    {
    
SetPlayerColor(playerid,red);
    }
    if(
PlayerInfo[playerid][Level] == 4)
    {
    
SetPlayerColor(playerid,red);
    }
    if(
PlayerInfo[playerid][Level] == 3)
    {
    
SetPlayerColor(playerid,red);
    }
    if(
PlayerInfo[playerid][Level] == 2)
    {
    
SetPlayerColor(playerid,red);
    }
    if(
PlayerInfo[playerid][Level] == 1)
    {
    
SetPlayerColor(playerid,red);
    } 
I have a second code too
PHP код:
if(PlayerInfo[playerid][Level] <= )
    {
    
SetPlayerColor(playerid,red);
    }
    if(
PlayerInfo[playerid][Level] == 6)
    {
    
SetPlayerColor(playerid,COLOR_BLUE);
    } 
Idk if both works or both are wrong
Reply
#2

i suggest to outsource those snippets into a stock, then call it in OnPlayerSpawn(), not OnPlayerConnect().
maybe the player color gets set after the player connected (again)?
also i suggest you to use a color array, and use the wantedlevel as pointer into the arraycell, it takes 1 comparement then, not half a dozen if-checks
Reply
#3

any other help bcz i need to get it in expanded way babul.
Reply
#4

Код:
if(PlayerInfo[playerid][Level] >= 1 || <=5 )  // if its only <=5 it will set all players colour to red since the normal players are level 0
    { 
    SetPlayerColor(playerid,red); 
    } 
    if(PlayerInfo[playerid][Level] == 6) 
    { 
    SetPlayerColor(playerid,COLOR_BLUE); 
    }
Reply
#5

try using code under onplayerspawn
Reply
#6

Quote:
Originally Posted by Dizzle
Посмотреть сообщение
Код:
if(PlayerInfo[playerid][Level] >= 1 || <=5 )  // if its only <=5 it will set all players colour to red since the normal players are level 0
    { 
    SetPlayerColor(playerid,red); 
    } 
    if(PlayerInfo[playerid][Level] == 6) 
    { 
    SetPlayerColor(playerid,COLOR_BLUE); 
    }
Dizzle where to paste this code bcz i tried both in onplayerspawn and connect and it wont work.Btw and it gives me Invalid function or declaration error.
Reply
#7

Just a second, I will try to test it in my GM then I will edit my post If I succeed to fix it.
Reply
#8

pawn Код:
public OnPlayerSpawn(playerid)
{
    switch(PlayerInfo[playerid][Level])
    {
        case 1..5: SetPlayerColor(playerid,red);
        case 6: SetPlayerColor(playerid,COLOR_BLUE);
    }
    return 1;
}
try using that
Reply
#9

Here - tested & working.

Код:
if(AccInfo[playerid][Level] >= 1 || AccInfo[playerid][Level] <= 5 )
{
SetPlayerColor(playerid, red);
if(AccInfo[playerid][Level] == 6)
SetPlayerColor(playerid, COLOR_BLUE);
return 1;
}
Reply
#10

mincer it worked
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)