Advertisement
fakuivan

not legal?

Dec 24th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.45 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sourcemod>
  5. #include <sdktools>
  6. #include <events>
  7.  
  8. #define PLUGIN_VERSION "0.0"
  9.  
  10. public Plugin myinfo =
  11. {
  12.     name = "Spectator Kill Fix",
  13.     author = "fakuivan",
  14.     description = "Fixes an exploit related to projectiles not being kill on team switch",
  15.     version = PLUGIN_VERSION,
  16.     url = "https://forums.alliedmods.net/member.php?u=264797"
  17. };
  18.  
  19. public void OnPluginStart()
  20. {
  21.     //CreateConVar("sm__version", PLUGIN_VERSION, "Version of ", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  22.     HookEvent("player_team", Event_OnClientChangeTeam);
  23. }
  24.  
  25. char gs_prop_ents[][2][] =
  26. {
  27.     {"obj_sentrygun"        , "m_hBuilder"},
  28.     {"projectile_rocket"    , "m_hOwnerEntity"},
  29.     {"obj_dispenser"        , "m_hBuilder"},
  30.     {"obj_teleporter"       , "m_hBuilder"}
  31. };
  32.  
  33. public void Event_OnClientChangeTeam(Event h_event, const char[] s_name, bool b_dontBroadcast)
  34. {
  35.     char s_client_name[MAX_NAME_LENGTH];
  36.     int i_userid =      GetEventInt(h_event, "userid");
  37.     int i_team =        GetEventInt(h_event, "team");
  38.     int i_old_team =    GetEventInt(h_event, "oldteam");
  39.     bool b_disconnect = GetEventBool(h_event, "disconnect");
  40.     bool b_auto_team =  GetEventBool(h_event, "autoteam");
  41.     bool b_sielent =    GetEventBool(h_event, "silent");
  42.     GetEventString(h_event, "name", s_client_name, sizeof(s_client_name));
  43.    
  44.     if (b_disconnect || i_team == i_old_team)
  45.     {
  46.         return;
  47.     }
  48.    
  49.     CleanParented(GetClientOfUserId(i_userid), gs_prop_ents, sizeof(gs_prop_ents));
  50. }
  51.  
  52. void CleanParented(int i_client, char[][][] s_ent_prop_names, int i_entnum)
  53. {
  54.     int i_entity;
  55.     for (int i = 0; i < i_entnum; i++)
  56.     {
  57.         while ((i_entity = FindEntityByClassname(i_entity, s_ent_prop_names[i][0])) != INVALID_ENT_REFERENCE)
  58.         {
  59.             if (GetEntPropEnt(i_entity, Prop_Send, s_ent_prop_names[i][1]) == i_client)
  60.             {
  61.                 AcceptEntityInput(i_entity, "Kill");
  62.             }
  63.         }
  64.     }
  65. }
  66.  
  67. /*Errors:
  68. C:\Users\fakui\Seafile\Programming\sm_scripting\experiments\Spectator Kill Fix\spectator_kill_fix.sp    49  error 035   argument type mismatch (argument 2)
  69. C:\Users\fakui\Seafile\Programming\sm_scripting\experiments\Spectator Kill Fix\spectator_kill_fix.sp    49  error 017   undefined symbol "s_ent_prop_names"
  70. C:\Users\fakui\Seafile\Programming\sm_scripting\experiments\Spectator Kill Fix\spectator_kill_fix.sp    49  error 029   invalid expression, assumed zero
  71. C:\Users\fakui\Seafile\Programming\sm_scripting\experiments\Spectator Kill Fix\spectator_kill_fix.sp    49  fatal error 190 too many error messages on one line */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement