HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /**
  2.  *
  3.  * Ghost Respawning
  4.  *
  5.  * ================
  6.  * ================
  7.  *
  8.  * Plugin thread
  9.  * http://forums.alliedmods.net/showthread.php?p=460699
  10.  ******
  11.  * Description
  12.  * Buy a respawn stone by typing /buystone in chat.
  13.  * If you have a stone, you will get respawned
  14.  * as a ghost (transparent) at the place you died.
  15.  ******
  16.  * Cvars
  17.  * ghost_enable <1|0> (default: 1)
  18.  * // Enables or disables the plugin.
  19.  *
  20.  * ghost_cost <money> (default: 10000)
  21.  * // The cost of the stone.
  22.  *
  23.  * ghost_health <health> (default: 50)
  24.  * // Health when the player is a ghost.
  25.  ******
  26.  * Commands
  27.  * say /buystone
  28.  * // Buy a respawn stone
  29.  ******
  30.  * Required modules
  31.  * -> Ham Sandwich
  32.  * -> Fakemeta
  33.  * -> Cstrike
  34.  ******
  35.  * Changelog
  36.  * 1.1
  37.  * [FIXED] Changed the time from 3 to 2 seconds delay
  38.  * before respawn.
  39.  * [FIXED] Total rewrite, using Ham Sandwich for
  40.  * events.
  41.  * 1.05
  42.  * [FIXED] Took away the (id) from event_new_round.
  43.  * You must download the new version in order
  44.  * to get the plugin to work.
  45.  *
  46.  * 1.04
  47.  * [FIXED] Moved the reset of rendering to the new round event.
  48.  * [FIXED] Now it only resets rendering on previous ghosts.
  49.  *
  50.  * 1.03
  51.  * [ADDED] Added that the player hav eto be in buyzone to buy
  52.  * the respawn stone.
  53.  * [FIXED] Fixed the set_task.
  54.  *
  55.  * 1.02
  56.  * [FIXED] The message "type /buystone"... comes at new round
  57.  * instead of round start now.
  58.  * [FIXED] Fixed that more than one person can die without
  59.  * respawning at the same place as the one before.
  60.  *
  61.  * 1.01
  62.  * [FIXED] Quick fix: The rendering will stop at round end.
  63.  *
  64.  * 1.0
  65.  * [RELEASE] Plugin released.
  66.  *******
  67.  * Credits
  68.  * -> Deviance
  69.  * -> VEN
  70. **/
  71.  
  72. #include <amxmodx>
  73. #include <hamsandwich>
  74. #include <fakemeta>
  75. #include <cstrike>
  76.  
  77. new g_pEnable,
  78. g_pCost,
  79. g_pHealth;
  80.  
  81. new Float:g_flOrigin[33][3];
  82.  
  83. new g_iGhostStones[33],
  84. bool:g_bGhost[33];
  85.  
  86. public plugin_init( )
  87. {
  88. register_plugin( "Ujraeledesi ko", "1.1", "MaTTe (magyarositas by protoN)" );
  89.  
  90. g_pEnable = register_cvar("ghost_enable", "1");
  91. g_pCost = register_cvar("ghost_cost", "10000");
  92. g_pHealth = register_cvar("ghost_health", "50");
  93.  
  94. RegisterHam( Ham_Killed, "player", "fwDeath" );
  95. register_event( "HLTV", "evNewRound", "a", "1=0", "2=0" );
  96.  
  97. register_clcmd( "say /korendeles", "cmdBuyStone" );
  98. }
  99.  
  100. public evNewRound( )
  101. {
  102. new iPlayers[ 32 ];
  103. new iNum, iPlayer;
  104. get_players( iPlayers, iNum );
  105.  
  106. for( new i = 0; i < iNum; i++ )
  107. {
  108. iPlayer = iPlayers[ i ];
  109.  
  110. if( g_bGhost[ iPlayer ] )
  111. {
  112. fm_set_rendering( iPlayer );
  113. g_bGhost[ iPlayer ] = false;
  114. }
  115.  
  116. client_print( iPlayer, print_chat, "Ird be a chatbe hogy /korendeles ha szeretnel ujraeledesi kovet rendelni!" );
  117. }
  118. }
  119.  
  120. public fwDeath( id, idattacker )
  121. {
  122. if( get_pcvar_num( g_pEnable ) )
  123. {
  124. if( g_iGhostStones[ id ] )
  125. {
  126. pev( id, pev_origin, g_flOrigin[ id ] );
  127.  
  128. set_task( 3.0, "fnGhostPlayer", id );
  129. }
  130. }
  131. }
  132.  
  133. public fnGhostPlayer( id )
  134. {
  135. if( is_user_alive( id ) )
  136. return;
  137.  
  138. g_bGhost[ id ] = true;
  139. g_iGhostStones[ id ]--;
  140.  
  141. ExecuteHamB( Ham_CS_RoundRespawn, id );
  142.  
  143. g_flOrigin[ id ][ 2 ] += 20.0;
  144. engfunc( EngFunc_SetOrigin, id, g_flOrigin[ id ] );
  145.  
  146. fm_set_rendering( id, kRenderFxNone, 16, 16, 16, kRenderTransAlpha, 16 );
  147.  
  148. set_pev( id, pev_health, float( get_pcvar_num( g_pHealth ) ) );
  149. }
  150.  
  151. public cmdBuyStone(id) {
  152. if( !get_pcvar_num( g_pEnable ) )
  153. return PLUGIN_HANDLED;
  154.  
  155. if( !is_user_alive( id ) )
  156. {
  157. client_print( id, print_chat, "Elned kell hogy ujraeledesi kovet rendelj!" );
  158. return PLUGIN_HANDLED;
  159. }
  160.  
  161. if( !cs_get_user_buyzone( id ) )
  162. {
  163. client_print( id, print_chat, "Muszaj hogy a buyzone teruleten legyel, hogy ujraleledesi kovet rendelj!" );
  164. return PLUGIN_HANDLED;
  165. }
  166.  
  167. new iMoney = cs_get_user_money( id );
  168. new iCost = get_pcvar_num( g_pCost );
  169.  
  170. if( iMoney < iCost )
  171. {
  172. client_print( id, print_chat, "Nincs eleg penzed hogy ujraeledesi kovet rendelj!" );
  173. return PLUGIN_HANDLED;
  174. }
  175.  
  176. cs_set_user_money( id, iMoney - iCost );
  177. g_iGhostStones[ id ]++;
  178.  
  179. client_print( id, print_chat, "Sikeresen megvetted az ujraeledesi kovet! (%d van a zsebedben)", g_iGhostStones[ id ] );
  180.  
  181. return PLUGIN_HANDLED;
  182. }
  183.  
  184. stock fm_set_rendering( entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16 )
  185. {
  186. new Float:RenderColor[ 3 ];
  187. RenderColor[ 0 ] = float( r );
  188. RenderColor[ 1 ] = float( g );
  189. RenderColor[ 2 ] = float( b );
  190.  
  191. set_pev( entity, pev_renderfx, fx );
  192. set_pev( entity, pev_rendercolor, RenderColor );
  193. set_pev( entity, pev_rendermode, render );
  194. set_pev( entity, pev_renderamt, float( amount ) );
  195.  
  196. return 1;
  197. }