AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Index out of bounds on set_view. (https://forums.alliedmods.net/showthread.php?t=94207)

xbatista 06-08-2009 03:18

Index out of bounds on set_view.
 
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);



Sylwester 06-08-2009 03:35

Re: Index out of bounds on set_view.
 
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
    }
//....



xPaw 06-08-2009 03:42

Re: Index out of bounds on set_view.
 
PHP Code:

#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxplayers ) 

This 1, or just check is_user_alive

xbatista 06-08-2009 04:29

Re: Index out of bounds on set_view.
 
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;



Sn!ff3r 06-08-2009 05:18

Re: Index out of bounds on set_view.
 
Just use
PHP Code:

is_user_connected(id

.

Quote:

#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxplayers )
Oh no, what with declare g_iMaxplayers variable ? ;)

xbatista 06-08-2009 05:30

Re: Index out of bounds on set_view.
 
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 : :crab: :crab: :crab:

xPaw 06-08-2009 06:13

Re: Index out of bounds on set_view.
 
Quote:

Originally Posted by Sn!ff3r (Post 844106)
Oh no, what with declare g_iMaxplayers variable ? ;)

g_iMaxplayers = get_maxplayers( );

xbatista 06-08-2009 06:17

Re: Index out of bounds on set_view.
 
I know :]]]]]]]]]]]]]

Jon 06-08-2009 18:25

Re: Index out of bounds on set_view.
 
Quote:

Originally Posted by xPaw (Post 844071)
PHP Code:

#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxplayers ) 


Why have people started doing this instead of is_user_connected()? :crab:

Bugsy 06-08-2009 19:55

Re: Index out of bounds on set_view.
 
Quote:

Originally Posted by Jon (Post 844548)
Why have people started doing this instead of is_user_connected()? :crab:

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.


All times are GMT -4. The time now is 13:57.

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