SA-MP Forums Archive
Check if the player's color is white - 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: Check if the player's color is white (/showthread.php?tid=581125)



Check if the player's color is white - dionisak0s - 10.07.2015

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.



Re: Check if the player's color is white - zSuYaNw - 10.07.2015

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


Re: Check if the player's color is white - dominik523 - 10.07.2015

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?


Re: Check if the player's color is white - shadowdog - 10.07.2015

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



Re: Check if the player's color is white - dionisak0s - 10.07.2015

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.


Re: Check if the player's color is white - Vince - 10.07.2015

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.


Re: Check if the player's color is white - dionisak0s - 11.07.2015

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.