Thanx Man, I got the trails to work. Both the flashbang and smokegrenade, I got them to reload after battling with the script for about 30 minutes. Now gambit is awesome now
Here's the edited script of Gambit:
With Hegrenade, Flashbang, Smokegrenade (All were able to reload successfully)
Now three of the grenades have trails
Just want to share
#include <amxmod>
#include <Vexd_Utilities>
#include <superheromod>
#define AMMOX_FLASHBANG 11
#define AMMOX_HEGRENADE 12
#define AMMOX_SMOKEGRENADE 13
// GLOBAL VARIABLES
new gHeroName[]="Gambit"
new bool:gHasGambitPower[SH_MAXSLOTS+1]
new gGrenTrail
new const HEGRENADE_MODEL[] = "models/w_hegrenade.mdl"
new const FLASHBANG_MODEL[] = "models/w_flashbang.mdl"
new const SMOKEGRENADE_MODEL[] = "models/w_smokegrenade.mdl"
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Gambit", "version", "Authors Name")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
register_cvar("gambit_level", "0")
register_cvar("gambit_grenademult", "60.9")
register_cvar("gambit_grenadetimer", "30.0")
register_cvar("gambit_cooldown", "120.0")
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
shCreateHero(gHeroName, "Kinetically Charged Nades", "Charge your HE Grenades with Kinetic Energy for Extra Damage, also refill HE Grenades.", false, "gambit_level")
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
// INIT
register_srvcmd("gambit_init", "gambit_init")
shRegHeroInit(gHeroName, "gambit_init")
// NEW SPAWN
register_event("ResetHUD", "newSpawn", "b")
// EXTRA NADE DAMAGE
register_event("Damage", "gambit_damage", "b", "2!0")
// FIND THROWN GRENADES
register_event("AmmoX", "on_AmmoX", "b")
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
gGrenTrail = precache_model("sprites/zbeam5.spr")
}
//----------------------------------------------------------------------------------------------
public gambit_init()
{
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id = str_to_num(temp)
// 2nd Argument is 0 or 1 depending on whether the id has the hero
read_argv(2,temp,5)
new hasPowers = str_to_num(temp)
gHasGambitPower[id] = (hasPowers!=0)
if ( hasPowers && is_user_alive(id) ) {
gambit_weapons(id)
}
}
//----------------------------------------------------------------------------------------------
public newSpawn(id)
{
if ( shModActive() && gHasGambitPower[id] && is_user_alive(id) ) {
gPlayerUltimateUsed[id] = false
set_task(0.1, "gambit_weapons", id)
}
}
//----------------------------------------------------------------------------------------------
public gambit_weapons(id)
{
if ( shModActive() && gHasGambitPower[id] && is_user_alive(id) ) {
shGiveWeapon(id, "weapon_hegrenade")
}
if ( shModActive() && gHasGambitPower[id] && is_user_alive(id) ) {
shGiveWeapon(id, "weapon_flashbang")
}
if ( shModActive() && gHasGambitPower[id] && is_user_alive(id) ) {
shGiveWeapon(id, "weapon_smokegrenade")
}
}
//----------------------------------------------------------------------------------------------
public gambit_damage(id)
{
if ( !shModActive() || !is_user_alive(id) ) return
new damage = read_data(2)
new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
new headshot = bodypart == 1 ? 1 : 0
if ( attacker <= 0 || attacker > SH_MAXSLOTS ) return
if ( gHasGambitPower[attacker] && weapon == CSW_HEGRENADE && is_user_alive(id) && !gPlayerUltimateUsed[attacker] ) {
// do extra damage
new extraDamage = floatround(damage * get_cvar_float("gambit_grenademult") - damage)
if (extraDamage > 0) shExtraDamage(id, attacker, extraDamage, "grenade", headshot)
if ( attacker != id ) {
// Set the cooldown in x seconds because nades can hurt more then one person
// only when damaging others
new parm[1]
parm[0] = attacker
set_task(0.2, "gambit_setcooldown", 0, parm,1)
}
}
}
//----------------------------------------------------------------------------------------------
public on_AmmoX(id)
{
if ( !shModActive() || !is_user_alive(id) ) return
new iAmmoType = read_data(1)
new iAmmoCount = read_data(2)
if ( iAmmoType == AMMOX_HEGRENADE && gHasGambitPower[id] ) {
if (iAmmoCount == 0) {
set_task(get_cvar_float("gambit_grenadetimer" ), "gambit_weapons", id)
if ( !gPlayerUltimateUsed[id] ) {
// Have to Find the current HE grenade
new iCurrent = -1
while ( ( iCurrent = FindEntity(iCurrent, "grenade") ) > 0 ) {
new string[32]
Entvars_Get_String(iCurrent, EV_SZ_model, string, 31)
if ( id == Entvars_Get_Edict(iCurrent, EV_ENT_owner) && equali(HEGRENADE_MODEL, string)) {
new Float:glowColor[3] = {225.0, 0.0, 20.0}
// Make the nade glow
Entvars_Set_Int(iCurrent, EV_INT_renderfx, kRenderFxGlowShell)
Entvars_Set_Vector(iCurrent, EV_VEC_rendercolor, glowColor)
// Make the nade a bit invisible to make glow look better
Entvars_Set_Int(iCurrent, EV_INT_rendermode, kRenderTransAlpha)
Entvars_Set_Float(iCurrent, EV_FL_renderamt, 100.0 )
// Make a trail
message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
write_byte(22) //TE_BEAMFOLLOW
write_short(iCurrent) // entity:attachment to follow
write_short(gGrenTrail) // sprite index
write_byte(10) // life in 0.1's
write_byte(10) // line width in 0.1's
write_byte(225) // colour
write_byte(90)
write_byte(102)
write_byte(255) // brightness
message_end()
}
}
}
}
else if (iAmmoCount > 0) {
// Got a new nade remove the timer
remove_task(id)
}
}
if ( iAmmoType == AMMOX_FLASHBANG && gHasGambitPower[id] ) {
if (iAmmoCount == 0) {
set_task(get_cvar_float("gambit_grenadetimer" ), "gambit_weapons", id)
if ( !gPlayerUltimateUsed[id] ) {
// Have to Find the current HE grenade
new iCurrent = -1
while ( ( iCurrent = FindEntity(iCurrent, "grenade") ) > 0 ) {
new string[32]
Entvars_Get_String(iCurrent, EV_SZ_model, string, 31)
if ( id == Entvars_Get_Edict(iCurrent, EV_ENT_owner) && equali(FLASHBANG_MODEL, string)) {
new Float:glowColor[3] = {225.0, 0.0, 20.0}
// Make the nade glow
Entvars_Set_Int(iCurrent, EV_INT_renderfx, kRenderFxGlowShell)
Entvars_Set_Vector(iCurrent, EV_VEC_rendercolor, glowColor)
// Make the nade a bit invisible to make glow look better
Entvars_Set_Int(iCurrent, EV_INT_rendermode, kRenderTransAlpha)
Entvars_Set_Float(iCurrent, EV_FL_renderamt, 100.0 )
// Make a trail
message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
write_byte(22) //TE_BEAMFOLLOW
write_short(iCurrent) // entity:attachment to follow
write_short(gGrenTrail) // sprite index
write_byte(10) // life in 0.1's
write_byte(10) // line width in 0.1's
write_byte(225) // colour
write_byte(90)
write_byte(102)
write_byte(255) // brightness
message_end()
}
}
}
}
else if (iAmmoCount > 0) {
// Got a new nade remove the timer
remove_task(id)
}
}
if ( iAmmoType == AMMOX_SMOKEGRENADE && gHasGambitPower[id] ) {
if (iAmmoCount == 0) {
set_task(get_cvar_float("gambit_grenadetimer" ), "gambit_weapons", id)
if ( !gPlayerUltimateUsed[id] ) {
// Have to Find the current HE grenade
new iCurrent = -1
while ( ( iCurrent = FindEntity(iCurrent, "grenade") ) > 0 ) {
new string[32]
Entvars_Get_String(iCurrent, EV_SZ_model, string, 31)
if ( id == Entvars_Get_Edict(iCurrent, EV_ENT_owner) && equali(SMOKEGRENADE_MODEL, string)) {
new Float:glowColor[3] = {225.0, 0.0, 20.0}
// Make the nade glow
Entvars_Set_Int(iCurrent, EV_INT_renderfx, kRenderFxGlowShell)
Entvars_Set_Vector(iCurrent, EV_VEC_rendercolor, glowColor)
// Make the nade a bit invisible to make glow look better
Entvars_Set_Int(iCurrent, EV_INT_rendermode, kRenderTransAlpha)
Entvars_Set_Float(iCurrent, EV_FL_renderamt, 100.0 )
// Make a trail
message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
write_byte(22) //TE_BEAMFOLLOW
write_short(iCurrent) // entity:attachment to follow
write_short(gGrenTrail) // sprite index
write_byte(10) // life in 0.1's
write_byte(10) // line width in 0.1's
write_byte(225) // colour
write_byte(90)
write_byte(102)
write_byte(255) // brightness
message_end()
}
}
}
}
else if (iAmmoCount > 0) {
// Got a new nade remove the timer
remove_task(id)
}
}
}
//----------------------------------------------------------------------------------------------
public gambit_setcooldown(parm[])
{
new id = parm[0]
if ( !is_user_alive(id) || gPlayerUltimateUsed[id] ) return
// Cooldown will only be set if user hurts someone with a gambit nade
new Float:gambitCooldown = get_cvar_float("gambit_cooldown")
if (gambitCooldown > 0.0) ultimateTimer(id, gambitCooldown)
}
//----------------------------------------------------------------------------------------------
public client_connect(id)
{
gHasGambitPower[id] = false
}
//----------------------------------------------------------------------------------------------
__________________