Raised This Month: $ Target: $400
 0% 

Player out of range (0)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GhostMan
Senior Member
Join Date: Jun 2012
Old 06-24-2012 , 19:33   Player out of range (0)
Reply With Quote #1

Quote:
L 06/23/2012 - 20:24:15: [FUN] Player out of range (0)
L 06/23/2012 - 20:24:15: [AMXX] Displaying debug trace (plugin "jb_days_lr.amxx")
L 06/23/2012 - 20:24:15: [AMXX] Run time error 10: native error (native "strip_user_weapons")
L 06/23/2012 - 20:24:15: [AMXX] [0] jb_days_lr.sma::fw_player_killed (line 368 )
PHP Code:
public fw_player_killed(victimattackershouldgib)
{
    new 
name[32]
    
get_user_name(attackername31)
            
    if(
duel_active)
    {
        if(
cs_get_user_team(victim) == CS_TEAM_CT && player_challenged[victim])
        {
            
m3_duel[attacker] = false
            deagle_duel
[attacker] = false
            ump_duel
[attacker] = false
            scout_duel
[attacker] = false
            once
[attacker] = false
            strip_user_weapons
(attacker)
            
give_item(attacker"weapon_knife")
            
set_user_rendering(attacker)
            
duel_menu(attacker)
        }
        else if(
cs_get_user_team(victim) == CS_TEAM_CT && !player_challenged[victim])
        {
            
set_task(0.4"kill_player"attacker)
            
set_hudmessage02550, -1.00.4025.08.00.00.010)
            
show_hudmessage(0"%L"LANG_PLAYER,"DUEL_DOWN"name)
                
        }
    }
    
remove_task(attacker)
    
remove_task(victim)

Line 368
PHP Code:
            strip_user_weapons(attacker
GhostMan is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-24-2012 , 19:39   Re: Player out of range (0)
Reply With Quote #2

When a player is killed by the map ( including by falling ) the attacker id is 0. So you need to run a check to ensure that the attacker is a player.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
GhostMan
Senior Member
Join Date: Jun 2012
Old 06-25-2012 , 06:54   Re: Player out of range (0)
Reply With Quote #3

And how do i do that? Just like that?

PHP Code:
public fw_player_killed(victimattackershouldgib)
{
    new 
name[32]
    
get_user_name(attackername31)
            
    if(
duel_active)
    {
        if(
cs_get_user_team(victim) == CS_TEAM_CT && player_challenged[victim])
        {
            
m3_duel[attacker] = false
            deagle_duel
[attacker] = false
            ump_duel
[attacker] = false
            scout_duel
[attacker] = false
            once
[attacker] = false

            
if(is_user_alive(attacker))
            {
                
strip_user_weapons(attacker)
                
give_item(attacker"weapon_knife")
                
set_user_rendering(attacker)
                
duel_menu(attacker)
            }

        }
        else if(
cs_get_user_team(victim) == CS_TEAM_CT && !player_challenged[victim])
        {
            
set_task(0.4"kill_player"attacker)
            
set_hudmessage02550, -1.00.4025.08.00.00.010)
            
show_hudmessage(0"%L"LANG_PLAYER,"DUEL_DOWN"name)
                
        }
    }
    
remove_task(attacker)
    
remove_task(victim)

Or is_user_alive not checks if its a player? :O
GhostMan is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-25-2012 , 08:06   Re: Player out of range (0)
Reply With Quote #4

You want to check straight away, so your not executing commands that aren't needed.

You can use this concept which is probably the best: !( 1 <= id <= g_iMaxPlayers )

In which case you add these pieces in:
Code:
new g_iMaxPlayers; public plugin_init() {     g_iMaxPlayers = get_maxplayers(); } public fw_player_killed(victim, attacker, shouldgib) {     if( !( 1 <= id <= g_iMaxPlayers ) )         return HAM_IGNORED;     //the rest of the code goes here     return HAM_IGNORED; }
Although, realistically, if your not going to have custom entities that will be inflicting damage to / killing the player, then all you need is this one check in place of the previous example ( without the global variable I added in ):
Code:
if( !attacker )     return HAM_IGNORED;

So if the attacker id is 0, the rest of your function will be ignored.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 06-25-2012 at 08:07.
hornet is offline
GhostMan
Senior Member
Join Date: Jun 2012
Old 06-25-2012 , 10:21   Re: Player out of range (0)
Reply With Quote #5

PHP Code:
if( !( <= id <= g_iMaxPlayers ) ) 
you sure it has to be "id" not "attacker"?
GhostMan is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-25-2012 , 10:40   Re: Player out of range (0)
Reply With Quote #6

Sorry, your right.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Reply


Thread Tools
Display Modes

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 06:17.


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