AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Attempting to fix Raptor Mod-Index Out of Bounds (https://forums.alliedmods.net/showthread.php?t=87610)

fang 03-14-2009 11:19

Attempting to fix Raptor Mod-Index Out of Bounds
 
Code causing errors:
PHP Code:

new raptorreallife get_user_health(id);
        new 
raptorinvis = ((raptorreallife*100)/(raptorlife));
        
set_hudmessage(25525500.020.8706.01.0)
        
show_hudmessage(id"Invisibility:%d/100^n Health: %d"raptorinvisraptorreallife)
        
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha, (raptorinvisi-(raptorinvis*2))) 

Log:
Quote:

L 03/04/2009 - 17:50:37: [AMXX] Displaying debug trace (plugin "revoraptor5.amxx")
L 03/04/2009 - 17:50:37: [AMXX] Run time error 11: divide
L 03/04/2009 - 17:50:37: [AMXX] [0] revoraptor5.sma::client_PreThink (line 444)
Anyone know how to fix it? I've got everything else fixed and running so far but this. :|



New Issue:


Okay, after some more debugging I've discovered another issue.

PHP Code:

    if(israptor[attacker]!=&& attacker!=id && is_user_alive(attacker)){
        new 
victimhealth get_user_health(id)
        
set_user_health(idvictimhealth-raptordomage)
        new 
Float:vVel[3]
        for(new 
0;<= 2;i++)
        
vVel[i] = random_float(-10.0,10.0)            
        
entity_set_vector(id,EV_VEC_punchangle,vVel)
        
pain(id)
    } 

Error Log:

Quote:

L 03/15/2009 - 15:12:20: [AMXX] Displaying debug trace (plugin "revoraptor5.amxx")
L 03/15/2009 - 15:12:20: [AMXX] Run time error 4: index out of bounds
L 03/15/2009 - 15:12:20: [AMXX] [0] revoraptor5.sma::damaging (line 340)
Much appreciated if someone could help me out with this issue. I've just finished fixing the gun menu and this came up so I'm not quite sure on how to fix it.

ConnorMcLeod 03-14-2009 11:22

Re: Attempting to fix Raptor Mod, Getting 'Divide' Error.
 
I don't know what is this 'raptorlife' var, may be you could link to the plugin.
Anyway you can try to replace :

new raptorinvis = ((raptorreallife*100)/(raptorlife));

with

new raptorinvis = ((raptorreallife*100)/( max(1, raptorlife) ));

This would avoid dividing by 0

fang 03-14-2009 11:26

Re: Attempting to fix Raptor Mod, Getting 'Divide' Error.
 
Original plugin:
http://forums.alliedmods.net/showthr...ght=raptor+mod

I'll give your fix a shot and post back if it's still giving me errors. Thanks for the help so far :o

One 03-14-2009 20:12

Re: Attempting to fix Raptor Mod, Getting 'Divide' Error.
 
lol this is a buggy plugin, but if u can fix this, please give me the sma. i have this running on ma server.

fang 03-15-2009 18:39

Re: Attempting to fix Raptor Mod, New Error after fixing 'Divide'.
 
One:
Uhm.. Let's just say it's 'running' but it's not.. quite the same anymore. I've changed quite a lot of things.

And Connor your fix worked perfectly. The only issue is another error has come up. I've edited the main post with the error'd code and debug log.

One 03-15-2009 19:33

Re: Attempting to fix Raptor Mod, New Error after fixing 'Divide'.
 
hmmm :mrgreen:
Offtopic : would u release the code or not? i mean after this is finished?i tried 1 time to fix this but i found there only bugs & i tried 2 4get it.
http://forums.alliedmods.net/showthread.php?t=85503 << first i had problems with the model & after this comes more & more & more bugs :mrgreen:

fang 03-15-2009 20:30

Re: Attempting to fix Raptor Mod, New Error after fixing 'Divide'.
 
Well I'm working one step at a time. Debug and then decide what to do with it after it's completed. For now I don't plan on releasing it due to it not being close to the finished product of what I plan it to be.

ConnorMcLeod 03-16-2009 02:35

Re: Attempting to fix Raptor Mod-Index Out of Bounds
 
PHP Code:

    static maxplayer
    
if( !maxplayer maxplayer get_maxplayers()    
    if( (
1<=attacker<=maxplayer) && israptor[attacker]!=&& attacker!=id && is_user_alive(attacker)){
        new 
damage
        
new victimhealth get_user_health(id)
        
damage read_data(2)
        
set_user_health(idvictimhealth-raptordomage)
        new 
Float:vVel[3]
        for(new 
0;<= 2;i++)
        
vVel[i] = random_float(-10.0,10.0)            
        
entity_set_vector(id,EV_VEC_punchangle,vVel)
        
pain(id)
    } 


fang 03-16-2009 14:46

Re: Attempting to fix Raptor Mod-Index Out of Bounds
 
Thanks connor! I'll test it asap.


All times are GMT -4. The time now is 08:55.

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