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.

I need help, Script to increase the height of the jump

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
Hamurlik
Fighter
Fighter
Posts: 49
Joined: Mon Aug 06, 2018 4:11 am

I need help, Script to increase the height of the jump

Post by Hamurlik » Wed Mar 06, 2019 2:46 am

Is there any script to increase the jump height of all players on the map? Thank you in advance.
0 x

User avatar
Pricey
Superfighter
Superfighter
Posts: 399
Joined: Thu May 05, 2016 9:29 pm
SFD Alias: (LM) Pricey
Started SFD: August 2015
Location: United Kingdom
Gender:
Age: 22

Post by Pricey » Wed Mar 06, 2019 8:47 am

Pretty sure there’s a modifier that increases jump height, just get all the players and apply the modifier to them.
0 x

Hamurlik
Fighter
Fighter
Posts: 49
Joined: Mon Aug 06, 2018 4:11 am

Post by Hamurlik » Wed Mar 06, 2019 12:19 pm

Pricey wrote:
Wed Mar 06, 2019 8:47 am
Pretty sure there’s a modifier that increases jump height, just get all the players and apply the modifier to them.
So, I do not see such a modifier, I did not find a separate one either, can I have the full name? since i don't see it.
https://imgur.com/a/DtRRrLM
0 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 26

Post by JakSparro98 » Wed Mar 06, 2019 12:37 pm

Pricey wrote:
Wed Mar 06, 2019 8:47 am
Pretty sure there’s a modifier that increases jump height, just get all the players and apply the modifier to them.
I think not, there is no modifier that can change jump height, it could be done with a script though.


@Hamurlik here is the script you requested, hope you like it.

Code: Select all

const float JUMP_FACTOR = 1.5f;
class Player {
 public static List < Player > PlayerList = new List < Player > ();
 IPlayer m_plr;
 int m_TotalJumps = 0;
 public Player(IPlayer plr) {
  m_plr = plr;
  PlayerList.Add(this);
 }
 public void CheckJump() {
  if (m_plr.Statistics.TotalJumps != m_TotalJumps) {
   m_TotalJumps = m_plr.Statistics.TotalJumps;
   Vector2 plrVel = m_plr.GetLinearVelocity();
   m_plr.SetLinearVelocity(new Vector2(plrVel.X, plrVel.Y * JUMP_FACTOR));
  }
 }
 public static bool FindPlayer(IPlayer plr) {
  foreach(Player pl in Player.PlayerList)
  if (pl.m_plr.UniqueID == plr.UniqueID)
   return true;
  return false;
 }
}
public void OnStartup() {
 Events.UpdateCallback.Start(OnUpdate, 0);
}
public void OnUpdate(float elapsed) {
 foreach(IPlayer plr in Game.GetPlayers()) {
  if (!Player.FindPlayer(plr)) {
   new Player(plr);
  }
 }
 foreach(Player plr in Player.PlayerList)
 plr.CheckJump();
}
1 x

Hamurlik
Fighter
Fighter
Posts: 49
Joined: Mon Aug 06, 2018 4:11 am

Post by Hamurlik » Wed Mar 06, 2019 12:47 pm

JakSparro98 wrote:
Wed Mar 06, 2019 12:37 pm
Pricey wrote:
Wed Mar 06, 2019 8:47 am
Pretty sure there’s a modifier that increases jump height, just get all the players and apply the modifier to them.
I think not, there is no modifier that can change jump height, it could be done with a script though.


@Hamurlik here is the script you requested, hope you like it.

Code: Select all

const float JUMP_FACTOR = 1.5f;
class Player {
 public static List < Player > PlayerList = new List < Player > ();
 IPlayer m_plr;
 int m_TotalJumps = 0;
 public Player(IPlayer plr) {
  m_plr = plr;
  PlayerList.Add(this);
 }
 public void CheckJump() {
  if (m_plr.Statistics.TotalJumps != m_TotalJumps) {
   m_TotalJumps = m_plr.Statistics.TotalJumps;
   Vector2 plrVel = m_plr.GetLinearVelocity();
   m_plr.SetLinearVelocity(new Vector2(plrVel.X, plrVel.Y * JUMP_FACTOR));
  }
 }
 public static bool FindPlayer(IPlayer plr) {
  foreach(Player pl in Player.PlayerList)
  if (pl.m_plr.UniqueID == plr.UniqueID)
   return true;
  return false;
 }
}
public void OnStartup() {
 Events.UpdateCallback.Start(OnUpdate, 0);
}
public void OnUpdate(float elapsed) {
 foreach(IPlayer plr in Game.GetPlayers()) {
  if (!Player.FindPlayer(plr)) {
   new Player(plr);
  }
 }
 foreach(Player plr in Player.PlayerList)
 plr.CheckJump();
}
The script is really good, but how can I choose the height of the jump? Thanks in advance again.
0 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 26

Post by JakSparro98 » Wed Mar 06, 2019 12:53 pm

Hamurlik wrote:
Wed Mar 06, 2019 12:47 pm
The script is really good, but how can I choose the height of the jump? Thanks in advance again.
You can change the value of the variable "JUMP_FACTOR" to any number if you want to use a float number remember to keep the "f" at the end of the number as you can already see in the script.
0 x

Hamurlik
Fighter
Fighter
Posts: 49
Joined: Mon Aug 06, 2018 4:11 am

Post by Hamurlik » Wed Mar 06, 2019 1:57 pm

JakSparro98 wrote:
Wed Mar 06, 2019 12:37 pm
Pricey wrote:
Wed Mar 06, 2019 8:47 am
Pretty sure there’s a modifier that increases jump height, just get all the players and apply the modifier to them.
I think not, there is no modifier that can change jump height, it could be done with a script though.


@Hamurlik here is the script you requested, hope you like it.

Code: Select all

const float JUMP_FACTOR = 1.5f;
class Player {
 public static List < Player > PlayerList = new List < Player > ();
 IPlayer m_plr;
 int m_TotalJumps = 0;
 public Player(IPlayer plr) {
  m_plr = plr;
  PlayerList.Add(this);
 }
 public void CheckJump() {
  if (m_plr.Statistics.TotalJumps != m_TotalJumps) {
   m_TotalJumps = m_plr.Statistics.TotalJumps;
   Vector2 plrVel = m_plr.GetLinearVelocity();
   m_plr.SetLinearVelocity(new Vector2(plrVel.X, plrVel.Y * JUMP_FACTOR));
  }
 }
 public static bool FindPlayer(IPlayer plr) {
  foreach(Player pl in Player.PlayerList)
  if (pl.m_plr.UniqueID == plr.UniqueID)
   return true;
  return false;
 }
}
public void OnStartup() {
 Events.UpdateCallback.Start(OnUpdate, 0);
}
public void OnUpdate(float elapsed) {
 foreach(IPlayer plr in Game.GetPlayers()) {
  if (!Player.FindPlayer(plr)) {
   new Player(plr);
  }
 }
 foreach(Player plr in Player.PlayerList)
 plr.CheckJump();
}
When I jump in the air the player becomes very fast, I need the player to just jump high in order to climb on the adages, and now he jumps very far, Can this be removed? Thank you in advance.
0 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 26

Post by JakSparro98 » Wed Mar 06, 2019 7:07 pm

Hamurlik wrote:
Wed Mar 06, 2019 1:57 pm
When I jump in the air the player becomes very fast, I need the player to just jump high in order to climb on the adages, and now he jumps very far, Can this be removed? Thank you in advance.
I changed it ,try now:

Code: Select all

const float JUMP_FACTOR = 1.5f;
class Player {
 public static List < Player > PlayerList = new List < Player > ();
 IPlayer m_plr;
 int m_TotalJumps = 0;
 public Player(IPlayer plr) {
  m_plr = plr;
  PlayerList.Add(this);
 }
 public void CheckJump() {
  if (m_plr.Statistics.TotalJumps != m_TotalJumps) {
   m_TotalJumps = m_plr.Statistics.TotalJumps;
   Vector2 plrVel = m_plr.GetLinearVelocity();
   m_plr.SetLinearVelocity(new Vector2(0, plrVel.Y * JUMP_FACTOR));
  }
 }
 public static bool FindPlayer(IPlayer plr) {
  foreach(Player pl in Player.PlayerList)
  if (pl.m_plr.UniqueID == plr.UniqueID)
   return true;
  return false;
 }
}
public void OnStartup() {
 Events.UpdateCallback.Start(OnUpdate, 0);
}
public void OnUpdate(float elapsed) {
 foreach(IPlayer plr in Game.GetPlayers()) {
  if (!Player.FindPlayer(plr)) {
   new Player(plr);
  }
 }
 foreach(Player plr in Player.PlayerList)
 plr.CheckJump();
}
0 x

Post Reply