Raised This Month: $32 Target: $400
 8% 

Timer on event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
farawayf
Senior Member
Join Date: Jan 2019
Old 01-19-2019 , 13:47   Timer on event
Reply With Quote #1

Hello
Need to set a timer that will start after the event "player_hurt" and will execute action "PlayerHurt"
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public OnPluginStart()
{    
    
HookEvent("player_hurt"PlayerHurtEventHookMode_Pre);
}    

public 
Action:PlayerHurt(Handle:event, const String:name[],bool:dontBroadcast)
{
    new 
GetClientOfUserId(GetEventInt(event"userid"));
    
    if(
== 0) return Plugin_Continue;
    if (
GetEntPropFloat(iProp_Send"m_flVelocityModifier") < 0.6SetEntPropFloat(iProp_Send"m_flVelocityModifier"0.4);

    return 
Plugin_Continue;

farawayf is offline
sdz
Senior Member
Join Date: Feb 2012
Old 01-19-2019 , 17:33   Re: Timer on event
Reply With Quote #2

https://sm.alliedmods.net/new-api/timers/CreateTimer
https://sm.alliedmods.net/new-api/events/Event

PHP Code:
#include <sourcemod>
#include <sdkhooks>

public void OnPluginStart()
{
    
HookEvent("player_hurt"Event_HurtEventHookMode_Pre);
}

public 
Action Event_Hurt(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if(!
IsClientConnected(client) || !IsClientInGame(client) || !IsPlayerAlive(client)) return Plugin_Continue;

    
CreateTimer(5.0Timer_SendHurtGetClientSerial(client));
}

public 
Action Timer_SendHurt(Handle timerany data)
{
    
int client GetClientFromSerial(data);

    
SDKHooks_TakeDamage(client00damageDMG_GENERIC, -1NULL_VECTORNULL_VECTOR);


Last edited by sdz; 01-19-2019 at 17:42.
sdz is offline
farawayf
Senior Member
Join Date: Jan 2019
Old 01-21-2019 , 13:42   Re: Timer on event
Reply With Quote #3

Thanks
farawayf is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:51.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode