Guest User

New Syntax Fixed!!!

a guest
Jun 9th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.12 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. ConVar Enabled;
  6.  
  7. public Plugin myinfo =  {
  8.     name = "Nade_Kick",
  9.     author = "AgentWesker",
  10.     description = "Player might get his weapon jammed while shooting and he has to reload.",
  11.     version = "0.0.1",
  12.     url = "http://steam-gamers.net"
  13. };
  14.  
  15. public void OnPluginStart()
  16. {
  17.     //Enabled / Disabled convar
  18.     Enabled = CreateConVar("sm_nadekick_enabled", "1", "Enable/Disable the plugin. Enable = 1.", _, true, 0.0, true, 1.0);
  19.    
  20.     HookEvent("player_hurt", Event_HandleNadeDamage); //You forgot to make the event hook for player_hurt
  21.    
  22.     //Execute the config and create if not yet made
  23.     AutoExecConfig(true, "nade_kick");
  24. }
  25.  
  26. public void OnEntityCreated(int entity, const char[] classname)
  27. {
  28.     //Hook the entity
  29.     SDKHook(entity, SDKHook_SpawnPost, OnEntitySpawned);
  30. }
  31.  
  32. public void OnEntitySpawned(int entity)
  33. {
  34.     //Is the plugin enabled? Otherwise dont continue
  35.     if (!GetConVarBool(Enabled))
  36.     {
  37.         return;
  38.     }
  39.    
  40.     char class_name[32];
  41.     GetEdictClassname(entity, class_name, 32);
  42.     int owner = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity"); //The client
  43.    
  44.     //Is the entity a projectile? This ignores weapon spawns
  45.     if (StrContains(class_name, "projectile", false) != -1 && IsValidEntity(entity))
  46.     {
  47.         //Is the projectile an hegrenade?
  48.         if (StrContains(class_name, "hegrenade") != -1)
  49.         {
  50.            
  51.             //Get the clients angles and position
  52.             float pEyePosition[3], pEyeAngle[3];
  53.             GetClientEyePosition(owner, pEyePosition);
  54.             GetClientEyeAngles(owner, pEyeAngle);
  55.            
  56.             //To be completed, put these in a hash using client as key
  57.            
  58.             //Print to chat for debugging purposes
  59.             PrintToChatAll("[SM]%N: My horizontal position is %f %f", owner, pEyePosition[0], pEyePosition[1]);
  60.             PrintToChatAll("[SM]%N: My horizontal angles are %f %f", owner, pEyeAngle[0], pEyeAngle[1]);
  61.         }
  62.     }
  63. }
  64.  
  65. public void Event_HandleNadeDamage(Event event, const char[] name, bool dontBroadcast) {
  66.    
  67.     //Get client of attacker and victim
  68.     /*int victimId = GetEventInt(event, "userid")
  69.     int attackerId = GetEventInt(event, "attacker")
  70.    
  71.     int victim = GetClientOfUserId(victimId);
  72.     int attacker = GetClientOfUserId(attackerId);*/
  73.    
  74.     //New syntax + easier way to do it
  75.     int victim = GetClientOfUserId(event.GetInt("userid"));
  76.     int attacker = GetClientOfUserId(event.GetInt("attacker"));
  77.    
  78.    
  79.     //int damage = GetEventInt(event,"dmg_health");
  80.     int damage = event.GetInt("dmg_health");
  81.    
  82.     char weapon[32];
  83.     //GetEventString(event, "weapon", weapon, sizeof(weapon));
  84.     event.GetString("weapon", weapon, 32);
  85.    
  86.     // If the player is a zombie and it is hurt with a grenade
  87.     if (GetClientTeam(victim) == 2 && StrEqual("weapon_hegrenade", weapon, false)) {
  88.        
  89.         //To be completed, lookup the hash value of the attacker and compare position
  90.         //Also apply attackers directional vector to the grenade
  91.         //Do not apply horizontal vector if the grenade is behind player
  92.        
  93.         // Generate the vector
  94.         float vector[3];
  95.         vector[0] = 0.0;
  96.         vector[1] = 0.0;
  97.         vector[2] = knockback * damage;
  98.        
  99.         // Apply the push
  100.         TeleportEntity(victim, NULL_VECTOR, NULL_VECTOR, vector);
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment