AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   (native "set_user_health") error (https://forums.alliedmods.net/showthread.php?t=117823)

OM NOM NOM NOM 02-05-2010 01:00

(native "set_user_health") error
 
Everything seems to work just fine, yet my logs say otherwise.

L 01/11/2010 - 12:23:58: [AMXX] Run time error 10 (plugin "om33h.amxx") (native "set_user_health") - debug not enabled!

What did I miss?

PHP Code:

#include <amxmodx>
#include <fun>
#include <hamsandwich>
#define Plugin "om33h"
#define Version "1.2"
#define Author "om"
#define ADMIN_LEVEL ADMIN_LEVEL_A
new cvarhp
public plugin_init()
{
register_plugin(PluginVersionAuthor)
RegisterHam(Ham_Spawn"player""client_spawn"1)
cvar register_cvar("hp_enable""1")
hp register_cvar("hp_extra""100")
}
public 
client_spawn(id)
{
if(
get_pcvar_num(cvar) < 1)
return 
PLUGIN_CONTINUE
if(get_user_flags(id) & ADMIN_LEVEL)
set_user_health(idget_user_health(id) + get_pcvar_num(hp))
return 
PLUGIN_CONTINUE



Firippu 02-05-2010 01:30

Re: (native "set_user_health") error
 
It's giving the 'Invalid player' warning. Everything looks fine to me. A quick fix would be checking if the player is alive before set_user_health takes place.

ConnorMcLeod 02-05-2010 02:21

Re: (native "set_user_health") error
 
In client_spawn check first if the client is alive.

OM NOM NOM NOM 02-05-2010 03:47

Re: (native "set_user_health") error
 
Thanks, going to try it in a moment.

OM NOM NOM NOM 02-05-2010 04:58

Re: (native "set_user_health") error
 
PHP Code:

#include < amxmodx >
#include < fun >
#include < hamsandwich >
#define ADMINS_ONLY
#define ADMIN_LEVEL ADMIN_LEVEL_A
new const Version[ ] = "1.3"
new cvarhp
public plugin_init( )
{
register_plugin("Premium health pack"Version"om");
RegisterHamHam_Spawn"player""HamPlayerSpawnPost");
 
cvar register_cvar"hp_enable""1" );
hp register_cvar"hp_extra""25" );
}
 
public 
HamPlayerSpawnPostid )
{
if( 
get_pcvar_numcvar ) ) 
{
if( 
is_user_aliveid ) ) {
#if defined ADMINS_ONLY
if ( !(get_user_flagsid ) & ADMIN_LEVEL ) )
return 
PLUGIN_HANDLED;
#endif 
set_user_healthidget_user_healthid ) + get_pcvar_numhp ) );
}
}
return 
PLUGIN_CONTINUE;



Arkshine 02-05-2010 05:58

Re: (native "set_user_health") error
 
You can do directly :

Code:
public HamPlayerSpawnPost( id ) {     if ( get_pcvar_num( cvar ) && is_user_alive( id ) )     {         #if defined ADMINS_ONLY         if ( !(get_user_flags( id ) & ADMIN_LEVEL ) )             return PLUGIN_HANDLED;         #endif                 set_user_health( id, get_user_health( id ) + get_pcvar_num( hp ) );     }     return PLUGIN_CONTINUE; }


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

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