Check if the player's color is white
#1

I have a new system for my chat cmds, like /b, /s etc. and I don't want players to be confused, when a player's color is white I don't want it to colorize the name, if his name is colored his name will be colored in the chat.
I made something like this but it doesn't works.
Код:
if(GetPlayerColor(playerid) == 0) return did stuff here.
Reply
#2

pawn Код:
if(~GetPlayerColor(playerid))
Try this..
Reply
#3

It's not working maybe because of this (from the wiki):
GetPlayerColor will return nothing (0) unless SetPlayerColor has been used first.
Click HERE for a fix.

@zSuYaNw: Isn't that the same as !GetPlayerColor or GetPlayerColor == 0?
Reply
#4

GetPlayerColor returns 0 when the color is not set or the player is not connected.

I would highly recommend setting a variable for the player's color, but if you really want to get their color, approach like this:

PHP код:
if(GetPlayerColor(playerid) == 0xFFFFFFFF) return did stuff here
Reply
#5

I set the color already, everything works perfectly I just need a way to check if the player's color is white, I will check if the code above works.
Reply
#6

Just compare it with COLOR_WHITE? What is so hard about that? They're just numbers, after all.

Quote:
Originally Posted by dominik523
Посмотреть сообщение
@zSuYaNw: Isn't that the same as !GetPlayerColor or GetPlayerColor == 0?
The ~ operator is known as bitwise not, or the one's complement; it inverts all the bits. So when applied to decimal 0, which has 32 bits all set to 0, you get 32 bits set to 1. When converting that to decimal you get decimal -1 or hexadecimal 0xFFFFFFFF, which is coincidentally the color white. So basically that if-statement would return true for anything BUT the color white and is therefore equal to GetPlayerColor != -1.
Reply
#7

Quote:
Originally Posted by shadowdog
Посмотреть сообщение
GetPlayerColor returns 0 when the color is not set or the player is not connected.

I would highly recommend setting a variable for the player's color, but if you really want to get their color, approach like this:

PHP код:
if(GetPlayerColor(playerid) == 0xFFFFFFFF) return did stuff here
Alright, it works perfectly, reputation given.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)