New to the forum? Say hello in this topic! Make sure to read the rules.
RULE NR 3 UPDATED: Don't hurt, harass or provoke other forum members or people.

Script Requesting

Share questions and tutorials related to the ScriptAPI and give suggestions for new functions you want to see.
Forum rules
By using the forum you agree to the following rules.
Post Reply
CrazyDuck
Meatbag
Posts: 6
Joined: Thu Sep 15, 2016 7:42 am

Script Requesting

Post by CrazyDuck » Thu Oct 12, 2017 4:07 pm

I don't know how to write scripts at all , So I hope to have a player that good at scripting can help me write a small script
If someone could help me , i will be able to finish my map . thank you guys!
The Scripts i need will resurrect the player on the body 5 seconds after he dead, and remove dead bodies from Resurrection, and if the body disappears, he will not be resurrected. And the script is in the form of public void, because I want to use it on the map instead of using it independently
0 x

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

Post by JakSparro98 » Thu Oct 12, 2017 7:14 pm

CrazyDuck wrote:
Thu Oct 12, 2017 4:07 pm
I don't know how to write scripts at all , So I hope to have a player that good at scripting can help me write a small script
If someone could help me , i will be able to finish my map . thank you guys!
The Scripts i need will resurrect the player on the body 5 seconds after he dead, and remove dead bodies from Resurrection, and if the body disappears, he will not be resurrected. And the script is in the form of public void, because I want to use it on the map instead of using it independently
Before I can start the code I need to ask you if the player have to resurrect in the same position he died and if the script needs to start at game start.

Then I want to precise that "public void form" as you say doesn't automatically makes a script for a map or indipendent, in particular the public keyword allows to declare if the code needs to be visible on more "levels" that's why when you trigger some script from game objects we use public instead of leaving it blank or giving it private.
0 x

CrazyDuck
Meatbag
Posts: 6
Joined: Thu Sep 15, 2016 7:42 am

Post by CrazyDuck » Sat Oct 14, 2017 7:00 am

JakSparro98 wrote:
Thu Oct 12, 2017 7:14 pm
CrazyDuck wrote:
Thu Oct 12, 2017 4:07 pm
I don't know how to write scripts at all , So I hope to have a player that good at scripting can help me write a small script
If someone could help me , i will be able to finish my map . thank you guys!
The Scripts i need will resurrect the player on the body 5 seconds after he dead, and remove dead bodies from Resurrection, and if the body disappears, he will not be resurrected. And the script is in the form of public void, because I want to use it on the map instead of using it independently
Before I can start the code I need to ask you if the player have to resurrect in the same position he died and if the script needs to start at game start.

Then I want to precise that "public void form" as you say doesn't automatically makes a script for a map or indipendent, in particular the public keyword allows to declare if the code needs to be visible on more "levels" that's why when you trigger some script from game objects we use public instead of leaving it blank or giving it private.
Thank you for reply,
Yes, I need to make it work at the beginning of the game
I don't need it to work on more levels, but on a particular map
The place where I need players to resurrect is changeable, and where their bodies are moved, he'll be resurrected there unless his body is destoryed or removed
Thank you very much for helping me
:D
0 x

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

Post by JakSparro98 » Fri Oct 20, 2017 8:58 pm

CrazyDuck wrote:
Sat Oct 14, 2017 7:00 am
JakSparro98 wrote:
Thu Oct 12, 2017 7:14 pm
CrazyDuck wrote:
Thu Oct 12, 2017 4:07 pm
I don't know how to write scripts at all , So I hope to have a player that good at scripting can help me write a small script
If someone could help me , i will be able to finish my map . thank you guys!
The Scripts i need will resurrect the player on the body 5 seconds after he dead, and remove dead bodies from Resurrection, and if the body disappears, he will not be resurrected. And the script is in the form of public void, because I want to use it on the map instead of using it independently
Before I can start the code I need to ask you if the player have to resurrect in the same position he died and if the script needs to start at game start.

Then I want to precise that "public void form" as you say doesn't automatically makes a script for a map or indipendent, in particular the public keyword allows to declare if the code needs to be visible on more "levels" that's why when you trigger some script from game objects we use public instead of leaving it blank or giving it private.
Thank you for reply,
Yes, I need to make it work at the beginning of the game
I don't need it to work on more levels, but on a particular map
The place where I need players to resurrect is changeable, and where their bodies are moved, he'll be resurrected there unless his body is destoryed or removed
Thank you very much for helping me
:D
Sorry for the late answer, I was been busy all the week, here's what you requested:
Download template
You can move the spawnpoint by triggering ScriptTriggers as set as in the map example, the last triggered will be used next time a player die and his body is still present. When not even one is triggered, the default spawn will be at map origin (0,0).

Tell me if it's what you wanted, I'm at your disposal for any question.
Last edited by JakSparro98 on Sun Oct 22, 2017 12:02 pm, edited 1 time in total.
0 x

CrazyDuck
Meatbag
Posts: 6
Joined: Thu Sep 15, 2016 7:42 am

Post by CrazyDuck » Sun Oct 22, 2017 5:18 am

JakSparro98 wrote:
Fri Oct 20, 2017 8:58 pm
CrazyDuck wrote:
Sat Oct 14, 2017 7:00 am
JakSparro98 wrote:
Thu Oct 12, 2017 7:14 pm

Before I can start the code I need to ask you if the player have to resurrect in the same position he died and if the script needs to start at game start.

Then I want to precise that "public void form" as you say doesn't automatically makes a script for a map or indipendent, in particular the public keyword allows to declare if the code needs to be visible on more "levels" that's why when you trigger some script from game objects we use public instead of leaving it blank or giving it private.
Thank you for reply,
Yes, I need to make it work at the beginning of the game
I don't need it to work on more levels, but on a particular map
The place where I need players to resurrect is changeable, and where their bodies are moved, he'll be resurrected there unless his body is destoryed or removed
Thank you very much for helping me
:D
Sorry for the late answer, I was been busy all the week, here's what you requested:
Download template
You can move the spawnpoint by triggering ScriptTriggers as set as in the map example, the last triggered will be used next time a player die and his body is still present. When not even one is triggered, the default spawn will be at map origin (0,0).

Tell me if it's what you wanted, I'm at your disposal for any question.
Thank you! but, i can't open this download link...
maybe you can send the txt file to my email 798108753@qq.com
0 x

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

Post by JakSparro98 » Sun Oct 22, 2017 12:03 pm

CrazyDuck wrote:
Sun Oct 22, 2017 5:18 am
Thank you! but, i can't open this download link...
maybe you can send the txt file to my email 798108753@qq.com
I modified the link in the previous post, can you retry?
0 x

CrazyDuck
Meatbag
Posts: 6
Joined: Thu Sep 15, 2016 7:42 am

Post by CrazyDuck » Mon Oct 23, 2017 6:48 am

JakSparro98 wrote:
Sun Oct 22, 2017 12:03 pm
CrazyDuck wrote:
Sun Oct 22, 2017 5:18 am
Thank you! but, i can't open this download link...
maybe you can send the txt file to my email 798108753@qq.com
I modified the link in the previous post, can you retry?
Yes , thank you . But I think you not fully understand what I mean... Your script is similar to the checkpoint script, but what I need is to make fighters like zombies, where to die and where to rise :) Please help me revise it again , Thank You!
By the way , my map has been completed, and now it's just need the script to make it work. It will be a really fun and creative map!
0 x

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

Post by JakSparro98 » Mon Oct 23, 2017 10:39 am

CrazyDuck wrote:
Mon Oct 23, 2017 6:48 am
Yes , thank you . But I think you not fully understand what I mean... Your script is similar to the checkpoint script, but what I need is to make fighters like zombies, where to die and where to rise :) Please help me revise it again , Thank You!
By the way , my map has been completed, and now it's just need the script to make it work. It will be a really fun and creative map!
Never talked about reviving bots, I thought you needed it for players, and yes, this code is a variation of the checkpoint system.
Do you need only to revive bots or both players and bots?
1 x

CrazyDuck
Meatbag
Posts: 6
Joined: Thu Sep 15, 2016 7:42 am

Post by CrazyDuck » Tue Oct 24, 2017 8:03 am

JakSparro98 wrote:
Mon Oct 23, 2017 10:39 am
CrazyDuck wrote:
Mon Oct 23, 2017 6:48 am
Yes , thank you . But I think you not fully understand what I mean... Your script is similar to the checkpoint script, but what I need is to make fighters like zombies, where to die and where to rise :) Please help me revise it again , Thank You!
By the way , my map has been completed, and now it's just need the script to make it work. It will be a really fun and creative map!
Never talked about reviving bots, I thought you needed it for players, and yes, this code is a variation of the checkpoint system.
Do you need only to revive bots or both players and bots?


I'm talking about getting players to resurrect on their bodies, not checkpoints! Right on their dead bodys! It's in the dead place resurrection rather than teleport to the checkpoint! And when the body was destroyed, they would not revive, and that was the most important thing!
0 x

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

Post by JakSparro98 » Mon Oct 30, 2017 6:02 pm

CrazyDuck wrote:
Tue Oct 24, 2017 8:03 am
JakSparro98 wrote:
Mon Oct 23, 2017 10:39 am
CrazyDuck wrote:
Mon Oct 23, 2017 6:48 am
Yes , thank you . But I think you not fully understand what I mean... Your script is similar to the checkpoint script, but what I need is to make fighters like zombies, where to die and where to rise :) Please help me revise it again , Thank You!
By the way , my map has been completed, and now it's just need the script to make it work. It will be a really fun and creative map!
Never talked about reviving bots, I thought you needed it for players, and yes, this code is a variation of the checkpoint system.
Do you need only to revive bots or both players and bots?


I'm talking about getting players to resurrect on their bodies, not checkpoints! Right on their dead bodys! It's in the dead place resurrection rather than teleport to the checkpoint! And when the body was destroyed, they would not revive, and that was the most important thing!
Clear, here's the script, I hope it's what you're asking:

Code: Select all

const int RespawnSeconds = 5;
static List < DeadPlayer > DPlayersList = new List < DeadPlayer > ();
Events.PlayerDeathCallback m_playerDeathEvent = null;
Events.UpdateCallback m_updateEvent = null;
class DeadPlayer {
 IProfile P_profile;
 public IUser P_user;
 public IPlayer P_body;
 public float P_DeathTime = 0f;
 PlayerTeam P_team;
 public DeadPlayer(IPlayer player) {
  P_profile = player.GetProfile();
  P_user = player.GetUser();
  P_DeathTime = Game.TotalElapsedGameTime;
  P_body = player;
  P_team = player.GetTeam();
 }
 public void Respawn() {
  IPlayer pl = Game.CreatePlayer(P_body.GetWorldPosition());
  pl.SetUser(this.P_user);
  pl.SetProfile(this.P_profile);
  pl.SetTeam(this.P_team);
  this.P_body.Remove();
  DPlayersList.Remove(this);
 }
}
public void OnStartup() {
 m_playerDeathEvent = Events.PlayerDeathCallback.Start(OnPlayerDeath);
 m_updateEvent = Events.UpdateCallback.Start(OnUpdate, 0);
}
public void OnPlayerDeath(IPlayer player) {
 if (!player.IsBot && !player.IsRemoved && DPlayersList.FirstOrDefault(s => s.P_user.UserID == player.GetUser().UserID) == null) {
  DeadPlayer pl = new DeadPlayer(player);
  DPlayersList.Add(pl);
 }
}
public void OnUpdate(float elapsed) {
 for (int i = 0; i < DPlayersList.Count; i++)
  if (IsElapsed(DPlayersList[i].P_DeathTime, RespawnSeconds * 1000) && !DPlayersList[i].P_body.IsRemoved)
   DPlayersList[i].Respawn();
}
public static bool IsElapsed(float TimeStarted, float TimeToElapse) {
 if ((float)(Game.TotalElapsedGameTime - TimeStarted) >= TimeToElapse)
  return true;
 else
  return false;
}
0 x

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest