AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   cs_get_user_team error (HELP) (https://forums.alliedmods.net/showthread.php?t=329700)

Id0x. 01-04-2021 06:06

cs_get_user_team error (HELP)
 
Code:

L 01/04/2021 - 06:38:38: [CSTRIKE] Invalid player 8 (not in-game)
L 01/04/2021 - 06:38:38: [AMXX] Displaying debug trace (plugin "best_player.amxx", version "1.0")
L 01/04/2021 - 06:38:38: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 01/04/2021 - 06:38:38: [AMXX]    [0] phpFFGgcW.sma::hamTakeDamage (line 33)

Code:

L 01/04/2021 - 06:38:55: [CSTRIKE] Invalid player 8 (not in-game)
L 01/04/2021 - 06:38:55: [AMXX] Displaying debug trace (plugin "best_player.amxx", version "1.0")
L 01/04/2021 - 06:38:55: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 01/04/2021 - 06:38:55: [AMXX]    [0] phpFFGgcW.sma::EventDeathMsg (line 45)

PHP Code:

public hamTakeDamage(victiminflictorattackerFloat:damageDamageBits)
{
    if( 
<= attacker <= 32)
    {
        if(
cs_get_user_team(victim) != cs_get_user_team(attacker))
            
g_iDmg[attacker] += floatround(damage)
        else 
g_iDmg[attacker] -= floatround(damage)
    }


PHP Code:

public EventDeathMsg()  
{  
    new 
killer read_data(1)  
    new 
victim read_data(2)  
    new 
is_hs read_data(3)  
      
    if(
killer != victim && killer && cs_get_user_team(killer) != cs_get_user_team(victim))  
    {  
        
g_iKills[killer]++;  
          
        if(
is_hs)  
            
g_iHS[killer]++;  
    }  
    else 
g_iKills[killer]--;  


Line 33 :
PHP Code:

if(cs_get_user_team(victim) != cs_get_user_team(attacker)) 

Line 45 :
PHP Code:

if(killer != victim && killer && cs_get_user_team(killer) != cs_get_user_team(victim)) 


Natsheh 01-04-2021 06:34

Re: cs_get_user_team error (HELP)
 
check if user ("attacker") is connected.

OciXCrom 01-04-2021 07:35

Re: cs_get_user_team error (HELP)
 
Always check if the player is connected before using "cs_get_user_team".

Bugsy 01-04-2021 22:13

Re: cs_get_user_team error (HELP)
 
I wouldn't say you'd always need to check if a player is connected before calling cs_get_user_team().

In scenarios where the player could be disconnected at the time it is called would be appropriate. A good example would be for the killer in a take damage or death event since this could result from a grenade throw and they disconnect immediately after, subsequently killing someone. But in a take damage event, the victim cannot be disconnected so calling it would be a waste.


All times are GMT -4. The time now is 14:07.

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