Veteran Member
Join Date: Jan 2016
Location: Argentina
|
05-31-2019
, 00:29
Re: [CS:GO] Custom fire particles
|
#12
|
Quote:
Originally Posted by extr1m725
check if this plugin will suit you
Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>
#include <zombiereloaded>
#define DECSPEED 0.55
#define DETDELAY 1.3
float g_iClientSpeed[MAXPLAYERS+1] = { 1.0, ... };
Handle g_hClientTimer[MAXPLAYERS+1] = {INVALID_HANDLE, ...};
public void OnPluginStart()
{
HookEvent("round_start", Event_OnRoundStart);
}
public void OnEntityCreated(int entity, const char[] classname)
{
if(entity > MAXPLAYERS){
if (!strcmp(classname, "hegrenade_projectile"))
{
int reference = EntIndexToEntRef(entity);
CreateTimer(0.0, Timer_OnGrenadeCreated, reference);
CreateTimer(DETDELAY, HeDetonate, reference, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
public Action Timer_OnGrenadeCreated(Handle Timer, any reference)
{
int entity = EntRefToEntIndex(reference);
if(entity != INVALID_ENT_REFERENCE)
{
int owner = GetEntPropEnt(entity, Prop_Send, "m_hThrower");
char name[32];
GetClientName(owner, name, sizeof(name));
SetEntProp(entity, Prop_Data, "m_nNextThinkTick", -1);
}
}
public Action Event_OnRoundStart(Handle event, char[] name, bool dontBroadcast)
{
for (int i=1;i<MaxClients;i++)
{
g_hClientTimer[i] = INVALID_HANDLE;
}
CreateTimer(0.1, Timer_GetMovementValue, client);
return Plugin_Continue;
}
public Action Timer_GetMovementValue( Handle Timer, int client )
{
if(IsValidClient(client) && IsPlayerAlive(client))
{
g_iClientSpeed[client] = GetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue");
}
return Plugin_Handled;
}
public Action HeDetonate(Handle Timer, any reference)
{
new entity = EntRefToEntIndex(reference);
if(entity == INVALID_ENT_REFERENCE)
return Plugin_Stop;
float entityposition[3];
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", entityposition);
for (new i = 1; i < MAXPLAYERS ; i++)
{
if (IsValidClient(i))
{
if (IsPlayerAlive(i) && !ZR_IsClientHuman(i))
{
char clientname[32];
GetClientName(i, clientname, sizeof(clientname));
float clientpos[3];
GetClientAbsOrigin(i, clientpos);
float distance = GetVectorDistance(entityposition, clientpos);
if(distance <= 350.0)
{
float time = 5.0;
ClientSetSpeed(i, g_iClientSpeed[i]-DECSPEED);
SetEntityRenderColor(i, 255, 0, 0, 255);
g_hClientTimer[i] = CreateTimer(time, Timer_ResetSpeed, i, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
}
AcceptEntityInput(entity,"Kill");
return Plugin_Handled;
}
void ClientSetSpeed(int client, float speed)
{
SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", speed);
}
public Action Timer_ResetSpeed(Handle Timer, any client)
{
if(Timer == g_hClientTimer[client] && IsValidClient(client))
{
ClientSetSpeed( client, g_iClientSpeed[client] );
SetEntityRenderColor(client, 255, 255, 255, 255);
g_hClientTimer[client] = INVALID_HANDLE;
}
return Plugin_Handled;
}
bool IsValidClient(int client)
{
if( client <= 0 )
return false;
if( client > GetMaxClients() )
return false;
if( !IsClientConnected(client) )
return false;
if( !IsClientInGame(client) )
return false;
return true;
}
|
Looks nice, did you make it?
I just fixed this because it didnt compile
PHP Code:
public Action Event_OnRoundStart(Handle event, char[] name, bool dontBroadcast)
{
for (int i=1;i<MaxClients;i++)
{
g_hClientTimer[i] = INVALID_HANDLE;
}
int client = GetClientOfUserId(GetEventInt(event, "userid"));
CreateTimer(0.1, Timer_GetMovementValue, client);
return Plugin_Continue;
}
By the way, i think this plugin can make issues with other maps with gravity/ice items, like ze_FFVII_Mako_Reactor, i'll test it tomorrow and back here again
__________________
|
|