Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.73 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <cstrike>
  4. #include <sdkhooks>
  5.  
  6. int dead;
  7. int Ghost[MAXPLAYERS+1];
  8.  
  9. #define FFADE_IN 0x0002 // Fade in
  10. #define FFADE_MODULATE 0x0004 // Modulate
  11. public Plugin:myinfo =
  12. {
  13. name = "Ghost",
  14. author = "ONIONZZZ",
  15. description = "Play as a ghost and fly whilst dead",
  16. version = "2.2.2",
  17. url = "https://dominationservers.com"
  18. };
  19.  
  20. public OnPluginStart()
  21. {
  22. HookEvent("round_end", Event_RoundEnd, EventHookMode_Pre);
  23. HookEvent("round_start", Event_RoundStart, EventHookMode_Pre);
  24. HookEvent("player_spawn", Event_PlayerSpawn);
  25. HookEvent("player_death", Event_PlayerDeath);
  26. RegConsoleCmd("sm_ghost", Command_Ghost);
  27. AddNormalSoundHook(blockSound);
  28. }
  29.  
  30. public OnClientPutInServer(client)
  31. {
  32. SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
  33. SDKHook(client, SDKHook_TraceAttack, OnTakedamage);
  34. }
  35.  
  36. public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
  37. {
  38. dead = 0;
  39. }
  40.  
  41. public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  42. {
  43. dead = 1;
  44. }
  45.  
  46. public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  47. {
  48. int client = GetClientOfUserId(GetEventInt(event, "userid"));
  49. if(Ghost[client])
  50. {
  51. CreateTimer(0.5, fixSolids, client); // this overwrites noblock etc..
  52. Ghost[client] = 0;
  53. }
  54. }
  55.  
  56. public Action fixSolids(Handle timer, any client)
  57. {
  58. SetEntProp(client, Prop_Data, "m_CollisionGroup", 1);
  59. SetEntProp(client, Prop_Data, "m_nSolidType", 0);
  60. SetEntProp(client, Prop_Send, "m_usSolidFlags", 4);
  61. ScreenEffect(client, 0, 0, FFADE_IN | FFADE_MODULATE, 255, 255, 255, 255);
  62. }
  63.  
  64. public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
  65. {
  66. int client = GetClientOfUserId(GetEventInt(event, "userid"));
  67. PrintToChat(client, "{darkred}[{default}Ghost{darkred}] {default}{default}Type {darkred}!ghost {default}to move around, and hold {lime}E {default}to fly!");
  68. }
  69.  
  70. public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
  71. {
  72. if(GetEntProp(client, Prop_Send, "m_lifeState") == 1)
  73. {
  74. MoveType movetype = GetEntityMoveType(client);
  75. if((buttons & IN_USE))
  76. {
  77. if(movetype != MOVETYPE_NOCLIP)
  78. {
  79. SetEntityMoveType(client, MOVETYPE_NOCLIP);
  80. }
  81. }else{
  82. if(movetype != MOVETYPE_WALK)
  83. {
  84. SetEntityMoveType(client, MOVETYPE_WALK);
  85. }
  86. }
  87. buttons &= ~IN_USE;
  88. }
  89. return Plugin_Continue;
  90. }
  91.  
  92. public Action Command_Ghost(client, args)
  93. {
  94. if(dead)
  95. {
  96. if (!IsPlayerAlive(client))
  97. {
  98. if(GetClientTeam(client) > 1)
  99. {
  100. Ghost[client] = 1;
  101. CS_RespawnPlayer(client);
  102. int weaponIndex;
  103. for (new i = 0; i <= 3; i++)
  104. {
  105. if ((weaponIndex = GetPlayerWeaponSlot(client, i)) != -1)
  106. {
  107. RemovePlayerItem(client, weaponIndex);
  108. RemoveEdict(weaponIndex);
  109. }
  110. }
  111. GivePlayerItem(client, "weapon_knife");
  112. SetEntProp(client, Prop_Send, "m_lifeState", 1);
  113. ScreenEffect(client, 100, 1000000000, FFADE_IN | FFADE_MODULATE, 0, 0, 0, 150);
  114. PrintToChat(client, "{darkred}[{default}Ghost{darkred}] {default}{default}You are now {lime}Ghosted{default}.");
  115. }
  116. else
  117. {
  118. PrintToChat(client, "{darkred}[{default}Ghost{darkred}] {default}{default}You must be on a team to use this{default}.");
  119. }
  120. }
  121. else
  122. {
  123. PrintToChat(client, "{darkred}[{default}Ghost{darkred}] {default}{default}You must be dead to use this{default}.");
  124. }
  125. }
  126. else
  127. {
  128. PrintToChat(client, "{darkred}[{default}Ghost{darkred}] {default}{default}Please wait till next round{default}.");
  129. }
  130. return Plugin_Handled;
  131. }
  132. stock void ScreenEffect(int client, int duration, int hold_time, int flag, int red, int green, int blue, int alpha)
  133. {
  134. Handle hFade = INVALID_HANDLE;
  135.  
  136. if(client)
  137. {
  138. hFade = StartMessageOne("Fade", client);
  139. }
  140. else
  141. {
  142. hFade = StartMessageAll("Fade");
  143. }
  144.  
  145. if(hFade != INVALID_HANDLE)
  146. {
  147. if(GetUserMessageType() == UM_Protobuf)
  148. {
  149. int clr[4];
  150. clr[0]=red;
  151. clr[1]=green;
  152. clr[2]=blue;
  153. clr[3]=alpha;
  154. PbSetInt(hFade, "duration", duration);
  155. PbSetInt(hFade, "hold_time", hold_time);
  156. PbSetInt(hFade, "flags", flag);
  157. PbSetColor(hFade, "clr", clr);
  158. }
  159. EndMessage();
  160. }
  161. }
  162. public Action:OnWeaponCanUse(client, weapon)
  163. {
  164. if(GetEntProp(client, Prop_Send, "m_lifeState") == 1)
  165. {
  166. return Plugin_Handled;
  167. }
  168.  
  169. return Plugin_Continue;
  170. }
  171.  
  172. public Action OnTakedamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
  173. {
  174. if(GetEntProp(victim, Prop_Send, "m_lifeState") == 1)
  175. {
  176. return Plugin_Handled;
  177. }
  178.  
  179. return Plugin_Continue;
  180. }
  181.  
  182. public Action blockSound(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
  183. {
  184. if (IsValidClient(entity))
  185. {
  186. if(GetEntProp(entity, Prop_Send, "m_lifeState"))
  187. {
  188. return Plugin_Handled;
  189. }
  190. }
  191. return Plugin_Continue;
  192. }
  193.  
  194. stock bool:IsValidClient(client, bool:nobots = true)
  195. {
  196. if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
  197. {
  198. return false;
  199. }
  200. return IsClientInGame(client);
  201. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement