AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Log errors (https://forums.alliedmods.net/showthread.php?t=184631)

Plc0tad0 05-07-2012 06:50

[Help] Log errors
 
PHP Code:

#include <amxmodx>
#include <fun>
#include <cstrike>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("VIPAdd""1.0""Plc0tad0")
    
    
RegisterHam(Ham_Spawn"player""HamPlayerSpawn"1)
}

public 
HamPlayerSpawn(id)
{
    if(
get_user_flags(id) & ADMIN_RESERVATION)
    {
        
strip_user_weapons(id)
        
give_item(id"weapon_knife")
        
give_item(id"weapon_m3")
        
give_item(id"weapon_deagle")
        
give_item(id"weapon_hegrenade")
        
give_item(id"weapon_flashbang")
        
give_item(id"weapon_flashbang")
        
give_item(id"weapon_smokegrenade")
        
cs_set_user_bpammo(idCSW_DEAGLE35)
        
cs_set_user_bpammo(idCSW_M332)
        
set_user_health(id200)
        
set_user_armor(id200)
    }


I'm new in programming so i am still learning. Works, but i get this log error. Whats happened?
Bad english :oops:

Code:

L 05/07/2012 - 10:33:19: Start of error session.
L 05/07/2012 - 10:33:19: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20120507.log")
L 05/07/2012 - 10:33:19: [FUN] Invalid player 1
L 05/07/2012 - 10:33:19: [AMXX] Displaying debug trace (plugin "vipadd.amxx")
L 05/07/2012 - 10:33:19: [AMXX] Run time error 10: native error (native "strip_user_weapons")
L 05/07/2012 - 10:33:19: [AMXX]    [0] vipadd.sma::HamPlayerSpawn (line 17)


hornet 05-07-2012 07:26

Re: [Help] Log errors
 
I know how to fix this, however I'd also like to know exactly why it happens? I can only assume it's some other kind of entity being spawned which is weird because the hook is for players only and post hook too. Explanation anyone? :)

This'll remove that error:

PHP Code:

#include <amxmodx>
#include <fun>
#include <cstrike>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("VIPAdd""1.0""Plc0tad0")
    
    
RegisterHam(Ham_Spawn"player""HamPlayerSpawn"1)
}

public 
HamPlayerSpawn(id)
{
    if( !
is_user_aliveid ) )
        return 
HAM_IGNORED;
    
    if(
get_user_flags(id) & ADMIN_RESERVATION)
    {
        
strip_user_weapons(id)
        
give_item(id"weapon_knife")
        
give_item(id"weapon_m3")
        
give_item(id"weapon_deagle")
        
give_item(id"weapon_hegrenade")
        
give_item(id"weapon_flashbang")
        
give_item(id"weapon_flashbang")
        
give_item(id"weapon_smokegrenade")
        
cs_set_user_bpammo(idCSW_DEAGLE35)
        
cs_set_user_bpammo(idCSW_M332)
        
set_user_health(id200)
        
set_user_armor(id200)
    }
    
    return 
HAM_IGNORED;



wickedd 05-07-2012 07:38

Re: [Help] Log errors
 
Quote:

Originally Posted by hornet (Post 1704083)
I know how to fix this, however I'd also like to know exactly why it happens?

I think it happen because he forgot check
Code:

if ( is_user_alive( id ) )

hornet 05-07-2012 07:42

Re: [Help] Log errors
 
Well yes ultimately that fixes the issue, but being a post hook, wouldn't you assume that the player has already spawned so therefor is alive?

Plc0tad0 05-07-2012 08:02

Re: [Help] Log errors
 
hmmm.. so i need check if user is alive, ok. Thanks a lot.

Quote:

Originally Posted by hornet (Post 1704094)
Well yes ultimately that fixes the issue, but being a post hook, wouldn't you assume that the player has already spawned so therefor is alive?

I agree with you

hornet 05-08-2012 19:21

Re: [Help] Log errors
 
Still wondering if anyone has an explanation as to why this happens ( out of curiosity ) ?


All times are GMT -4. The time now is 00:28.

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