AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Player out of range (0) (https://forums.alliedmods.net/showthread.php?t=224053)

GhostMan 08-19-2013 16:11

Player out of range (0)
 
Quote:

L 08/18/2013 - 22:22:01: [CSTRIKE] Player out of range (0)
L 08/18/2013 - 22:22:01: [AMXX] Displaying debug trace (plugin "jb_days_box_open.amxx")
L 08/18/2013 - 22:22:01: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 08/18/2013 - 22:22:01: [AMXX] [0] jb_days_box_open.sma::fw_player_killed (line 286)
PHP Code:

public fw_player_killed(victimkillershouldgib)
{            
    switch(
g_SpecDay)
    {
        case 
8:
        {
            new 
CsTeams:vteam cs_get_user_team(victim)
            new 
CsTeams:kteam cs_get_user_team(killer)
            
            if(
IsPlayer(killer) && victim != killer && is_user_alive(killer) && vteam != kteam && kteam == CS_TEAM_T && vteam == CS_TEAM_CT)
            {
                if(
get_user_health(killer) < 200)
                {
                    
set_user_health(killermin(get_user_health(killer) + 50200))
                    
client_print_color(killerkiller"%s You got ^3+50 HP ^1for killing an opponent"PREFIX)
                }
                else
                {
                    
client_print_color(killerkiller"%s You already have ^3200 HP^1, that is the maximum amount."PREFIX)
                }
            }
        }
    }


286 line is this one
PHP Code:

            new CsTeams:kteam cs_get_user_team(killer


Black Rose 08-19-2013 16:19

Re: Player out of range (0)
 
if ( ! is_user_connected(killer) || ! is_user_connected(victim) )
return;

simanovich 08-19-2013 17:07

Re: Player out of range (0)
 
The killer is the world (index = 0) (trigger_hurt, fall, etc.)

GhostMan 08-19-2013 17:26

Re: Player out of range (0)
 
Quote:

Originally Posted by simanovich (Post 2017487)
The killer is the world (index = 0) (trigger_hurt, fall, etc.)

I'v though i have IsPlayer part for that but apparently it's incorrect.

Now it is
PHP Code:

#define IsPlayer(%0)    (1 <= (%0) <= g_iMaxPlayers) 

Should it be
PHP Code:

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

or something?

By the way, that does that %0 (or %1) part means?

^SmileY 08-19-2013 19:52

Re: Player out of range (0)
 
anyway its the same, youre registred g_iMaxPlayers in plugin_init?

Black Rose 08-20-2013 00:07

Player out of range (0)
 
The define is correct but you're calling it too late. It has to be before cs_get_user_team().

yokomo 08-20-2013 04:01

Re: Player out of range (0)
 
No need to use IsPlayer just use is_user_alive(killer):

PHP Code:

public fw_player_killed(victimkillershouldgib)
{
    if(!
is_user_alive(killer)) return; //User die, so no ++ hp for him.
    
    //Do your next code




All times are GMT -4. The time now is 15:49.

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