Setcolour for ALL players function.
#1

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.
Reply
#2

It is possible.

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

Can you give me a code example please ?

Thanks.
Reply
#4

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.
Reply
#5

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

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.
Reply
#7

The script I wrote works just fine for me
Reply
#8

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.
Reply
#9

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.
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)