nomy

Untitled

Oct 8th, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <sdktools>
  5. #include <cstrike>
  6.  
  7. #define PLUGIN_VERSION "1.0"
  8.  
  9. new Handle:sm_ar_enable = INVALID_HANDLE;
  10. new Handle:ar_respawn_delay = INVALID_HANDLE;
  11. new Handle:ar_respawn_msgs = INVALID_HANDLE;
  12. new Handle:ar_dissolve_ragdolls = INVALID_HANDLE;
  13.  
  14. public Plugin:myinfo =
  15. {
  16.     name = "Respawn Fix for CSS:DM",
  17.     author = "somebettername",
  18.     description = "Respawns Bots cause of CSS:DM Respawn Problems",
  19.     version = PLUGIN_VERSION,
  20.     url = "somebetterhost.com"
  21. }
  22.  
  23. public OnPluginStart()
  24. {
  25.     CreateConVar("sm_ar_version", PLUGIN_VERSION, "Defines the version of AutoRespawn installed on this server", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  26.     sm_ar_enable = CreateConVar("sm_ar_enable", "1", "Enables/disables AutoRespawn on this server at any given time", FCVAR_PLUGIN|FCVAR_REPLICATED|FCVAR_NOTIFY);
  27.     ar_respawn_delay = CreateConVar("ar_respawn_delay", "1.2", "Amount of time (in seconds) after players die before they are automatically respawned");
  28.     ar_respawn_msgs = CreateConVar("ar_respawn_msgs", "0", "Enables/disables notification messages to players after they die that they will be respawned");
  29.     ar_dissolve_ragdolls = CreateConVar("ar_dissolve_ragdolls", "1", "Enables/disables the dissolving of a player's ragdoll following a successful respawn");
  30.  
  31.     HookEvent("player_team", Event_Spawn);
  32.     HookEvent("player_death", Event_Death);
  33. }
  34.  
  35. public OnPluginEnd()
  36. {
  37.     UnhookEvent("player_class", Event_Spawn);
  38.     UnhookEvent("player_death", Event_Death);
  39. }
  40.  
  41. public Event_Spawn( Handle:Spawn_Event, const String:Death_Name[], bool:Death_Broadcast )
  42. {
  43.     if( GetConVarBool(sm_ar_enable) )
  44.     {
  45.         new client = GetClientOfUserId( GetEventInt(Spawn_Event,"userid") );
  46.         new team = GetEventInt(Spawn_Event, "team");
  47.  
  48.         if( client != 0 && team > 1 )
  49.         {
  50.             new Float:respawndelaytime = GetConVarFloat(ar_respawn_delay);
  51.             CreateTimer(respawndelaytime, RespawnClient, any:client);
  52.            
  53.             if( GetConVarBool(ar_respawn_msgs) )
  54.             {
  55.                 new respawndelaytimeint = GetConVarInt(ar_respawn_delay);
  56.                 PrintToChat(client, "\x01\x04[AutoRespawn] \x01You will spawn in approximately %d seconds...", respawndelaytimeint);
  57.             }
  58.         }
  59.     }
  60. }
  61.  
  62. public Event_Death( Handle:Death_Event, const String:Death_Name[], bool:Death_Broadcast )
  63. {
  64.     if( GetConVarBool(sm_ar_enable) )
  65.     {
  66.         new client = GetClientOfUserId( GetEventInt(Death_Event,"userid") );
  67.  
  68.         if ( client != 0 )
  69.         {
  70.             new Float:respawndelaytime = GetConVarFloat(ar_respawn_delay);
  71.             CreateTimer(respawndelaytime, RespawnClient, any:client);
  72.            
  73.             if( GetConVarBool(ar_respawn_msgs) )
  74.             {
  75.                 new respawndelaytimeint = GetConVarInt(ar_respawn_delay);
  76.                 PrintToChat(client, "\x01\x04[AutoRespawn] \x01You will respawn in approximately %d seconds...", respawndelaytimeint);
  77.             }
  78.         }
  79.     }
  80. }
  81.  
  82. public Action:RespawnClient( Handle:timer, any:client )
  83. {
  84.     if( GetConVarBool(sm_ar_enable) )
  85.     {
  86.         if ( IsValidEntity(client) && IsClientInGame(client) && IsClientObserver(client) && !IsPlayerAlive(client) )
  87.         {
  88.             if ( GetConVarBool(ar_dissolve_ragdolls) )
  89.             {
  90.                 new ragdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
  91.                 if ( ragdoll > 0 )
  92.                 {
  93.                     new ent = CreateEntityByName("env_entity_dissolver");
  94.                     if ( ent > 0 )
  95.                     {
  96.                         new String:dissolvename[32];
  97.                         Format(dissolvename, sizeof(dissolvename), "dis_%d", client);
  98.                         DispatchKeyValue(ragdoll, "targetname", dissolvename);
  99.                         DispatchKeyValue(ent, "dissolvetype", "0");
  100.                         DispatchKeyValue(ent, "target", dissolvename);
  101.                         AcceptEntityInput(ent, "Dissolve");
  102.                         AcceptEntityInput(ent, "kill");
  103.                     }
  104.                 }
  105.             }
  106.            
  107.             CS_RespawnPlayer(client);
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment