This forum is going to be locked at the end of this year and eventually going offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Make sure to read the rules.

How to get PlayerModifier properties by using a button?

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
Jovani
Fighter
Fighter
Posts: 55
Joined: Sun Sep 18, 2016 2:49 am
Title: Heroe
SFD Account: Jovani
SFD Alias: Johnny
Started SFD: 2014
Location: Mexico
Gender:

How to get PlayerModifier properties by using a button?

Post by Jovani » Wed Mar 20, 2019 5:15 am

Hello guys, may you make me a script that does the following:
When the player presses the button, he get PlayerModifier properties.
Image

I will be grateful for the help :^)
0 x

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

Post by ebomb09 » Wed Mar 20, 2019 8:08 pm

You will need to set the button's script method to 'GiveMods' and set the string in the script 'ModifierCustomID' to your PlayerModifierInfo CustomID.

Code: Select all

public string ModifierCustomID = "YourModifierCustomID";

public void GiveMods(TriggerArgs args){
	if(args.Sender is IPlayer){
		IPlayer ply = args.Sender as IPlayer;
		IObjectPlayerModifierInfo mods = (IObjectPlayerModifierInfo)Game.GetSingleObjectByCustomID(ModifierCustomID);
		ply.SetModifiers(mods.GetModifiers());
	}
}
2 x

User avatar
Jovani
Fighter
Fighter
Posts: 55
Joined: Sun Sep 18, 2016 2:49 am
Title: Heroe
SFD Account: Jovani
SFD Alias: Johnny
Started SFD: 2014
Location: Mexico
Gender:

Post by Jovani » Thu Mar 21, 2019 12:58 am

ebomb09 wrote:
Wed Mar 20, 2019 8:08 pm
You will need to set the button's script method to 'GiveMods' and set the string in the script 'ModifierCustomID' to your PlayerModifierInfo CustomID.

Code: Select all

public string ModifierCustomID = "YourModifierCustomID";

public void GiveMods(TriggerArgs args){
	if(args.Sender is IPlayer){
		IPlayer ply = args.Sender as IPlayer;
		IObjectPlayerModifierInfo mods = (IObjectPlayerModifierInfo)Game.GetSingleObjectByCustomID(ModifierCustomID);
		ply.SetModifiers(mods.GetModifiers());
	}
}
Thanks for your help
0 x

Post Reply