/**
*
* Ghost Respawning
*
* ================
* ================
*
* Plugin thread
* http://forums.alliedmods.net/showthread.php?p=460699
******
* Description
* Buy a respawn stone by typing /buystone in chat.
* If you have a stone, you will get respawned
* as a ghost (transparent) at the place you died.
******
* Cvars
* ghost_enable <1|0> (default: 1)
* // Enables or disables the plugin.
*
* ghost_cost <money> (default: 10000)
* // The cost of the stone.
*
* ghost_health <health> (default: 50)
* // Health when the player is a ghost.
******
* Commands
* say /buystone
* // Buy a respawn stone
******
* Required modules
* -> Ham Sandwich
* -> Fakemeta
* -> Cstrike
******
* Changelog
* 1.1
* [FIXED] Changed the time from 3 to 2 seconds delay
* before respawn.
* [FIXED] Total rewrite, using Ham Sandwich for
* events.
* 1.05
* [FIXED] Took away the (id) from event_new_round.
* You must download the new version in order
* to get the plugin to work.
*
* 1.04
* [FIXED] Moved the reset of rendering to the new round event.
* [FIXED] Now it only resets rendering on previous ghosts.
*
* 1.03
* [ADDED] Added that the player hav eto be in buyzone to buy
* the respawn stone.
* [FIXED] Fixed the set_task.
*
* 1.02
* [FIXED] The message "type /buystone"... comes at new round
* instead of round start now.
* [FIXED] Fixed that more than one person can die without
* respawning at the same place as the one before.
*
* 1.01
* [FIXED] Quick fix: The rendering will stop at round end.
*
* 1.0
* [RELEASE] Plugin released.
*******
* Credits
* -> Deviance
* -> VEN
**/
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>
new g_pEnable,
g_pCost,
g_pHealth;
new Float:g_flOrigin[33][3];
new g_iGhostStones[33],
bool:g_bGhost[33];
public plugin_init( )
{
register_plugin( "Ujraeledesi ko", "1.1", "MaTTe (magyarositas by protoN)" );
g_pEnable = register_cvar("ghost_enable", "1");
g_pCost = register_cvar("ghost_cost", "10000");
g_pHealth = register_cvar("ghost_health", "50");
RegisterHam( Ham_Killed, "player", "fwDeath" );
register_event( "HLTV", "evNewRound", "a", "1=0", "2=0" );
register_clcmd( "say /korendeles", "cmdBuyStone" );
}
public evNewRound( )
{
new iPlayers[ 32 ];
new iNum, iPlayer;
get_players( iPlayers, iNum );
for( new i = 0; i < iNum; i++ )
{
iPlayer = iPlayers[ i ];
if( g_bGhost[ iPlayer ] )
{
fm_set_rendering( iPlayer );
g_bGhost[ iPlayer ] = false;
}
client_print( iPlayer, print_chat, "Ird be a chatbe hogy /korendeles ha szeretnel ujraeledesi kovet rendelni!" );
}
}
public fwDeath( id, idattacker )
{
if( get_pcvar_num( g_pEnable ) )
{
if( g_iGhostStones[ id ] )
{
pev( id, pev_origin, g_flOrigin[ id ] );
set_task( 3.0, "fnGhostPlayer", id );
}
}
}
public fnGhostPlayer( id )
{
if( is_user_alive( id ) )
return;
g_bGhost[ id ] = true;
g_iGhostStones[ id ]--;
ExecuteHamB( Ham_CS_RoundRespawn, id );
g_flOrigin[ id ][ 2 ] += 20.0;
engfunc( EngFunc_SetOrigin, id, g_flOrigin[ id ] );
fm_set_rendering( id, kRenderFxNone, 16, 16, 16, kRenderTransAlpha, 16 );
set_pev( id, pev_health, float( get_pcvar_num( g_pHealth ) ) );
}
public cmdBuyStone(id) {
if( !get_pcvar_num( g_pEnable ) )
return PLUGIN_HANDLED;
if( !is_user_alive( id ) )
{
client_print( id, print_chat, "Elned kell hogy ujraeledesi kovet rendelj!" );
return PLUGIN_HANDLED;
}
if( !cs_get_user_buyzone( id ) )
{
client_print( id, print_chat, "Muszaj hogy a buyzone teruleten legyel, hogy ujraleledesi kovet rendelj!" );
return PLUGIN_HANDLED;
}
new iMoney = cs_get_user_money( id );
new iCost = get_pcvar_num( g_pCost );
if( iMoney < iCost )
{
client_print( id, print_chat, "Nincs eleg penzed hogy ujraeledesi kovet rendelj!" );
return PLUGIN_HANDLED;
}
cs_set_user_money( id, iMoney - iCost );
g_iGhostStones[ id ]++;
client_print( id, print_chat, "Sikeresen megvetted az ujraeledesi kovet! (%d van a zsebedben)", g_iGhostStones[ id ] );
return PLUGIN_HANDLED;
}
stock fm_set_rendering( entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16 )
{
new Float:RenderColor[ 3 ];
RenderColor[ 0 ] = float( r );
RenderColor[ 1 ] = float( g );
RenderColor[ 2 ] = float( b );
set_pev( entity, pev_renderfx, fx );
set_pev( entity, pev_rendercolor, RenderColor );
set_pev( entity, pev_rendermode, render );
set_pev( entity, pev_renderamt, float( amount ) );
return 1;
}