Raised This Month: $ Target: $400
 0% 

Index out of bounds on set_view.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 06-08-2009 , 03:18   Index out of bounds on set_view.
Reply With Quote #1

I don't have now logs, but i don't understand why it writes index out of bounds(on set_view/invalid player)? I'm doing it for 1 specified client

PHP Code:
public TaskFinishHeal2(client)
{
    if( 
pev_valid(g_ent[client]) )
    {
        
engfunc(EngFunc_RemoveEntityg_ent[client]);
        
g_ent[client] = 0;
    }
    
//    new target = g_target[client];
        
    
new Float:health;
    
pev(clientpev_healthhealth);
    if( 
health 100.0 
    {
        
set_pev(clientpev_healthHEALTH_SET);
    }
            
    
ManageBar(clientBAR_REMOVE);
            
    
g_healing[client] = false;
//    g_target[client] = 0;
            
//    g_being_healed[target] = false;
//    g_healer[target] = 0;
            
    
g_Player_Item_Picked[client] = false;
            
    
set_view(client,CAMERA_NONE);

__________________
xbatista is offline
Send a message via Skype™ to xbatista
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-08-2009 , 03:35   Re: Index out of bounds on set_view.
Reply With Quote #2

Where and how do you use this function/set this task? Show more code.

EDIT: you can try:
PHP Code:
public TaskFinishHeal2(client)
{
    if(
client<|| client>g_max_players)
    {
        
log_amx("Trying to call TaskFinishHeal2 with invalid client id (%d)"client)
        return
    }
//....

__________________
Impossible is Nothing

Last edited by Sylwester; 06-08-2009 at 03:41.
Sylwester is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 06-08-2009 , 03:42   Re: Index out of bounds on set_view.
Reply With Quote #3

PHP Code:
#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxplayers ) 
This 1, or just check is_user_alive
__________________
xPaw is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 06-08-2009 , 04:29   Re: Index out of bounds on set_view.
Reply With Quote #4

Where I'm doing set_task there are #define IsPlayer(%1) ( 1 <= %1 <= g_iMaxplayers )
In TaskFinish2 no, so this is a problem?

I mean do it too in task:
PHP Code:
public TaskFinishHeal2(client)
{
    if( !(
<= client <= g_max_clients) || !g_alive[client] ) return PLUGIN_CONTINUE;
    
    if( 
pev_valid(g_ent[client]) )
    {
        
engfunc(EngFunc_RemoveEntityg_ent[client]);
        
g_ent[client] = 0;
    }
    
    new 
target g_target[client];
        
    new 
Float:health;
    
pev(clientpev_healthhealth);
    if( 
health 100.0 
    {
        
set_pev(clientpev_healthHEALTH_SET);
    }
            
    
ManageBar(clientBAR_REMOVE);
            
    
g_healing[client] = false;
//    g_target[client] = 0;
            
    
g_being_healed[target] = false;
//    g_healer[target] = 0;
            
    
g_Player_Item_Picked[client] = false;
            
    
set_view(client,CAMERA_NONE);
    
    return 
PLUGIN_CONTINUE;

__________________

Last edited by xbatista; 06-08-2009 at 04:38.
xbatista is offline
Send a message via Skype™ to xbatista
Sn!ff3r
Veteran Member
Join Date: Aug 2007
Location: Poland
Old 06-08-2009 , 05:18   Re: Index out of bounds on set_view.
Reply With Quote #5

Just use
PHP Code:
is_user_connected(id
.

Quote:
#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxplayers )
Oh no, what with declare g_iMaxplayers variable ? ;)
__________________
Join US - custom Zombie Server - Custom Addons:



Sn!ff3r is offline
Send a message via Skype™ to Sn!ff3r
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 06-08-2009 , 05:30   Re: Index out of bounds on set_view.
Reply With Quote #6

I know

So now seem no problems when I check if is a player, I'll post if they're any errors again.
Thanks all here you some crabs :
__________________
xbatista is offline
Send a message via Skype™ to xbatista
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 06-08-2009 , 06:13   Re: Index out of bounds on set_view.
Reply With Quote #7

Quote:
Originally Posted by Sn!ff3r View Post
Oh no, what with declare g_iMaxplayers variable ? ;)
g_iMaxplayers = get_maxplayers( );
__________________
xPaw is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 06-08-2009 , 06:17   Re: Index out of bounds on set_view.
Reply With Quote #8

I know :]]]]]]]]]]]]]
__________________
xbatista is offline
Send a message via Skype™ to xbatista
Jon
Veteran Member
Join Date: Dec 2007
Old 06-08-2009 , 18:25   Re: Index out of bounds on set_view.
Reply With Quote #9

Quote:
Originally Posted by xPaw View Post
PHP Code:
#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxplayers ) 
Why have people started doing this instead of is_user_connected()?
Jon is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-08-2009 , 19:55   Re: Index out of bounds on set_view.
Reply With Quote #10

Quote:
Originally Posted by Jon View Post
Why have people started doing this instead of is_user_connected()?
This isn't a replacement for is_user_connected(). It checks to see if the value inputted is a player; valid player-id's range from 1 to MaxPlayers.
__________________

Last edited by Bugsy; 06-08-2009 at 19:58.
Bugsy 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 13:57.


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