AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved error 4: index out of bounds (SG Teleport) (https://forums.alliedmods.net/showthread.php?t=336602)

Arje 03-02-2022 11:51

error 4: index out of bounds (SG Teleport)
 
Hi, well i try to make it work when you get sg teleport, but when you don't, make it work like normal smoke

I got it by doing this in the code:

PHP Code:

new bool:gHasBatman[SH_MAXSLOTS+1// its like [MAX_PLAYERS+1];

public plugin_init()
{
      
register_forward(FM_EmitSound"forward_emitsound")
      
register_forward(FM_PlaybackEvent"forward_playbackevent"false)
    
// we do not precaching, but retrieving the indexes
    
g_spriteid_steam1 engfunc(EngFunc_PrecacheModel"sprites/steam1.spr")
    
g_eventid_createsmoke engfunc(EngFunc_PrecacheEvent1"events/createsmoke.sc")
}

public 
forward_playbackevent(flagsinvokereventindex
{    
    if ( !
gHasBatman[invoker] ) return FMRES_IGNORED
    
// we do not need a large amount of smoke 
    
if( eventindex == g_eventid_createsmoke)
        return 
FMRES_SUPERCEDE

    
return FMRES_IGNORED


but I get error 4 every time the SG explodes

HTML Code:

L 03/02/2022 - 13:27:11: [AMXX] Displaying debug trace (plugin "sh_batman.amxx", version "1.2.0.14")
L 03/02/2022 - 13:27:11: [AMXX] Run time error 4: index out of bounds
L 03/02/2022 - 13:27:11: [AMXX]    [0] sh_batman.sma::forward_playbackevent (line 3


Natsheh 03-02-2022 12:23

Re: error 4: index out of bounds (SG Teleport)
 
Most common error, easy to fix, you need to check if you have a valid invoker id.

Code:
    if ( !( invoker && invoker <= SH_MAXSLOTS) || !gHasBatman[invoker] ) return FMRES_IGNORED     //

Arje 03-02-2022 13:00

Re: error 4: index out of bounds (SG Teleport)
 
Hi again! but i proof and it didn't work for me, but after searching more and more posts about this error, I found a solution that works, which is the following:

PHP Code:

public forward_playbackevent(flagsinvokereventindex
{    
    if ( !( 
<= invoker <= 32 ) || !is_user_alive(invoker) ) return FMRES_IGNORED 

    
if ( !gHasBatman[invoker] ) return FMRES_IGNORED 
    
// we do not need a large amount of smoke 
    
if( eventindex == g_eventid_createsmoke)
        return 
FMRES_SUPERCEDE

    
return FMRES_IGNORED     // FMRES_IGNORED 


pd: I made the thread because I saw like 15 posts with the same error and none had a solution but just after posting I found one with a solution for me... but thanks for the time!

Natsheh 03-02-2022 13:08

Re: error 4: index out of bounds (SG Teleport)
 
I made a simple mistake, fixed.


All times are GMT -4. The time now is 12:48.

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