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.
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
Forum rules
By using the forum you agree to the following rules.
By using the forum you agree to the following rules.
I need help, Script to increase the height of the jump
Is there any script to increase the jump height of all players on the map? Thank you in advance.
0 x
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
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 26
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
The script is really good, but how can I choose the height of the jump? Thanks in advance again.JakSparro98 wrote: ↑Wed Mar 06, 2019 12:37 pmI 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(); }
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 26
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
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.JakSparro98 wrote: ↑Wed Mar 06, 2019 12:37 pmI 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(); }
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 26
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