Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- ConVar Enabled;
- public Plugin myinfo = {
- name = "Nade_Kick",
- author = "AgentWesker",
- description = "Player might get his weapon jammed while shooting and he has to reload.",
- version = "0.0.1",
- url = "http://steam-gamers.net"
- };
- public void OnPluginStart()
- {
- //Enabled / Disabled convar
- Enabled = CreateConVar("sm_nadekick_enabled", "1", "Enable/Disable the plugin. Enable = 1.", _, true, 0.0, true, 1.0);
- HookEvent("player_hurt", Event_HandleNadeDamage); //You forgot to make the event hook for player_hurt
- //Execute the config and create if not yet made
- AutoExecConfig(true, "nade_kick");
- }
- public void OnEntityCreated(int entity, const char[] classname)
- {
- //Hook the entity
- SDKHook(entity, SDKHook_SpawnPost, OnEntitySpawned);
- }
- public void OnEntitySpawned(int entity)
- {
- //Is the plugin enabled? Otherwise dont continue
- if (!GetConVarBool(Enabled))
- {
- return;
- }
- char class_name[32];
- GetEdictClassname(entity, class_name, 32);
- int owner = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity"); //The client
- //Is the entity a projectile? This ignores weapon spawns
- if (StrContains(class_name, "projectile", false) != -1 && IsValidEntity(entity))
- {
- //Is the projectile an hegrenade?
- if (StrContains(class_name, "hegrenade") != -1)
- {
- //Get the clients angles and position
- float pEyePosition[3], pEyeAngle[3];
- GetClientEyePosition(owner, pEyePosition);
- GetClientEyeAngles(owner, pEyeAngle);
- //To be completed, put these in a hash using client as key
- //Print to chat for debugging purposes
- PrintToChatAll("[SM]%N: My horizontal position is %f %f", owner, pEyePosition[0], pEyePosition[1]);
- PrintToChatAll("[SM]%N: My horizontal angles are %f %f", owner, pEyeAngle[0], pEyeAngle[1]);
- }
- }
- }
- public void Event_HandleNadeDamage(Event event, const char[] name, bool dontBroadcast) {
- //Get client of attacker and victim
- /*int victimId = GetEventInt(event, "userid")
- int attackerId = GetEventInt(event, "attacker")
- int victim = GetClientOfUserId(victimId);
- int attacker = GetClientOfUserId(attackerId);*/
- //New syntax + easier way to do it
- int victim = GetClientOfUserId(event.GetInt("userid"));
- int attacker = GetClientOfUserId(event.GetInt("attacker"));
- //int damage = GetEventInt(event,"dmg_health");
- int damage = event.GetInt("dmg_health");
- char weapon[32];
- //GetEventString(event, "weapon", weapon, sizeof(weapon));
- event.GetString("weapon", weapon, 32);
- // If the player is a zombie and it is hurt with a grenade
- if (GetClientTeam(victim) == 2 && StrEqual("weapon_hegrenade", weapon, false)) {
- //To be completed, lookup the hash value of the attacker and compare position
- //Also apply attackers directional vector to the grenade
- //Do not apply horizontal vector if the grenade is behind player
- // Generate the vector
- float vector[3];
- vector[0] = 0.0;
- vector[1] = 0.0;
- vector[2] = knockback * damage;
- // Apply the push
- TeleportEntity(victim, NULL_VECTOR, NULL_VECTOR, vector);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment