Wanted level help -
KinderClans - 05.08.2018
So, i just setup a function to not exceed 6 stars wanted level (Gta Sa default):
pawn Код:
#define SetPlayerWantedLevelEx(%0,%1) SetPlayerWantedLevel(%0, clamp(%1, 0, 6))
Now i have a problem with colors, i can't assign them to the right wanted level:
pawn Код:
stock SetPlayerWantedLevelColor(playerid)
{
new wantedlevel;
wantedlevel = GetPlayerWantedLevel(playerid);
switch(wantedlevel)
{
case 0: SetPlayerColor(playerid, -1);
case 1, 2: SetPlayerColor(playerid, COLOR_YELLOW);
case 3: SetPlayerColor(playerid, COLOR_ORANGE);
case 4: SetPlayerColor(playerid, COLOR_ORANGE);
case 5, 6: SetPlayerColor(playerid, COLOR_RED);
}
return 1;
}
Doesn't work, doesn't matter if im level 1 or 6, i'll still have the default Sa-Mp color. What's wrong?
Re: Wanted level help -
DBZdabIt3Bro7 - 05.08.2018
Are you checking yourself on the scoreboard list with no one else online?
If so, that's why. The color is only visible to yourself when you've clicked on someone else's name in the scoreboard. You can check your own color by writing a quick debug command:
PHP код:
cmd:mycolor(playerid) {
new color = GetPlayerColor(playerid);
SendClientMessage(playerid, (color == 0)?(-1):(color), (color == 0)?("Your color hasn't changed since you first logged on!"):("This message is in the color of your name tag!"));
return 1;
}
Re: Wanted level help -
KinderClans - 05.08.2018
Im checking by writing in chat after the wanted level has changed. Still the default Sa-Mp color.
Re: Wanted level help -
DBZdabIt3Bro7 - 05.08.2018
Quote:
Originally Posted by KinderClans
Im checking by writing in chat after the wanted level has changed. Still the default Sa-Mp color.
|
Did you try my debug command? If you didn't, show me your OnPlayerText callback.
Re: Wanted level help -
KinderClans - 05.08.2018
Yes i did:
I'm level 6 wanted, so i should be color red, but as u can see, i'm not.
I don't know if can help, but i haven't placed that stock anywhere. Should i move it in a timer? (I have a 1 sec timer which checks all server/player funcs).
EDIT 2: Removed the stock and placed that code inside 1 second timer, it works. But i don't know if is the correct method. Would cause lag?
Re: Wanted level help -
DBZdabIt3Bro7 - 05.08.2018
PHP код:
#define SetPlayerWantedLevelEx(%0,%1) \
SetPlayerWantedLevel(%0, clamp(%1, 0, 6)),\
SetPlayerWantedLevelColor(%0)
Re: Wanted level help -
KinderClans - 05.08.2018
For a strange reason doesn't work. I mean, i have a command to test it:
pawn Код:
CMD:test(playerid)
{
SetPlayerWantedLevelEx(playerid, GetPlayerWantedLevel(playerid)+1);
SendClientMessage(playerid, COLOR_RED, "Wanted level increased by 1.");
new buf[128];
format(buf, sizeof(buf), "Wanted level: %d - %s", GetPlayerWantedLevel(playerid), WantedLevelName(playerid));
SendClientMessage(playerid, -1, buf);
return 1;
}
Command doesn't get executed.
Before editing that define the command worked. So should be something wrong with your code..
Re: Wanted level help -
taktaz - 06.08.2018
add this under OnPlayerUpdate function (or mb an all-time-repeating timer that involve all players)
PHP код:
if(GetPVarInt(playerid,"coloredWanted") != GetPlayerWantedLevel(playerid))
{
SetPlayerWantedLevelColor(playerid);
SetPVarInt(playerid,"coloredWanted",GetPlayerWantedLevel(playerid));
}
* also remove the 'stock' before SetPlayerWantedLevelColor in 'stock SetPlayerWantedLevelColor...' Because stock dont show warnings.
* also dont forget rep :P