Page 1 of 1

[REQUEST] Rainbow man!

Posted: Fri Nov 23, 2018 10:52 am
by Diamond TH
Hey dudes! So i want to make a script that changes player's clothing item color to rainbow's colors EVERY SECOND if player's name is DiamondTH. Something like this:
[ Hat's colors for example ]
First sec - Red.
Second sec - Orange.
Third second - Yellow.
ETC. And it repeats after hitting purple.
I know how to change clothing color for ONCE, but i don't understand how to make it change color evety sec and repeat :?: .
I will be grateful. So please help X/

Re: [REQUEST] Rainbow man!

Posted: Sat Nov 24, 2018 6:22 am
by willofcapes lk
Only problem with this request is I'm pretty sure the script API doesn't have a way to check player names.
Other then that this script would be pretty easy to accomplish if you had it choose a random player.

Re: [REQUEST] Rainbow man!

Posted: Sat Nov 24, 2018 8:58 am
by ebomb09
I think I understand what you wanted now?

Code: Select all

//This affects the rate of colour change
int TimeScale = 250;
//If you change your username you will need to change this
string player_name = "DiamondTH";

int col = 0;
string color_name = "Red";

public void OnStartup(){

	IObjectTimerTrigger Timer = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
	Timer.SetRepeatCount(0);
	Timer.SetIntervalTime(TimeScale);
	Timer.SetScriptMethod("Checker");
	Timer.Trigger();

}

public void Checker(TriggerArgs args){
	col ++;
	switch(col){
		case 1:
			color_name = "Orange";
		break;
		case 2:
			color_name = "Yellow";
		break;
		case 3:
			color_name = "Green";
		break;
		case 4:
			color_name = "Cyan";
		break;
		case 5:
			color_name = "Blue";
		break;
		case 6:
			color_name = "Red";
		break;
		case 7:
			color_name = "Purple";
			col = 0;
		break;
	}
	foreach(IPlayer ply in Game.GetPlayers()){
		if (ply.Name == player_name){
			IProfile profile = ply.GetProfile();
				//You can edit these lines with text 'profile.Head' to something like 'profile.ChestOver'
				if (profile.Head != null) { profile.Head.Color1 = "Clothing" + color_name; }		
				if (profile.Head != null) { profile.Head.Color2 = "Clothing" + color_name; }
				//This
			ply.SetProfile(profile);
		}
	}
}

Re: [REQUEST] Rainbow man!

Posted: Sun Nov 25, 2018 4:41 pm
by Diamond TH
ebomb09 wrote:
Sat Nov 24, 2018 8:58 am
I think I understand what you wanted now?

Code: Select all

//This affects the rate of colour change
int TimeScale = 250;
//If you change your username you will need to change this
string player_name = "DiamondTH";

int col = 0;
string color_name = "Red";

public void OnStartup(){

	IObjectTimerTrigger Timer = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
	Timer.SetRepeatCount(0);
	Timer.SetIntervalTime(TimeScale);
	Timer.SetScriptMethod("Checker");
	Timer.Trigger();

}

public void Checker(TriggerArgs args){
	col ++;
	switch(col){
		case 1:
			color_name = "Orange";
		break;
		case 2:
			color_name = "Yellow";
		break;
		case 3:
			color_name = "Green";
		break;
		case 4:
			color_name = "Cyan";
		break;
		case 5:
			color_name = "Blue";
		break;
		case 6:
			color_name = "Red";
		break;
		case 7:
			color_name = "Purple";
			col = 0;
		break;
	}
	foreach(IPlayer ply in Game.GetPlayers()){
		if (ply.Name == player_name){
			IProfile profile = ply.GetProfile();
				//You can edit these lines with text 'profile.Head' to something like 'profile.ChestOver'
				if (profile.Head != null) { profile.Head.Color1 = "Clothing" + color_name; }		
				if (profile.Head != null) { profile.Head.Color2 = "Clothing" + color_name; }
				//This
			ply.SetProfile(profile);
		}
	}
}
Exactly, just what i needed! Thank you so much dude, for the second time :D. Now i can understand how it works!