Page 1 of 1
How to get PlayerModifier properties by using a button?
Posted: Wed Mar 20, 2019 5:15 am
by Jovani
Hello guys, may you make me a script that does the following:
When the player presses the button, he get PlayerModifier properties.
I will be grateful for the help :^)
Re: How to get PlayerModifier properties by using a button?
Posted: Wed Mar 20, 2019 8:08 pm
by ebomb09
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());
}
}
Re: How to get PlayerModifier properties by using a button?
Posted: Thu Mar 21, 2019 12:58 am
by Jovani
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