SA-MP Forums Archive
Help on SetColor - 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: Help on SetColor (/showthread.php?tid=387089)



Help on SetColor - Gamer_007 - 23.10.2012

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


Re: Help on SetColor - Babul - 23.10.2012

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


Re: Help on SetColor - Gamer_007 - 23.10.2012

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


Re: Help on SetColor - Dizzle - 23.10.2012

Код:
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); 
    }



Re: Help on SetColor - mincer - 23.10.2012

try using code under onplayerspawn


Re: Help on SetColor - Gamer_007 - 23.10.2012

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.


Re: Help on SetColor - Dizzle - 23.10.2012

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


Re: Help on SetColor - mincer - 23.10.2012

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


Re: Help on SetColor - Dizzle - 23.10.2012

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;
}



Re: Help on SetColor - Gamer_007 - 23.10.2012

mincer it worked