Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

[REQUEST] Rainbow man!

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
Diamond TH
Fighter
Fighter
Posts: 21
Joined: Fri Sep 14, 2018 10:44 am
Title: Fairplayer
SFD Account: Diamond_TH
SFD Alias: Diamond_TH
Started SFD: May 2015
Location: Russia
Gender:
Age: 20
Contact:

[REQUEST] Rainbow man!

Post by Diamond TH » Fri Nov 23, 2018 10:52 am

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/
0 x
Image - Noob SuperFighter saying

willofcapes lk
Meatbag
Posts: 5
Joined: Thu Nov 09, 2017 12:29 pm
SFD Account: willofcapes (lk)
Gender:

Post by willofcapes lk » Sat Nov 24, 2018 6:22 am

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.
0 x

User avatar
ebomb09
Fighter
Fighter
Posts: 13
Joined: Mon Apr 30, 2018 5:04 am
SFD Account: ebomb09
Location: Canada/BC
Age: 22

Post by ebomb09 » 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);
		}
	}
}
1 x

User avatar
Diamond TH
Fighter
Fighter
Posts: 21
Joined: Fri Sep 14, 2018 10:44 am
Title: Fairplayer
SFD Account: Diamond_TH
SFD Alias: Diamond_TH
Started SFD: May 2015
Location: Russia
Gender:
Age: 20
Contact:

Post by Diamond TH » Sun Nov 25, 2018 4:41 pm

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!
1 x
Image - Noob SuperFighter saying

Post Reply