AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Grenade Glow (https://forums.alliedmods.net/showthread.php?t=53673)

Dark Kingdom 04-08-2007 17:02

Grenade Glow
 
How do I make grenades glow for SvenCoop?

Wilson [29th ID] 04-08-2007 18:49

Re: Grenade Glow
 
You can hook FM_SetModel and test if the entity is having its model set to a grenade. If so, set the entity's effects that way.

For Example:

Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> // Set the model you wish to make glow here new const g_szGrenadeMdl[] = "models/w_grenade.mdl"; public plugin_init() {     register_forward( FM_SetModel, "hook_SetModel_post", 1 ); } public hook_SetModel_post( ent, const szMdl[] ) {     // If model being set equals the global string of the grenade model     if( equal( szMdl, g_szGrenadeMdl ) )     {         // Set Glow Effect         set_pev( ent, pev_renderfx, kRenderFxGlowShell );         set_pev( ent, pev_renderamt, 125.0 );         set_pev( ent, pev_rendermode, kRenderTransAlpha );         set_pev( ent, pev_rendercolor, {0.0, 255.0, 0.0} );     } }

Dark Kingdom 04-08-2007 19:05

Re: Grenade Glow
 
Your Example, is giving my errors when I compile it.

Wilson [29th ID] 04-08-2007 19:49

Re: Grenade Glow
 
Well post them.

Make sure you include above the very first line the regular includes

#include <amxmodx>
#include <amxmisc>

Dark Kingdom 04-09-2007 06:45

Re: Grenade Glow
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>


new const g_szGrenadeMdl "models/w_grenade.mdl"

public plugin_init() {
    
register_forwardFM_SetModel"hook_SetModel_post")
}

public 
hook_SetModel_postent, const szMdl[] )
 
    if( 
equalszMdlg_szGrenadeMdl ) )
    {
        
set_peventpev_renderfxkRenderFxGlowShell )
        
set_peventpev_renderamt125.0 )
        
set_peventpev_rendermodekRenderTransAlpha )
        
set_peventpev_rendercolor, {0.0255.00.0} )
    }


Compiles with

Code:

Welcome to the AMX Mod X 1.76-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

/home/groups/amxmodx/tmp3/phpGNlx58.sma(12) : warning 218: old style prototypes used with optional semicolumns
/home/groups/amxmodx/tmp3/phpGNlx58.sma(14) : error 010: invalid function or declaration
/home/groups/amxmodx/tmp3/phpGNlx58.sma(17) : error 021: symbol already defined: "set_pev"
/home/groups/amxmodx/tmp3/phpGNlx58.sma(23) : warning 203: symbol is never used: "g_szGrenadeMdl"

2 Errors.
Could not locate output file /home/groups/amxmodx/public_html/websc3/phpGNlx58.amx (compile failed).


Wilson [29th ID] 04-09-2007 12:25

Re: Grenade Glow
 
Dear god I for got a Squiggly thing! On the public hook_SetModel_post line, add a { at the end

Nican 04-09-2007 14:22

Re: Grenade Glow
 
Lol...
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

public plugin_init() {
    
register_forwardFM_SetModel"hook_SetModel_post")
}

public 
hook_SetModel_postent, const szMdl[] ){
 
    if( 
equaliszMdl"models/w_grenade.mdl" ) )
    {
        
set_peventpev_renderfxkRenderFxGlowShell )
        
set_peventpev_renderamt125.0 )
        
set_peventpev_rendermodekRenderTransAlpha )
        
set_peventpev_rendercolor, {0.0255.00.0} )
    }



Wilson [29th ID] 04-09-2007 20:19

Re: Grenade Glow
 
No, Nican...use global const's for strings. Read about optimization.

I wrote the original thing in a rush -- forgot the [] for the global const too. Check up top it's fixed in my original thread.

Drak 05-08-2007 16:03

Re: Grenade Glow
 
Quote:

Originally Posted by Wilson [29th ID] (Post 462795)
No, Nican...use global const's for strings. Read about optimization.

I wrote the original thing in a rush -- forgot the [] for the global const too. Check up top it's fixed in my original thread.

I know this is a somewhat old thread. But I couldn't find much information on this, why is it better to use a global, instead of what Nican did? (What's making it perform better?)

pRED* 05-08-2007 19:22

Re: Grenade Glow
 
http://wiki.amxmodx.org/Optimizing_P...tant_variables

Pretty useful page. Really should pay more attention to it myself


All times are GMT -4. The time now is 06:39.

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