Advertisement
DeathChaos25

Untitled

Mar 22nd, 2015
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. #pragma semicolon 1
  2. #include <sourcemod>
  3. #include <sdktools>
  4.  
  5. #define NICK 0
  6. #define ROCHELLE 1
  7. #define COACH 2
  8. #define ELLIS 3
  9. #define BILL 4
  10. #define ZOEY 5
  11. #define FRANCIS 6
  12. #define LOUIS 7
  13.  
  14. static const String:MODEL_NICK[] = "models/survivors/survivor_gambler.mdl";
  15. static const String:MODEL_ROCHELLE[] = "models/survivors/survivor_producer.mdl";
  16. static const String:MODEL_COACH[] = "models/survivors/survivor_coach.mdl";
  17. static const String:MODEL_ELLIS[] = "models/survivors/survivor_mechanic.mdl";
  18. static const String:MODEL_BILL[] = "models/survivors/survivor_namvet.mdl";
  19. static const String:MODEL_ZOEY[] = "models/survivors/survivor_teenangst.mdl";
  20. static const String:MODEL_FRANCIS[] = "models/survivors/survivor_biker.mdl";
  21. static const String:MODEL_LOUIS[] = "models/survivors/survivor_manager.mdl";
  22.  
  23. public Plugin:myinfo =
  24. {
  25. name = "L4D2 Randomize Survivor on Server Join",
  26. author = "DeathChaos25",
  27. description = "Randomizes a Survivor's character whenever they first join the server",
  28. version = "1.0",
  29. url = "DUMMY"
  30. }
  31.  
  32. public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
  33. {
  34. decl String:s_GameFolder[32];
  35. GetGameFolderName(s_GameFolder, sizeof(s_GameFolder));
  36. if (!StrEqual(s_GameFolder, "left4dead2", false))
  37. {
  38. strcopy(error, err_max, "This plugin is for Left 4 Dead 2 Only!");
  39. return APLRes_Failure;
  40. }
  41. return APLRes_Success;
  42. }
  43.  
  44. public OnPluginStart()
  45. {
  46. RegAdminCmd("sm_randomize", AdminRandomizesPlayers, ADMFLAG_GENERIC, "Randomizes the character of all the survivors");
  47. HookEvent("player_team", PlayerTeam_Event);
  48. }
  49.  
  50. public OnMapStart()
  51. {
  52. CheckModelPreCache(MODEL_NICK);
  53. CheckModelPreCache(MODEL_ROCHELLE);
  54. CheckModelPreCache(MODEL_COACH);
  55. CheckModelPreCache(MODEL_ELLIS);
  56. CheckModelPreCache(MODEL_BILL);
  57. CheckModelPreCache(MODEL_ZOEY);
  58. CheckModelPreCache(MODEL_FRANCIS);
  59. CheckModelPreCache(MODEL_LOUIS);
  60. }
  61.  
  62. stock CheckModelPreCache(const String:Modelfile[])
  63. {
  64. if (!IsModelPrecached(Modelfile))
  65. {
  66. PrecacheModel(Modelfile, true);
  67. PrintToServer("Precaching Model:%s",Modelfile);
  68. }
  69. }
  70.  
  71. public PlayerTeam_Event(Handle:event, const String:name[], bool:dontBroadcast)
  72. {
  73. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  74. if (client < 0 || client > MAXPLAYERS)
  75. return;
  76.  
  77. new team = GetEventInt(event, "team");
  78. if (team == 2)
  79. {
  80. RandomizeSurvivor(client);
  81. }
  82. }
  83.  
  84. public Action:AdminRandomizesPlayers(client, args)
  85. {
  86. new maxplayers = GetMaxClients();
  87. for (new i = 1; i < maxplayers; i++)
  88. {
  89. if (IsClientInGame(i) && GetClientTeam(i) == 2)
  90. {
  91. RandomizeSurvivor(i);
  92. }
  93. }
  94. }
  95.  
  96. public RandomizeSurvivor(client)
  97. {
  98. new random = GetRandomInt(1,8);
  99.  
  100. switch(random)
  101. {
  102. case 1: NickUse(client);
  103. case 2: RochelleUse(client);
  104. case 3: CoachUse(client);
  105. case 4: EllisUse(client);
  106. case 5: BillUse(client);
  107. case 6: ZoeyUse(client);
  108. case 7: LouisUse(client);
  109. case 8: BikerUse(client);
  110. }
  111. }
  112. public Action:ZoeyUse(client)
  113. {
  114.  
  115. SetEntProp(client, Prop_Send, "m_survivorCharacter", NICK);
  116. SetEntityModel(client, MODEL_ZOEY);
  117. if (IsFakeClient(client))
  118. {
  119. SetClientInfo(client, "name", "Zoey");
  120. }
  121. }
  122.  
  123. public Action:NickUse(client)
  124. {
  125.  
  126. SetEntProp(client, Prop_Send, "m_survivorCharacter", NICK);
  127. SetEntityModel(client, MODEL_NICK);
  128. if (IsFakeClient(client))
  129. {
  130. SetClientInfo(client, "name", "Nick");
  131. }
  132. }
  133.  
  134. public Action:EllisUse(client)
  135. {
  136. SetEntProp(client, Prop_Send, "m_survivorCharacter", ELLIS);
  137. SetEntityModel(client, MODEL_ELLIS);
  138. if (IsFakeClient(client))
  139. {
  140. SetClientInfo(client, "name", "Ellis");
  141. }
  142. }
  143.  
  144. public Action:CoachUse(client)
  145. {
  146. SetEntProp(client, Prop_Send, "m_survivorCharacter", COACH);
  147. SetEntityModel(client, MODEL_COACH);
  148. if (IsFakeClient(client))
  149. {
  150. SetClientInfo(client, "name", "Coach");
  151. }
  152. }
  153.  
  154. public Action:RochelleUse(client)
  155. {
  156. SetEntProp(client, Prop_Send, "m_survivorCharacter", ROCHELLE);
  157. SetEntityModel(client, MODEL_ROCHELLE);
  158. if (IsFakeClient(client))
  159. {
  160. SetClientInfo(client, "name", "Rochelle");
  161. }
  162. }
  163.  
  164. public Action:BillUse(client)
  165. {
  166. SetEntProp(client, Prop_Send, "m_survivorCharacter", BILL);
  167. SetEntityModel(client, MODEL_BILL);
  168. if (IsFakeClient(client))
  169. {
  170. SetClientInfo(client, "name", "Bill");
  171. }
  172. }
  173.  
  174. public Action:BikerUse(client)
  175. {
  176. SetEntProp(client, Prop_Send, "m_survivorCharacter", FRANCIS);
  177. SetEntityModel(client, MODEL_FRANCIS);
  178. if (IsFakeClient(client))
  179. {
  180. SetClientInfo(client, "name", "Francis");
  181. }
  182. }
  183.  
  184. public Action:LouisUse(client)
  185. {
  186. SetEntProp(client, Prop_Send, "m_survivorCharacter", LOUIS);
  187. SetEntityModel(client, MODEL_LOUIS);
  188. if (IsFakeClient(client))
  189. {
  190. SetClientInfo(client, "name", "Louis");
  191. }
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement