Veteran Member
Join Date: Jan 2016
Location: Romania
|
12-01-2016
, 11:55
HH plugin problems.
|
#1
|
I'm working on a new plugin, when you kiill somebody a red heart entity will be respawned on that place, if somebody 'touch' the heart, the entity is removed and that guy take +1 lives, wich he can use that heart to respawn.
The problem itself is that when i Open my server the server is crashing, i have no idea why.
( Note: I have no errors in the log. )
PHP Code:
#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <engine>
#include <nvault>
#include <hamsandwich>
new const PLUGIN[] = "Heart Lives";
new const VERSION[] = "1.0";
new const AUTHOR[] = "Craxor";
new const szHealthModel[] = "models/w_hh.mdl";
new const szTouchSound[] = "sound/flamethrower.wav";
new gHealthEntity[] = "health_heart_entitty";
new gLives[33], gAuthId[35][33], gVault;
new const VName[] = "heart_respawn_vault";
public plugin_init( )
{
register_plugin
(
PLUGIN,
VERSION,
AUTHOR
);
register_event( "DeathMsg","Event_DeathMsg","a" );
register_logevent( "LOGEvent_Round_Start", 2, "1=Round_Start" );
register_forward( FM_Touch, "forward_FM_Touch" );
gVault = nvault_open( VName )
if( gVault == INVALID_HANDLE )
set_fail_state( "Problems openning 'heart_respawn_vault' file." );
register_clcmd( "say /respawn", "respawn_hook" );
register_clcmd( "say_team /respawn", "respawn_hook" );
register_clcmd( "say /lives", "lives_hook" );
register_clcmd( "say_team /lives", "lives_hook" );
}
public lives_hook( id )
{
client_print( id , print_chat, "Lives to use: %i", gLives[id] );
return PLUGIN_HANDLED;
}
public respawn_hook( id )
{
if( !is_user_alive( id ) )
{
if( gLives[ id ] > 0 )
{
ExecuteHam( Ham_CS_RoundRespawn, id );
gLives[ id ]--;
}
else
client_print( id , print_chat , "You need at least one life to respawn!" );
}
else
client_print( id, print_chat, "You already are dead, use this command when you're dead!" );
return PLUGIN_HANDLED;
}
public plugin_precache()
{
precache_model( szHealthModel );
precache_sound( szTouchSound );
}
public Event_DeathMsg( )
{
new iV = read_data( 2 );
static FLoat:flOrigin[3];
pev( iV, pev_origin, flOrigin );
new iEnt = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) );
engfunc( EngFunc_SetOrigin, iEnt, flOrigin );
if( !pev_valid( iEnt ) )
{
return PLUGIN_HANDLED;
}
set_pev( iEnt, pev_classname, gHealthEntity );
engfunc( EngFunc_SetModel, iEnt, szHealthModel );
dllfunc( DLLFunc_Spawn, iEnt );
set_pev( iEnt, pev_solid, SOLID_BBOX );
set_pev( iEnt, pev_movetype, MOVETYPE_NONE );
engfunc( EngFunc_SetSize, iEnt, Float:{ -23.160000, -13.660000, -0.050000 }, Float:{ 11.470000, 12.780000, 6.720000 } );
engfunc( EngFunc_DropToFloor, iEnt );
return PLUGIN_HANDLED;
}
public forward_FM_Touch( iEnt, id )
{
if( !pev_valid( iEnt ) )
return FMRES_IGNORED;
new szClassname[ 32 ];
pev( iEnt, pev_classname, szClassname, charsmax( szClassname ) );
if( !equal( szClassname, gHealthEntity) )
{
return FMRES_IGNORED;
}
gLives[ id ]++;
emit_sound( id, CHAN_ITEM, szTouchSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
engfunc( EngFunc_RemoveEntity, iEnt );
return FMRES_IGNORED;
}
public LOGEvent_Round_Start( )
{
new iEntity = -1;
while( ( iEntity = find_ent_by_class( iEntity, gHealthEntity ) ) )
{
engfunc( EngFunc_RemoveEntity, iEntity );
}
}
public client_authorized( id )
{
// Anyways, bots have steamid as "BOT".
if( !is_user_bot( id ) )
{
get_user_authid( id, gAuthId[id], charsmax( gAuthId ) );
new szData[11], iTs;
if( nvault_lookup( gVault, gAuthId[id], szData, charsmax( szData ), iTs ) )
gLives[ id ] = str_to_num( szData );
}
}
public client_disconnect( id )
{
new szData[11];
num_to_str( gLives[id] , szData , charsmax( szData ) );
nvault_set( gVault, gAuthId[id], szData );
}
public plugin_end( ) nvault_close( gVault )
__________________
Project: Among Us
|
|