SA-MP Forums Archive
Setcolour for ALL players function. - 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: Setcolour for ALL players function. (/showthread.php?tid=603467)



Setcolour for ALL players function. - Harty - 23.03.2016

I want to make a cmd that temporary save all players name colors, then all players name colors on the list (TAB) believe orange for ALL players connected, and after that, all colors believe as saved before.

Is that possible?

Thanks & Regards.


Re: Setcolour for ALL players function. - Sew_Sumi - 23.03.2016

It is possible.

Using GetPlayerColor you can store them to an array, and then set them back once the orange-need is over.


Re: Setcolour for ALL players function. - Harty - 23.03.2016

Can you give me a code example please ?

Thanks.


Re: Setcolour for ALL players function. - Golden96 - 23.03.2016

You'll need to have a variable to hold the colors and then run a loop via your command to set them all.

I.E;
PHP код:
CMD:toorange(playeridparams[]) {
    for(new 
0iMAX_PLAYERSi++) {
        if(
IsPlayerConnected(i)) {
            
SetPVarInt(i"color"GetPlayerColor(i));
            
SetPlayerColor(i0xD1773BFF); // orange
        
}
    }
    return 
1;
}
CMD:returncolors(playeridparams[]) {
    for(new 
0MAX_PLAYERSi++) {
        if(
IsPlayerConnected(i)) {
            
SetPlayerColor(iGetPVarInt(i"color"));
        }
    }
    return 
1;

This will be different depending on what you use to create commands obviously.
The reason I use SetPVarInt is so that if the player disconnects and another joins, it won't give the new player the old player's color. It's a lot easier.


Re: Setcolour for ALL players function. - Harty - 23.03.2016

It doesn't work, it set for all players the orange color, but the second command don't back the saved one.


Re: Setcolour for ALL players function. - Sew_Sumi - 23.03.2016

This is not the place to ask for "examples", because this is Scripting Help, not Script for you.

The usual reason why the GetPlayerColor sets to black, is because the Color hasn't been set prior.


A good point is that he's using an Integer, where he should almost be using a string as it's a hex code that gets retrieved, and needs to be handed back to the script as a string so it can read it.

Try using SetPVarString and GetPVarString.


Re: Setcolour for ALL players function. - Golden96 - 23.03.2016

The script I wrote works just fine for me


Re: Setcolour for ALL players function. - Sew_Sumi - 23.03.2016

Quote:
Originally Posted by Golden96
Посмотреть сообщение
The script I wrote works just fine for me
Then it's because of the fact that in his script, it doesn't have SetPlayerColor used...


In all honesty though, you need to read the rules about scripting help. Pasting up code, ISN'T helping, as next time something needs to be done, they'll just post up threads expecting people to hand out examples rather than actually learning to script.


Re: Setcolour for ALL players function. - Golden96 - 23.03.2016

I'm just showing him how easy it was. It's just a loop and storing variables, it's not like I wrote a whole script for him. I doubt he's just going to use those simple commands and if he is it's pretty silly since anyone can use those commands and just set everyone's colors all the time.


Re: Setcolour for ALL players function. - Sew_Sumi - 24.03.2016

Asks if it's possible, code gets supplied... Yea..........