Guest User

Holdfast SDK leaning code for Jacob

a guest
May 15th, 2022
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1.  
  2.  
  3. public static class HealthBuffer
  4. {
  5. public static int slapAmount = -50; //default value
  6.  
  7. //ID's that we care about. By default just ID "6", will want to make this changable by config.
  8. public static List<int> spawnSectionsForSlap = new List<int>(){6};
  9.  
  10.  
  11. //call this from your IHoldfastSharedMethods implementation
  12. public static void OnPlayerSpawned(int playerId, int spawnSectionId, FactionCountry playerFaction, PlayerClass playerClass, int uniformId, GameObject playerObject)
  13. {
  14. //is the spawn section one we care about?
  15. if (!spawnSectionForSlap.Contains(spawnSectionId)){return;}
  16.  
  17. //player spawned on the ID, so lets slap them.
  18. ConsoleController.SlapPlayer(playerId,slapAmount);
  19. }
  20.  
  21. //method for you to write
  22. //normally use "Wrex notation" for mod variables these will be of the form:
  23. // MOD_ID:MOD_VARIABLE:NEW_VALUE
  24.  
  25. //eg: 2666645553:slapAmount:-100
  26. //would change "slapAmount" to -100
  27.  
  28. //eg: 2666645553:spawnSectionsForSlap:6,7,8,10,12
  29. //would change "spawnSectionsForSlap" to be the list [6,7,8,10,12]
  30.  
  31. public static void PassConfigVariables(string[] value)
  32. {
  33. string modID = "2531692643";
  34. for (int i = 0; i < value.Length; i++)
  35. {
  36. string[] splitData = value[i].Split(':');
  37. if (splitData.Length != 3)
  38. {
  39. Debug.LogError("invalid number of variables");
  40. continue;
  41. }
  42. if (splitData[0] != modID) { continue; }
  43.  
  44.  
  45. //your code goes here to change the variable's value.
  46.  
  47. //splitData[1] is the "variable name"
  48. //splitData[2] is the "new value"
  49. //consider how you can determine + change the variable from this
  50. }
  51. }
  52.  
  53.  
  54. }
  55.  
  56. public static clas ConsoleController
  57. {
  58. //this is a reference to the "Console" panel where commands will be input to.
  59. private static InputField f1menu;
  60.  
  61. //Call this when OnServer is ran.
  62. public static void GetConsole()
  63. {
  64. //Assign f1menu using code from Wrex's line former
  65. //https://github.com/CM2Walki/HoldfastMods/blob/master/LineFormer/LineFormer.cs
  66.  
  67. }
  68.  
  69. //holdfast only allows int to be used for slap.
  70. public static SlapPlayer(int playerID, int damage)
  71. {
  72. //maybe need some validation incase f1 is null?
  73.  
  74. //dont need "rc" since this will run server side.
  75. f1menu.onEndEdit.Invoke($"serverAdmin slap {playerID} {damage}");
  76. }
  77. }
  78.  
Advertisement
Add Comment
Please, Sign In to add comment