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.

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: 22

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