daily pastebin goal
66%
SHARE
TWEET

SFD Script

a guest May 30th, 2017 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const float RESPTIME = 1000f;
  2.  
  3. public class PlayerData{
  4.     public IPlayer Body = null;
  5.     public IUser User = null;
  6.     public PlayerTeam Team = PlayerTeam.Independent;
  7.     public float RespTime = 8000f;
  8.     public bool Dead = true;
  9.     public Vector2 Spawn = Start;
  10.     public PlayerData(IPlayer ply){
  11.         this.Body = ply;
  12.         this.User = ply.GetUser();
  13.         this.Team = ply.GetTeam();
  14.     }
  15. }
  16.  
  17. static Vector2 Start = Vector2.Zero;
  18.  
  19. List <PlayerData> DataList = new List<PlayerData>();
  20.  
  21. public void OnStartup(){
  22.     Start = ((IObject)Game.GetSingleObjectByCustomId("Start")).GetWorldPosition(); 
  23.  
  24.     IObjectTimerTrigger TimerHund = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
  25.     TimerHund.SetScriptMethod("RespawnCheck");
  26.     TimerHund.SetIntervalTime(100);
  27.     TimerHund.SetRepeatCount(0);
  28.     TimerHund.Trigger();
  29.  
  30.     foreach(IPlayer ply in Game.GetPlayers()){
  31.         DataList.Add(new PlayerData(ply));
  32.         ply.Remove();
  33.     }
  34. }
  35.  
  36. public void RespawnCheck(TriggerArgs args){
  37.     foreach(PlayerData data in DataList){
  38.         if (data.Dead && (data.RespTime < Game.TotalElapsedGameTime || Game.TotalElapsedGameTime < 1000f)){
  39.             Respawn(data);
  40.         }
  41.         if ((data.Body.IsRemoved || data.Body.IsDead)&& !data.Dead){
  42.             data.RespTime = Game.TotalElapsedGameTime + RESPTIME;
  43.             data.Dead = true;
  44.         }
  45.     }
  46. }
  47.  
  48. public void Respawn(PlayerData data){
  49.     IPlayer ply = Game.CreatePlayer(data.Spawn);
  50.     data.Dead = false;
  51.     if (data.Body != null) data.Body.Remove();
  52.    
  53.     ply.SetProfile(data.User.GetProfile());
  54.     ply.SetUser(data.User);
  55.     ply.SetTeam(data.Team);
  56.     data.Body = ply;
  57. }
  58.  
  59. public PlayerData GetData(IUser user){
  60.     foreach(PlayerData data in DataList){
  61.         if (user.UserId == data.User.UserId) return data;
  62.     }
  63.     return null;
  64. }
  65.  
  66. public void gameover(TriggerArgs args)
  67. {
  68. Game.SetGameOver("GREAT JOB! YOU WON!");
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top