Raised This Month: $ Target: $400
 0% 

can someone fix my plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-02-2010 , 21:31   can someone fix my plugin
Reply With Quote #1

OK, I will post my code here, because I don't know how to fix it !
and I hope someone can help me, and tell me why !

Quote:
Originally Posted by ConnorMcLeod View Post
No, english is not our native language, gonna try to explain again :


You can use Think function of c4, but don't alter c4 nextthink.

In Think function, compare gametime() to the value you stored in a blobal var.
If it's time to send a new blast, send one, and then update the global var.
If it's not time, do nothing.
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "Bomb Blast"
#define VERSION "0.3"
#define AUTHOR "K.K.Lv"
new HamHook:g_BombThink
new g_Bomb
new g_SpriteCircle
new Float:g_fExplodeTime
new g_pCvarColor
public plugin_precache()
{
    g_SpriteCircle = precache_model( "sprites/shockwave.spr" )
}
public plugin_init()
{
    register_plugin( PLUGIN, VERSION, AUTHOR )
 
    g_pCvarColor = register_cvar( "bb_color", "250250250" ) //RRRGGGBBB
 
    if( find_ent_by_class( FM_NULLENT, "func_bomb_target" ) || find_ent_by_class( FM_NULLENT, "info_bomb_target" ) )
    {
         g_BombThink = RegisterHam( Ham_Think, "grenade", "Bomb_Think", 1 )
         register_event( "HLTV", "Stop", "a", "1=0", "2=0" )
         register_logevent( "Stop", 2, "1=Round_End" )
         register_logevent( "PlantedBomb", 3, "2=Planted_The_Bomb" )
    }
}
public Stop()
{
    g_Bomb = 0
    DisableHamForward( g_BombThink)
}
public PlantedBomb()
{
    new C4 = FM_NULLENT
    while( ( C4 = find_ent_by_class( C4, "grenade" ) ) )
    {
         if ( get_pdata_int( C4, 96 ) & ( 1<<8 ) )
         {
              g_Bomb = C4
              g_fExplodeTime = get_pdata_float( g_Bomb, 100 )
              EnableHamForward( g_BombThink )
         }
    }
}
public Bomb_Think( iEnt )
{
    if ( g_Bomb != iEnt )
         return
 
    new Float:fTime, iTime, Float:fThinkTime
 
    fTime = g_fExplodeTime - halflife_time()
    iTime = floatround( fTime )
 
    if ( iTime > 13 ) fThinkTime = 1.0
    else if ( iTime > 7 ) fThinkTime = 0.5
    else  fThinkTime = 0.3
    
    create_blast_circle( iEnt )
 
    entity_set_float( iEnt, EV_FL_nextthink, halflife_time() + fThinkTime )
}
public create_blast_circle( iEnt ) {
    new Float:fOrigin[ 3 ]
 
    pev( iEnt, pev_origin, fOrigin )
 
    new szColor[ 12 ], iColor[ 3 ]
    get_pcvar_string( g_pCvarColor, szColor, charsmax( szColor ) )
 
    iColor[ 2 ] = str_to_num( szColor[ 6 ] )
 
    szColor[ 6 ] = 0
    iColor[ 1 ] = str_to_num( szColor[ 3 ] )
 
    szColor[ 3 ] = 0
    iColor[ 0 ] = str_to_num( szColor[ 0 ] )
 
    engfunc( EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, fOrigin )
    write_byte( TE_BEAMCYLINDER )
    engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] )
    engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] )
    engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] )
    engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] )
    engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] )
    engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] + 125 )
    write_short( g_SpriteCircle )
    write_byte( 0 )
    write_byte( 1 )
    write_byte( 6 )
    write_byte( 8 )
    write_byte( 1 )
    write_byte( iColor[ 0 ] )
    write_byte( iColor[ 1 ] )
    write_byte( iColor[ 2 ] )
    write_byte( 128 )
    write_byte( 5 )
    message_end()
}
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Mxnn
Veteran Member
Join Date: Aug 2009
Location: AT MY HOME
Old 11-02-2010 , 21:41   Re: can someone fix my plugin
Reply With Quote #2

Tell us what's the plugin's problem
Mxnn is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-02-2010 , 21:42   Re: can someone fix my plugin
Reply With Quote #3

Just look at ConnorMcLeod's post .
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-02-2010 , 21:55   Re: can someone fix my plugin
Reply With Quote #4

Basically, don't set EV_FL_nextthink.
Use a global variable to save next think time and check that variable each think to see if it's time for a blast to be created.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-02-2010 , 21:55   Re: can someone fix my plugin
Reply With Quote #5

Code additions or changed highlighted :

Code:
new Float:g_flNextBlastGameTime public PlantedBomb() {     new C4 = FM_NULLENT     while( ( C4 = find_ent_by_class( C4, "grenade" ) ) )     {          if ( get_pdata_int( C4, 96 ) & ( 1<<8 ) )          {               g_Bomb = C4               g_fExplodeTime = get_pdata_float( g_Bomb, 100 )               EnableHamForward( g_BombThink )               // added line :               g_flNextBlastGameTime = 0.0 // blast at next think               break // don't search anymore          }     } } public Bomb_Think( iEnt ) {     if ( g_Bomb != iEnt )          return       // cache get_gametime() result here, we need it 2 times     new Float:flGameTime = get_gametime()     if( g_flNextBlastGameTime < flGameTime )     {         return     }     new Float:fTime, iTime, Float:fThinkTime     fTime = g_fExplodeTime - flGameTime     iTime = floatround( fTime )       if ( iTime > 13 ) fThinkTime = 1.0     else if ( iTime > 7 ) fThinkTime = 0.5     else  fThinkTime = 0.3     g_flNextBlastGameTime = flGameTime + fThinkTime         create_blast_circle( iEnt )     // don't change this        //entity_set_float( iEnt, EV_FL_nextthink, halflife_time() + fThinkTime ) }
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-02-2010 , 22:18   Re: can someone fix my plugin
Reply With Quote #6

thx all, today I test the old code, and understand why don't set EV_FL_nextthink !

and a new question, get_gametime() and halflife_time() , Is it the same ?

edit:
Code:
   if( g_flNextBlastGameTime < flGameTime )
    {
        return
    }
==>
Code:
   if( g_flNextBlastGameTime > flGameTime )
    {
        return
    }


right ?
__________________
QQ:116268742

Last edited by K.K.Lv; 11-02-2010 at 22:49.
K.K.Lv is offline
Send a message via MSN to K.K.Lv
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-02-2010 , 22:56   Re: can someone fix my plugin
Reply With Quote #7

It's the same excepted that get_gametime() is from amxx and halflife_time from engine module.

WIKI can be usefull for such questions : http://www.amxmodx.org/funcwiki.php
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-02-2010 , 23:04   Re: can someone fix my plugin
Reply With Quote #8

i add this line to test it ,
but the value lower than zero !
why ?

Code:
if( g_flNextBlastGameTime < flGameTime )
    {
        client_print( 0, print_center, "%f", g_flNextBlastGameTime - flGameTime )
        return
    }
it show me "-XX.XX"
and not blast to be showed
__________________
QQ:116268742

Last edited by K.K.Lv; 11-02-2010 at 23:07.
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Voi
Veteran Member
Join Date: Sep 2006
Location: Gdansk, Poland
Old 11-02-2010 , 23:51   Re: can someone fix my plugin
Reply With Quote #9

Because when g_flNextBlastGameTime is lower than flGameTime you print g_flNextBlastGameTime - flGameTime. :p
__________________
Voi is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-03-2010 , 00:20   Re: can someone fix my plugin
Reply With Quote #10

By the way, ConnorMcLeod got it backwards.
It should be
Code:
if( g_flNextBlastGameTime > flGameTime ) {     return; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 18:20.


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