Change Wanted Color -
15outland - 09.04.2013
Hi,
I am wondering how I can make it so when a player gets 1 star, their name automatically changes to yellow, and >= 4 is changed to Orange..
I do understand the concept of the code, and how to do it (I think :P) - But not sure where to position it, under what header and what not :S
Re: Change Wanted Color -
Faisal_khan - 09.04.2013
Under
OnPlayerUpdate,
get the players wanted level then
set the player's color.
Something like this:
pawn Код:
public OnPlayerUpdate(playerid)
{
if(GetPlayerWantedLevel(playerid) == 1)
{
SetPlayerColor(playerid, 0xFFFF00AA);
}
return 1;
}
Re: Change Wanted Color -
Jstylezzz - 09.04.2013
Set a timer to check the wanted level of a player.
pawn Код:
public MyTimer()
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(GetPlayerWantedLevel(i) == 1)
{
SetPlayerColor(...);
}
}
}
Sorry for the code indentaton, but it's hard to write good indented code in the reply field :P
The code above is just an example, but that's how I would handle this.
EDIT: You can also do this under OnPlayerUpdate, then you don't need to set a timer, and don't need to make a new public function.
Re: Change Wanted Color -
Faisal_khan - 09.04.2013
Quote:
Originally Posted by Jstylezzz
Set a timer to check the wanted level of a player.
pawn Код:
public MyTimer() { for(new i=0; i < MAX_PLAYERS; i++) { if(GetPlayerWantedLevel(i) == 1) { SetPlayerColor(...); } } }
Sorry for the code indentaton, but it's hard to write good indented code in the reply field :P
The code above is just an example, but that's how I would handle this.
EDIT: You can also do this under OnPlayerUpdate, then you don't need to set a timer, and don't need to make a new public function.
|
Using timers unnecessarily will help you in increasing the lag.
Re: Change Wanted Color -
Jstylezzz - 09.04.2013
Quote:
Originally Posted by Faisal_khan
Using timers unnecessarily will help you in increasing the lag.
|
A little while ago I asked this (because I thought timers cause lagg too), but ****** replied that timers are not that consuming. I didn't use OnPlayerUpdate in my other post, because it's called quite a few times per second, which causes lagg if you have a lot of stuff in there. But as I said in my other post, OnPlayerUpdate should be ok with small code like this.
Re: Change Wanted Color -
Faisal_khan - 09.04.2013
Quote:
Originally Posted by Jstylezzz
A little while ago I asked this (because I thought timers cause lagg too), but ****** replied that timers are not that consuming. I didn't use OnPlayerUpdate in my other post, because it's called quite a few times per second, which causes lagg if you have a lot of stuff in there. But as I said in my other post, OnPlayerUpdate should be ok with small code like this.
|
Damn! Never knew it! Anyway, thanks.
Re: Change Wanted Color -
Vince - 09.04.2013
Funny thing is, you don't even need timers since the wanted level is controlled entirely on the server's side. That means that you know at all times what its value is and when it changes (hook SetPlayerWantedLevel).
Re: Change Wanted Color -
15outland - 09.04.2013
Ok, thanks for all that, but I am just wondering..
since I have few classes with different colors, say mechanic is brown, then he goes yellow for crime, but wouldn't he go white instead of brown when cleared?
And since that would require a few 'if' commands, would that lag it more?
My OnPlayerUpdate, is pretty much empty, just a line or two in it
I tried using an if for all the civilians, but says error 075: input line too long (after substitutions), how do I fix this?
Since they are all in teams, like pimp = TEAM_PIMP, Chicken = TEAM_CHICKEN, is it possible to have a variable, where Civilians = Team_XX1, TEAM_XX2, TEAM_ etc etc ?
Re: Change Wanted Color -
15outland - 09.04.2013
I am using, seems to work
if(GetPlayerWantedLevel(playerid) == 0 && PlayerInfo[playerid][team] != TEAM_ARMY && PlayerInfo[playerid][team] != TEAM_SWAT && PlayerInfo[playerid][team] != TEAM_LVCOP && PlayerInfo[playerid][team] != TEAM_LVARMY && PlayerInfo[playerid][team] != TEAM_LVSWAT && PlayerInfo[playerid][team] != TEAM_LSCOP && PlayerInfo[playerid][team] !=TEAM_MEDIC && PlayerInfo[playerid][team] != TEAM_LVMEDIC && PlayerInfo[playerid][team] != TEAM_MECHANIC)
{
SetPlayerColor(playerid, COLOR_WHITE);
}
else if(GetPlayerWantedLevel(playerid) == 0 && PlayerInfo[playerid][team] == TEAM_MEDIC && PlayerInfo[playerid][team] == TEAM_LVMEDIC)
{
SetPlayerColor(playerid, COLOR_PINK);
}
else if(GetPlayerWantedLevel(playerid) == 0 && PlayerInfo[playerid][team] == TEAM_MECHANIC)
{
SetPlayerColor(playerid, COLOR_BROWN);
}
else if(GetPlayerWantedLevel(playerid) >= 1 && GetPlayerWantedLevel(playerid) <=3)// between 1 and less than 3 stars, name color changed to yellow
{
SetPlayerColor(playerid, COLOR_YELLOW);
}
else if (GetPlayerWantedLevel(playerid) >=4 )
{
SetPlayerColor(playerid,COLOR_ORANGE); // with 4 or more stars, name color changed to orange
}