AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Invalid player errors (https://forums.alliedmods.net/showthread.php?t=204984)

F0RCE 01-05-2013 13:30

Invalid player errors
 
Hello, I have some weird player errors in Zombie Plague.

PHP Code:

L 01/05/2013 10:36:21: [ZPInvalid Player (4)
L 01/05/2013 10:36:21: [AMXXDisplaying debug trace (plugin "zp50_item_infection_bomb.amxx")
L 01/05/2013 10:36:21: [AMXXRun time error 10native error (native "zp_core_infect")
L 01/05/2013 10:36:21: [AMXX]    [0zp50_item_infection_bomb.sma::infection_explode (line 323)
L 01/05/2013 10:36:21: [AMXX]    [1zp50_item_infection_bomb.sma::fw_ThinkGrenade (line 264

And here are functions :

PHP Code:

// Ham Grenade Think Forward
public fw_ThinkGrenade(entity)
{
    
// Invalid entity
    
if (!pev_valid(entity)) return HAM_IGNORED;
    
    
// Get damage time of grenade
    
static Float:dmgtime
    pev
(entitypev_dmgtimedmgtime)
    
    
// Check if it's time to go off
    
if (dmgtime get_gametime())
        return 
HAM_IGNORED;
    
    
// Check if it's one of our custom nades
    
switch (pev(entityPEV_NADE_TYPE))
    {
        case 
NADE_TYPE_INFECTION// Infection Bomb
        
{
            
infection_explode(entity// 264 line
            
return HAM_SUPERCEDE;
        }
    }
    
    return 
HAM_IGNORED;


PHP Code:


// Infection Bomb Explosion
infection_explode(ent)
{
    
// Round ended
    
if (zp_gamemodes_get_current() == ZP_NO_GAME_MODE)
    {
        
// Get rid of the grenade
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
    
// Get origin
    
static Float:origin[3]
    
pev(entpev_originorigin)
    
    
// Make the explosion
    
create_blast(origin)
    
    
// Infection nade explode sound
    
static sound[SOUND_MAX_LENGTH]
    
ArrayGetString(g_sound_grenade_infect_exploderandom_num(0ArraySize(g_sound_grenade_infect_explode) - 1), soundcharsmax(sound))
    
emit_sound(entCHAN_WEAPONsound1.0ATTN_NORM0PITCH_NORM)
    
    
// Get attacker
    
new attacker pev(entpev_owner)
    
    
// Infection bomb owner disconnected or not zombie anymore?
    
if (!is_user_connected(attacker) || !zp_core_is_zombie(attacker))
    {
        
// Get rid of the grenade
        
engfunc(EngFunc_RemoveEntityent)
        return;
    }
    
    
// Collisions
    
new victim = -1
    
    
while ((victim engfunc(EngFunc_FindEntityInSpherevictimoriginNADE_EXPLOSION_RADIUS)) != 0)
    {
        
// Only effect alive humans
        
if (!is_user_alive(victim) || zp_core_is_zombie(victim))
            continue;
        
        
// Last human is killed
        
if (zp_core_get_human_count() == 1)
        {
            
ExecuteHamB(Ham_Killedvictimattacker0)
            continue;
        }
        
        
// Turn into zombie
        
zp_core_infect(victimattacker// 332 line
        
        // Victim's sound
        
ArrayGetString(g_sound_grenade_infect_playerrandom_num(0ArraySize(g_sound_grenade_infect_player) - 1), soundcharsmax(sound))
        
emit_sound(victimCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
    }
    
    
// Get rid of the grenade
    
engfunc(EngFunc_RemoveEntityent)



Anyone know how to fix that?

AngeIII 01-05-2013 14:15

Re: Invalid player errors
 
zp_core_infect native
if you see the native, you see that this happens only if player is died. with your VICTIM_ID is dead.
PHP Code:


public native_core_infect(plugin_idnum_params)
{
    new 
id get_param(1)
    
    if (!
is_user_alive(id))
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid Player (%d)"id)
        return 
false;
    }
    
    if (
flag_get(g_IsZombieid))
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Player already infected (%d)"id)
        return 
false;
    }
    
    new 
attacker get_param(2)
    
    
InfectPlayer(idattacker)
    return 
true;


you can try before turning to zombie check
PHP Code:

if(is_user_alive(victim))
{
        
// Turn into zombie
        
zp_core_infect(victimattacker// 332 line
}
else
{
        continue;


why you need to double check if is_user_alive i can't answer.. maybe cause from first line to this line passed a some time when player get killed..


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

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