Пару багов есть в плагине хз как исправить
1. Когда игрок заходит на сервер, он сможет начать играть только после начала нового раунда, рестарта
2. При переходе в спектры автоматически ресается и никого нельзя убить, а тебя может валить не только враг но и союзник :)
Код:
/* last update 1/15/14 */
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#define RESPAWNDELAY 3 // delay before respawn
// ===========
new giDelay
new Float:gflDelay
new gMsgBarTime
new giMaxPlayers
new bool:giBlockRespawn // whether respawn process should be blocked for now
new giInDelay // whether respawn process was started
#define CheckInDelay(%1) ( giInDelay & ( 1 <<( %1-1 ) ) )
#define SetInDelay(%1) ( giInDelay |= ( 1 <<( %1-1 ) ) )
#define ClearInDelay(%1) ( giInDelay &= ~( 1 <<( %1-1 ) ) )
public plugin_init() {
register_plugin( "Respawn", "0.3", "fl0wer / Safety1st" )
gMsgBarTime = get_user_msgid( "BarTime" )
giDelay = RESPAWNDELAY
gflDelay = float( RESPAWNDELAY )
giMaxPlayers = get_maxplayers()
register_event( "HLTV", "NewRound", "a", "1=0", "2=0" )
register_event( "TextMsg", "CancelRespawn", "a", "2=#Game_will_restart_in", "2=#Game_Commencing" )
register_logevent( "CancelRespawn", 2, "1=Round_End" )
RegisterHam( Ham_Killed, "player", "FwdKilled" )
}
public FwdKilled(id) {
if( giBlockRespawn )
return
//client_print( id, print_center, "%L", id, "RESPAWN_MSG", giDelay )
message_begin( MSG_ONE_UNRELIABLE, gMsgBarTime, _, id )
write_short( giDelay )
message_end()
set_task( gflDelay, "Respawn", id )
SetInDelay(id)
}
public Respawn(id) {
switch( cs_get_user_team(id) ) {
case CS_TEAM_T, CS_TEAM_CT : {
ExecuteHamB( Ham_CS_RoundRespawn, id )
ClearInDelay(id)
}
}
}
public client_disconnect(id) {
if( CheckInDelay(id) ) {
remove_task(id)
ClearInDelay(id)
}
}
public CancelRespawn() {
giBlockRespawn = true
if( !giInDelay ) // no one is scheduled to be respawned
return
for( new i = 0; i < giMaxPlayers; i++ ) {
if( CheckInDelay(i) )
remove_task(i)
}
giInDelay = 0 // completely reset the value
}
public NewRound() {
giBlockRespawn = false
}