Page 1 of 1

Effect Script

Posted: Sat Jul 16, 2016 6:32 pm
by Painkiller
The language the script should be coded in : Source Python

Games the script should work with : Half-Life 2 DeathMatch

A detailed description of what you want the script to do :
Hello Eventscripts Team and Other.

Can anybody sourcemod plugin rewrite for Source Python please?

Best perhaps both equal in one.
( This script make a explosions effect: frag_grenade, smg1_grenade, rpg_missle, slam, combine_ball, barrels etc.)


Syntax: Select all

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

//Current version of the plugin.
#define PLUGIN_VERSION "1.0.2"

new g_iEffect[2048];

new Handle:g_hDelay = INVALID_HANDLE;
new Handle:g_hVtf = INVALID_HANDLE;
new Handle:g_hVmt = INVALID_HANDLE;
new Handle:g_hSound = INVALID_HANDLE;
new Handle:g_hVtf2 = INVALID_HANDLE;
new Handle:g_hVmt2 = INVALID_HANDLE;
new Handle:g_hSound2 = INVALID_HANDLE;

new String:g_sVtf[PLATFORM_MAX_PATH], String:g_sVmt[PLATFORM_MAX_PATH], String:g_sSound[PLATFORM_MAX_PATH];
new String:g_sVtf2[PLATFORM_MAX_PATH], String:g_sVmt2[PLATFORM_MAX_PATH], String:g_sSound2[PLATFORM_MAX_PATH];

public Plugin:myinfo =
{
name = "HL2:DM Explosion",
author = "Panda",
description = "Creates an explosive entity on grenade death and barrel explosion.",
version = PLUGIN_VERSION,
url = "http://forums.alliedmodders.com"
};

public OnPluginStart()
{
g_hVtf = CreateConVar("sm_hl2dm_explosion_vtf", "particle/smokeball.vtf", "Path to specified VTF file. (GAS/BARREL)", FCVAR_NONE);
g_hVmt = CreateConVar("sm_hl2dm_explosion_vmt", "particle/smokeball.vmt", "Path to specified VMT file. (GAS/BARREL)", FCVAR_NONE);
g_hSound = CreateConVar("sm_hl2dm_explosion_sound", "effects/barrel_explode.mp3", "Sound to play. Set to \"\" to disable. (GAS/BARREL)", FCVAR_NONE);
g_hVtf2 = CreateConVar("sm_hl2dm_explosion_vtf_2", "particle/orbsmoke3.vtf", "Path to specified VTF file. (COMBINEBALL)", FCVAR_NONE);
g_hVmt2 = CreateConVar("sm_hl2dm_explosion_vmt_2", "particle/orbsmoke3.vmt", "Path to specified VMT file. (COMBINEBALL)", FCVAR_NONE);
g_hSound2 = CreateConVar("sm_hl2dm_explosion_sound_2", "effects/death_combine.mp3", "Sound to play. Set to \"\" to disable. (COMBINEBALL)", FCVAR_NONE);
g_hDelay = CreateConVar("sm_hl2dm_explosion_delay", "8.0", "Delay until deleting the created explosion.", FCVAR_NONE);
AutoExecConfig(true, "sm_hl2dm_explosion_v102");

GetConVarString(g_hVtf, g_sVtf, sizeof(g_sVtf));
GetConVarString(g_hVmt, g_sVmt, sizeof(g_sVmt));
GetConVarString(g_hSound, g_sSound, sizeof(g_sSound));
GetConVarString(g_hVtf2, g_sVtf2, sizeof(g_sVtf2));
GetConVarString(g_hVmt2, g_sVmt2, sizeof(g_sVmt2));
GetConVarString(g_hSound2, g_sSound2, sizeof(g_sSound2));
}

public OnMapStart()
{
GetConVarString(g_hVtf, g_sVtf, sizeof(g_sVtf));
GetConVarString(g_hVmt, g_sVmt, sizeof(g_sVmt));
GetConVarString(g_hSound, g_sSound, sizeof(g_sSound));
GetConVarString(g_hVtf2, g_sVtf2, sizeof(g_sVtf2));
GetConVarString(g_hVmt2, g_sVmt2, sizeof(g_sVmt2));
GetConVarString(g_hSound2, g_sSound2, sizeof(g_sSound2));

decl String:sBuffer[PLATFORM_MAX_PATH];
Format(sBuffer, sizeof(sBuffer), "materials/%s", g_sVtf);
AddFileToDownloadsTable(sBuffer);
PrecacheModel(g_sVtf, true);

Format(sBuffer, sizeof(sBuffer), "materials/%s", g_sVmt);
AddFileToDownloadsTable(sBuffer);
PrecacheModel(g_sVmt, true);

if(!StrEqual(g_sSound, ""))
{
Format(sBuffer, sizeof(sBuffer), "sound/%s", g_sSound);
AddFileToDownloadsTable(sBuffer);
PrecacheSound(g_sSound, true);
}

Format(sBuffer, sizeof(sBuffer), "materials/%s", g_sVtf2);
AddFileToDownloadsTable(sBuffer);
PrecacheModel(g_sVtf2, true);

Format(sBuffer, sizeof(sBuffer), "materials/%s", g_sVmt2);
AddFileToDownloadsTable(sBuffer);
PrecacheModel(g_sVmt2, true);

if(!StrEqual(g_sSound2, ""))
{
Format(sBuffer, sizeof(sBuffer), "sound/%s", g_sSound2);
AddFileToDownloadsTable(sBuffer);
PrecacheSound(g_sSound2, true);
}
}

public OnEntityCreated(entity, const String:classname[])
{
if(entity <= MAXPLAYERS)
return;
else if(StrContains(classname, "prop_", false) != -1)
CreateTimer(0.1, Timer_Created, EntIndexToEntRef(entity));
}

public Action:Timer_Created(Handle:timer, any:ref)
{
new entity = EntRefToEntIndex(ref);
if(entity != INVALID_ENT_REFERENCE)
{
decl String:sBuffer[PLATFORM_MAX_PATH];
GetEntPropString(entity, Prop_Data,mi "m_ModelName", sBuffer, sizeof(sBuffer));
if(StrEqual(sBuffer, "models/props_c17/oildrum001_explosive.mdl", false))
{
g_iEffect[entity] = 1;
SDKHook(entity, SDKHook_OnTakeDamage, CreateExplosion);
}
else if(StrEqual(sBuffer, "models/props_junk/gascan001a.mdl", false))
{
g_iEffect[entity] = 1;
SDKHook(entity, SDKHook_OnTakeDamage, CreateExplosion);
}
else if(StrEqual(sBuffer, "models/effects/combineball.mdl", false))
g_iEffect[entity] = 2;
}
}

public OnEntityDestroyed(entity)
{
if(entity >= 0)
{
if(IsValidEntity(entity) && g_iEffect[entity] == 2)
CreateExplosion2(entity);

g_iEffect[entity] = 0;
}
}

CreateExplosion2(entity)
{
new iExplosion = CreateEntityByName("env_ar2explosion");
if(iExplosion > 0)
{
decl Float:fOrigin[3];
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fOrigin);

DispatchKeyValue(iExplosion, "material", g_sVtf2);
DispatchSpawn(iExplosion);
TeleportEntity(iExplosion, fOrigin, NULL_VECTOR, NULL_VECTOR);
if(!StrEqual(g_sSound2, ""))
EmitAmbientSound(g_sSound2, fOrigin, entity, SNDLEVEL_ROCKET);

CreateTimer(0.1, Timer_Explode, EntIndexToEntRef(iExplosion));
}

return;
}

public Action:CreateExplosion(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3], damagecustom)
{
new Float:fHealth = Float:GetEntProp(victim, Prop_Data, "m_iHealth");
if((fHealth - damage) > 0.0)
return Plugin_Continue;

new iExplosion = CreateEntityByName("env_ar2explosion");
if(iExplosion > 0)
{
decl Float:fOrigin[3];
GetEntPropVector(victim, Prop_Send, "m_vecOrigin", fOrigin);

DispatchKeyValue(iExplosion, "material", g_sVtf);
DispatchSpawn(iExplosion);
TeleportEntity(iExplosion, fOrigin, NULL_VECTOR, NULL_VECTOR);
if(!StrEqual(g_sSound, ""))
EmitAmbientSound(g_sSound, fOrigin, victim, SNDLEVEL_ROCKET);

CreateTimer(0.1, Timer_Explode, EntIndexToEntRef(iExplosion));
g_iEffect[victim] = 0;

SDKUnhook(victim, SDKHook_OnTakeDamage, CreateExplosion);
}

return Plugin_Continue;
}

public Action:Timer_Explode(Handle:timer, any:ref)
{
new entity = EntRefToEntIndex(ref);
if(entity != INVALID_ENT_REFERENCE)
{
AcceptEntityInput(entity, "Explode");
CreateTimer(GetConVarFloat(g_hDelay), Timer_Kill, ref);
}
}

public Action:Timer_Kill(Handle:timer, any:ref)
{
new entity = EntRefToEntIndex(ref);
if(entity != INVALID_ENT_REFERENCE)
{
AcceptEntityInput(entity, "Kill");
}
}


AND

Syntax: Select all

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

//Current version of the plugin.
#define PLUGIN_VERSION "1.0.2"

new g_iEffect[2048];

new Handle:g_hDelay = INVALID_HANDLE;
new Handle:g_hVtf = INVALID_HANDLE;
new Handle:g_hVmt = INVALID_HANDLE;
new Handle:g_hSound = INVALID_HANDLE;
new Handle:g_hVtf2 = INVALID_HANDLE;
new Handle:g_hVmt2 = INVALID_HANDLE;
new Handle:g_hSound2 = INVALID_HANDLE;

new String:g_sVtf[PLATFORM_MAX_PATH], String:g_sVmt[PLATFORM_MAX_PATH], String:g_sSound[PLATFORM_MAX_PATH];
new String:g_sVtf2[PLATFORM_MAX_PATH], String:g_sVmt2[PLATFORM_MAX_PATH], String:g_sSound2[PLATFORM_MAX_PATH];

public Plugin:myinfo =
{
name = "HL2:DM Explosion1",
author = "Painkiller",
description = "Creates an explosive entity on grenade death and slams explosion.",
version = PLUGIN_VERSION,
url = "http://forums.alliedmodders.com"
};

public OnPluginStart()
{
g_hVtf = CreateConVar("sm_hl2dm_explosion1_vtf", "particle/particle_smokegrenade1.vtf", "Path to specified VTF file. (GAS/BARREL)", FCVAR_NONE);
g_hVmt = CreateConVar("sm_hl2dm_explosion1_vmt", "particle/particle_smokegrenade1.vmt", "Path to specified VMT file. (GAS/BARREL)", FCVAR_NONE);
g_hSound = CreateConVar("sm_hl2dm_explosion1_sound", "effects/explode.mp3", "Sound to play. Set to \"\" to disable. (GAS/BARREL)", FCVAR_NONE);
g_hVtf2 = CreateConVar("sm_hl2dm_explosion1_vtf_2", "particle/particle_smokegrenade1.vtf", "Path to specified VTF file. (COMBINEBALL)", FCVAR_NONE);
g_hVmt2 = CreateConVar("sm_hl2dm_explosion1_vmt_2", "particle/particle_smokegrenade1.vmt", "Path to specified VMT file. (COMBINEBALL)", FCVAR_NONE);
g_hSound2 = CreateConVar("sm_hl2dm_explosion1_sound_2", "effects/explode.mp3", "Sound to play. Set to \"\" to disable. (COMBINEBALL)", FCVAR_NONE);
g_hDelay = CreateConVar("sm_hl2dm_explosion1_delay", "8.0", "Delay until deleting the created explosion.", FCVAR_NONE);
AutoExecConfig(true, "sm_hl2dm_explosion_v103");

GetConVarString(g_hVtf, g_sVtf, sizeof(g_sVtf));
GetConVarString(g_hVmt, g_sVmt, sizeof(g_sVmt));
GetConVarString(g_hSound, g_sSound, sizeof(g_sSound));
GetConVarString(g_hVtf2, g_sVtf2, sizeof(g_sVtf2));
GetConVarString(g_hVmt2, g_sVmt2, sizeof(g_sVmt2));
GetConVarString(g_hSound2, g_sSound2, sizeof(g_sSound2));
}

public OnMapStart()
{
GetConVarString(g_hVtf, g_sVtf, sizeof(g_sVtf));
GetConVarString(g_hVmt, g_sVmt, sizeof(g_sVmt));
GetConVarString(g_hSound, g_sSound, sizeof(g_sSound));
GetConVarString(g_hVtf2, g_sVtf2, sizeof(g_sVtf2));
GetConVarString(g_hVmt2, g_sVmt2, sizeof(g_sVmt2));
GetConVarString(g_hSound2, g_sSound2, sizeof(g_sSound2));

decl String:sBuffer[PLATFORM_MAX_PATH];
Format(sBuffer, sizeof(sBuffer), "materials/%s", g_sVtf);
AddFileToDownloadsTable(sBuffer);
PrecacheModel(g_sVtf, true);

Format(sBuffer, sizeof(sBuffer), "materials/%s", g_sVmt);
AddFileToDownloadsTable(sBuffer);
PrecacheModel(g_sVmt, true);

if(!StrEqual(g_sSound, ""))
{
Format(sBuffer, sizeof(sBuffer), "sound/%s", g_sSound);
AddFileToDownloadsTable(sBuffer);
PrecacheSound(g_sSound, true);
}

Format(sBuffer, sizeof(sBuffer), "materials/%s", g_sVtf2);
AddFileToDownloadsTable(sBuffer);
PrecacheModel(g_sVtf2, true);

Format(sBuffer, sizeof(sBuffer), "materials/%s", g_sVmt2);
AddFileToDownloadsTable(sBuffer);
PrecacheModel(g_sVmt2, true);

if(!StrEqual(g_sSound2, ""))
{
Format(sBuffer, sizeof(sBuffer), "sound/%s", g_sSound2);
AddFileToDownloadsTable(sBuffer);
PrecacheSound(g_sSound2, true);
}
}

public OnEntityCreated(entity, const String:classname[])
{
if(entity <= MAXPLAYERS)
return;
else if(StrContains(classname, "prop_", false) != -1)
CreateTimer(0.1, Timer_Created, EntIndexToEntRef(entity));
}

public Action:Timer_Created(Handle:timer, any:ref)
{
new entity = EntRefToEntIndex(ref);
if(entity != INVALID_ENT_REFERENCE)
{
decl String:sBuffer[PLATFORM_MAX_PATH];
GetEntPropString(entity, Prop_Data, "m_ModelName", sBuffer, sizeof(sBuffer));
if(StrEqual(sBuffer, "models/items/ar2_grenade.mdl", false))
{
g_iEffect[entity] = 1;
SDKHook(entity, SDKHook_OnTakeDamage, CreateExplosion);
}
else if(StrEqual(sBuffer, "models/weapons/w_grenade.mdl", false))
{
g_iEffect[entity] = 1;
SDKHook(entity, SDKHook_OnTakeDamage, CreateExplosion);
}
else if(StrEqual(sBuffer, "models/items/ammocrate_rockets.mdl", false))
g_iEffect[entity] = 2;
}
}

public OnEntityDestroyed(entity)
{
if(entity >= 0)
{
if(IsValidEntity(entity) && g_iEffect[entity] == 2)
CreateExplosion2(entity);

g_iEffect[entity] = 0;
}
}

CreateExplosion2(entity)
{
new iExplosion = CreateEntityByName("env_ar2explosion");
if(iExplosion > 0)
{
decl Float:fOrigin[3];
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fOrigin);

DispatchKeyValue(iExplosion, "material", g_sVtf2);
DispatchSpawn(iExplosion);
TeleportEntity(iExplosion, fOrigin, NULL_VECTOR, NULL_VECTOR);
if(!StrEqual(g_sSound2, ""))
EmitAmbientSound(g_sSound2, fOrigin, entity, SNDLEVEL_ROCKET);

CreateTimer(0.1, Timer_Explode, EntIndexToEntRef(iExplosion));
}

return;
}

public Action:CreateExplosion(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3], damagecustom)
{
new Float:fHealth = Float:GetEntProp(victim, Prop_Data, "m_iHealth");
if((fHealth - damage) > 0.0)
return Plugin_Continue;

new iExplosion = CreateEntityByName("env_ar2explosion");
if(iExplosion > 0)
{
decl Float:fOrigin[3];
GetEntPropVector(victim, Prop_Send, "m_vecOrigin", fOrigin);

DispatchKeyValue(iExplosion, "material", g_sVtf);
DispatchSpawn(iExplosion);
TeleportEntity(iExplosion, fOrigin, NULL_VECTOR, NULL_VECTOR);
if(!StrEqual(g_sSound, ""))
EmitAmbientSound(g_sSound, fOrigin, victim, SNDLEVEL_ROCKET);

CreateTimer(0.1, Timer_Explode, EntIndexToEntRef(iExplosion));
g_iEffect[victim] = 0;

SDKUnhook(victim, SDKHook_OnTakeDamage, CreateExplosion);
}

return Plugin_Continue;
}

public Action:Timer_Explode(Handle:timer, any:ref)
{
new entity = EntRefToEntIndex(ref);
if(entity != INVALID_ENT_REFERENCE)
{
AcceptEntityInput(entity, "Explode");
CreateTimer(GetConVarFloat(g_hDelay), Timer_Kill, ref);
}
}

public Action:Timer_Kill(Handle:timer, any:ref)
{
new entity = EntRefToEntIndex(ref);
if(entity != INVALID_ENT_REFERENCE)
{
AcceptEntityInput(entity, "Kill");
}
}

Re: Effect Script

Posted: Fri Jul 22, 2016 8:11 pm
by Painkiller
Hello Nobody an Idia?

Re: Effect Script

Posted: Wed Jul 27, 2016 10:53 am
by Guest
Please, help for this?

Re: Effect Script

Posted: Thu Jul 28, 2016 9:54 pm
by iPlayer

Syntax: Select all

GetEntPropString(entity, Prop_Data,mi "m_ModelName", sBuffer, sizeof(sBuffer));

Are you sure this line even compiles? Other than that, both scripts are almost the same exact code.

Re: Effect Script

Posted: Thu Jul 28, 2016 10:32 pm
by satoon101
The best way to get this request written would be to post exactly what you want it to do. I, personally, would rather just go off of that than have to read through a SM plugin and try to adapt it.

Re: Effect Script

Posted: Fri Jul 29, 2016 5:20 am
by Painkiller
iPlayer wrote:

Syntax: Select all

GetEntPropString(entity, Prop_Data,mi "m_ModelName", sBuffer, sizeof(sBuffer));

Are you sure this line even compiles? Other than that, both scripts are almost the same exact code.



Yes, they are almost identical.

The top shows effect at combine_ball and Barrels
and the lower script for grenades, slams, rpg and smg_grenades

Re: Effect Script

Posted: Fri Jul 29, 2016 5:22 am
by Painkiller
satoon101 wrote:The best way to get this request written would be to post exactly what you want it to do. I, personally, would rather just go off of that than have to read through a SM plugin and try to adapt it.


This plugin creates in detonation a smoky cloud with an overlay and sound.

Re: Effect Script

Posted: Mon Aug 08, 2016 9:15 pm
by Painkiller
Hello,
Nobody an Idia?

Re: Effect Script

Posted: Sat Oct 08, 2016 10:11 pm
by Painkiller
Nobody an idia?

Re: Effect Script

Posted: Sun Oct 23, 2016 4:14 pm
by Painkiller
I have the first contribution edit
To tell you what it does.