Skocz do zawartości

  • Zaloguj korzystając z Facebooka Zaloguj korzystając z Twittera Zaloguj przez Steam Zaloguj poprzez Google      Logowanie »   
  • Rejestracja

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.

  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

Usuwanie funkcji


  • Zamknięty Temat jest zamknięty
Brak odpowiedzi do tego tematu

#1 kam821

    Początkujący

  • Użytkownik

Reputacja: 1
Nowy

  • Postów:10
Offline

Napisano 14.03.2009 21:35

Czy jest możliwość usunięcia restartu i wiadomości gdy 1 team jest pusty i wbija jakiś gracz jako nowy (Game Connecting).

Przerobiłem DeathRun Managera, żeby przy wyjściu przenosił 1 CT do TT i odradzał go, ale ciągle mam problem z tym restartem samoistnym, a wiadomo, że w Zombie Plague zostało to jakoś zlikwidowane.

Przerobione sma, nie patrcie że jakiś krzywy kod, robiłem żeby w ogóle zobaczyć czy zadziała:
/****************************************/
/*					*/
/*	Deathrun Manager		*/
/*		by xPaw			*/
/*					*/
/*	Original code			*/
/*		by Grim			*/
/****************************************/

/***
 * Link to the plugin
 *
 *	http://forums.alliedmods.net/showthread.php?t=78197
 */

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#pragma semicolon 1

// Plugin Version
#define VERSION	"2.2"
#define TASK_TEAM 2100
#define ID_TEAM (taskid - TASK_TEAM)

// Global Variables
new bool:g_Restart, bool:g_Randromized, bool:g_Starting, bool:g_FirstRound;
new g_iSemiClip[33], g_sv_restart, g_mp_autoteambalance, g_mp_limitteams, bool:g_isEnabled, g_HudSync, g_HudSync2;
new g_Toggle, g_SprayB, g_RadioB, g_Semiclip, g_GiveUsp, g_RemoveBZ, g_HideHud, g_BlockMoney, g_LifeSystem;
new g_Maxplayers, g_msgHideWeapon, g_msgCrosshair, g_msgTeamInfo, g_msgMoney, g_BuyZone, g_Lifes[33], g_MapName[64];
new Float:g_teams_targettime; // for adding delays between Team Change messages
new g_frags[33];
new g_deaths[33];
new g_switchingteam[33]; // is switching team

// Macros
#if cellbits == 32
	#define OFFSET_BZ 235
#else
	#define OFFSET_BZ 268
#endif

new const TEAMNAMES[][] = { "UNASSIGNED", "TERRORIST", "CT", "SPECTATOR" };

enum {
	FM_TEAM_UNASSIGNED,
	FM_TEAM_T,
	FM_TEAM_CT,
	FM_TEAM_SPECTATOR,
	
	FM_TEAM_MAX
};

// =======================================================================================

public plugin_init() {
	register_plugin("Deathrun Manager", VERSION, "xPaw");
	g_Toggle 	= register_cvar("deathrun_toggle",	"1");
	g_SprayB	= register_cvar("deathrun_spray",	"1");
	g_RadioB	= register_cvar("deathrun_radio",	"1");
	g_Semiclip	= register_cvar("deathrun_semiclip",	"1");
	g_GiveUsp	= register_cvar("deathrun_giveusp",	"1");
	g_RemoveBZ	= register_cvar("deathrun_removebz",	"1");
	g_HideHud	= register_cvar("deathrun_hidehud",	"1");
	g_BlockMoney	= register_cvar("deathrun_blockmoney",	"1");
	g_LifeSystem	= register_cvar("deathrun_lifesystem",	"1");
	
	g_sv_restart		= get_cvar_pointer( "sv_restart" );
	g_mp_autoteambalance	= get_cvar_pointer( "mp_autoteambalance" );
	g_mp_limitteams		= get_cvar_pointer( "mp_limitteams" );
	
	register_cvar("deathrun_version",	VERSION, FCVAR_SERVER|FCVAR_SPONLY);
	set_cvar_string("deathrun_version",	VERSION);
	
	// Registering Language file
	register_dictionary( "deathrun.txt" );

	// Logging Events
	register_logevent( "eStartRound", 2, "1=Round_Start" );
	register_logevent( "eRandromize", 2, "1=Round_End" );
	register_event( "SendAudio",	"eTerrWin",	"a",	"2&%!MRAD_terwin" );
	// register_event( "TextMsg",	"eRandromize",	"a",	"2&#Game_w" );
	register_event( "DeathMsg",	"eDeath",	"a");
	register_event( "Money",	"eMoney",	"b" );
	register_event( "ResetHUD",	"eResetHUD",	"be" );
	
	// Forwards
	RegisterHam( Ham_Spawn, "player",	"fwHamPlayerSpawnPost", 1 );
	register_forward( FM_ClientKill,	"fwClientKill" );
	register_forward( FM_CmdStart,		"fwCmdStart" );
	register_forward( FM_GetGameDescription,"fwGameDesc" );
	
	g_FirstRound	= true;
	g_Maxplayers	= get_maxplayers();
	g_msgHideWeapon	= get_user_msgid( "HideWeapon" );
	g_msgCrosshair	= get_user_msgid( "Crosshair" );
	g_msgTeamInfo	= get_user_msgid( "TeamInfo" );
	g_msgMoney	= get_user_msgid( "Money" );
	
	g_HudSync	= CreateHudSyncObj();
	g_HudSync2	= CreateHudSyncObj();
	
	if( get_pcvar_num(g_Toggle) ) {
		// Block all radio commands
		register_clcmd("radio1",	"cmdBlockRadio");
		register_clcmd("radio2",	"cmdBlockRadio");
		register_clcmd("radio3",	"cmdBlockRadio");
		register_clcmd("coverme",	"cmdBlockRadio");
		register_clcmd("takepoint",	"cmdBlockRadio");
		register_clcmd("holdpos",	"cmdBlockRadio");
		register_clcmd("regroup",	"cmdBlockRadio");
		register_clcmd("followme",	"cmdBlockRadio");
		register_clcmd("takingfire",	"cmdBlockRadio");
		register_clcmd("go",		"cmdBlockRadio");
		register_clcmd("fallback",	"cmdBlockRadio");
		register_clcmd("sticktog",	"cmdBlockRadio");
		register_clcmd("getinpos",	"cmdBlockRadio");
		register_clcmd("stormfront",	"cmdBlockRadio");
		register_clcmd("report",	"cmdBlockRadio");
		register_clcmd("roger",		"cmdBlockRadio");
		register_clcmd("enemyspot",	"cmdBlockRadio");
		register_clcmd("needbackup",	"cmdBlockRadio");
		register_clcmd("sectorclear",	"cmdBlockRadio");
		register_clcmd("inposition",	"cmdBlockRadio");
		register_clcmd("reportingin",	"cmdBlockRadio");
		register_clcmd("getout",	"cmdBlockRadio");
		register_clcmd("negative",	"cmdBlockRadio");
		register_clcmd("enemydown",	"cmdBlockRadio");
		
		register_clcmd("say /lifes", "cmdShowlifes");
		register_clcmd("say /lives", "cmdShowlifes");
		
		// Terrorist Check
		set_task(15.0, "eTerrorCheck",0,_,_, "b");
		
		// Lets make restart after 20 seconds from map start.
		set_task(20.0, "fnRestart");
		
		// Lets get map name...
		get_mapname( g_MapName, 63 );
		
		if( get_pcvar_num(g_RemoveBZ) ) {
			register_forward( FM_PlayerPostThink,	"fwPlayerPostThink");
			register_message( get_user_msgid("StatusIcon"), "msgStatusIcon" ); // BuyZone Icon
			
			g_BuyZone = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_buyzone"));
			dllfunc(DLLFunc_Spawn, g_BuyZone);
			engfunc(EngFunc_SetSize, g_BuyZone, {-8192.0, -8192.0, -8192.0}, {-8191.0, -8191.0, -8191.0});
		}
		
		if( get_pcvar_num(g_Semiclip) ) {
			register_forward( FM_StartFrame,	"fwStartFrame",	0 );
			register_forward( FM_AddToFullPack,	"fwFullPack",	1 );
		}
		
		g_isEnabled = true;
		log_amx("Deathrun Manager by xPaw v%s is ON.", VERSION);
	} else
		g_isEnabled = false;
}

// =======================================================================================

// ================
// Making new Terr
// ================
public eRandromize()
{
	if( !g_isEnabled || g_FirstRound || g_Randromized )
		return PLUGIN_CONTINUE;
	
	g_Randromized = true;
	
	new iPlayers, indexArray[32];
	
	for( new i = 1; i <= g_Maxplayers; i++ )
	{
		if( is_user_connected(i) )
		{
			indexArray[iPlayers] = i;
			iPlayers++;
		}
		
		if( get_user_team(i) == 1 )
			fm_set_user_team(i, FM_TEAM_CT);
	}
	
	if( iPlayers <= 1 )
		return PLUGIN_CONTINUE;
	
	new ID = indexArray[random_num(0, iPlayers - 1)];
	
	if( get_user_team(ID) == 2 || get_user_team(ID) == 1 )
	{
		new name[32];
		get_user_name(ID, name, 31);
	
		client_print(0, print_chat, "[Deathrun] %L", LANG_PLAYER, "MSG_NOW_TERR", name);
	
		fm_set_user_team(ID, FM_TEAM_T);
	}
	else
	{
		g_Randromized = false;
		eRandromize();
	}
	
	return PLUGIN_CONTINUE;
}

// ================
// New round
// ================
public eStartRound() {
	if( !g_isEnabled )
		return PLUGIN_CONTINUE;
	
	g_Randromized	= false;
	g_Restart	= false;
	g_Starting = false;
	
	new g_Players;
	for( new i = 1; i <= g_Maxplayers; i++ ) {
		if(is_user_connected(i) && (get_user_team(i) == 1 || get_user_team(i) == 2) )
			g_Players++;
	}
	
	if( g_Players <= 1 ) {
		set_hudmessage(0, 128, 0, -1.0, 0.1, 0, 4.0, 4.0, 0.5, 0.5, 4);
		ShowSyncHudMsg(0, g_HudSync, "Not enought players to start Deathrun!");
		
		return PLUGIN_CONTINUE;
	}
	
	set_pcvar_num(g_mp_autoteambalance, 0);
	set_pcvar_num(g_mp_limitteams, 0);
	
//	set_hudmessage(255, 127, 0, -1.0, 0.1, 2, 4.0, 4.0, 0.1, 0.3, 1);
//	ShowSyncHudMsg(0, g_HudSync, "%L", LANG_PLAYER, "MSG_PREPARE");
	
	if( g_FirstRound ) {
		log_amx("[Deathrun] %L", LANG_SERVER, "MSG_STARTING");
		
		set_hudmessage(0, 128, 0, -1.0, 0.1, 0, 4.0, 4.0, 0.5, 0.5, 4);
		ShowSyncHudMsg(0, g_HudSync, "%L", LANG_PLAYER, "MSG_STARTING");
		
		client_print(0, print_chat, "[Deathrun] %L", LANG_PLAYER, "MSG_STARTING");
		
		set_task(9.0, "fnRestart");
		g_Starting = true;
		g_FirstRound = false;
	}
	
	return PLUGIN_CONTINUE;
}

public eTerrorCheck(leaving_player)
{
	if( !g_isEnabled || g_FirstRound || g_Starting )
		return PLUGIN_CONTINUE;
		
	// Get alive players count
	static iPlayersnum;
	iPlayersnum = fnGetAlive();
	
	new iTerrors, iPlayers, iTeam;
	static id, name[32];
	
	for( new i = 1; i <= g_Maxplayers; i++ )
	{
		iTeam = get_user_team(i);
		if( iTeam == 1 )
			iTerrors++;
		
		if( is_user_connected(i) && (iTeam == 1 || iTeam == 2) )
			iPlayers++;
	}
	
	if( iPlayers <= 1 )
	{
		set_hudmessage(0, 128, 0, -1.0, 0.1, 0, 4.0, 4.0, 0.5, 0.5, 4);
		ShowSyncHudMsg(0, g_HudSync, "Not enought players to start Deathrun!");
		
		return PLUGIN_CONTINUE;
	}
	
	if( iTerrors == 0 )
	{
		if( g_Restart )
			return PLUGIN_CONTINUE;
		
		g_Restart = true;
		// client_print(0, print_chat, "[Deathrun] %L", LANG_PLAYER, "MSG_NO_DETECT");
		log_amx("[Deathrun] %L", LANG_SERVER, "MSG_NO_DETECT");
		
		while ((id = fnGetRandomAlive(random_num(1, iPlayersnum))) == leaving_player ) {}
			
		get_user_name(id, name, sizeof name - 1);
		
		fm_set_user_team(id, FM_TEAM_T);
		fm_user_team_update(id);
		ExecuteHamB(Ham_CS_RoundRespawn, id);
		
		client_print(0, print_chat, "[Deathrun] TT wyszedl z serwera, nowym zostal %s", name);
		
		/*for( new i = 1; i <= g_Maxplayers; i++ )
		{
			if(is_user_alive(i))
			{
				g_frags[i] = get_user_frags(i);
				g_deaths[i] = get_user_deaths(i);
			}
			set_task(8.0, "reset_stats", i);
		}*/
	}
	
	return PLUGIN_CONTINUE;
}

public reset_stats(i)
{
	fm_set_user_frags(i, g_frags[i]);
	fm_set_user_deaths(i, g_deaths[i]);
}

// ================
// Life System
// ================
public eTerrWin() {
	if( !g_isEnabled || g_FirstRound )
		return PLUGIN_CONTINUE;
	
	new Float:flFrags;
	
	for( new i = 1; i <= g_Maxplayers; i++ ) {
		if( get_user_team(i) == 1 ) {
			pev(i, pev_frags, flFrags);
			set_pev(i, pev_frags, flFrags + 3.0);
			
			if( get_pcvar_num(g_LifeSystem) == 2 )
				g_Lifes[i]++;
		}
	}
	
	return PLUGIN_CONTINUE;
}

public eDeath() {
	if( !g_isEnabled || get_pcvar_num(g_LifeSystem) == 0 )
		return PLUGIN_CONTINUE;
	
	new iKiller = read_data( 1 );
	new iVictim = read_data( 2 );
	
	if( iKiller != iVictim && get_user_team(iKiller) != get_user_team(iVictim) )
		g_Lifes[iKiller]++;
	
	if( get_user_team(iVictim) == 2 && g_Lifes[iVictim] > 0 ) {
		new iCTcount;
		for( new i = 1; i <= g_Maxplayers; i++ ) {
			if( is_user_alive(i) && get_user_team(i) == 2 )
				iCTcount++;
		}
		
		if( iCTcount > 1 ) {
			set_task(3.2, "fnRevivePlayer", iVictim);
			
			client_print(iVictim, print_chat, "[Deathrun] You will be respawned in 3 seconds!");
		} else
			client_print(iVictim, print_chat, "[Deathrun] You could be respawned but all CT's are dead now!");
	}
	
	return PLUGIN_CONTINUE;
}

public fnRevivePlayer( id ) {
	if( is_user_connected(id) ) {
		new iCTcount;
		for( new i = 1; i <= g_Maxplayers; i++ )
			if( is_user_alive(i) && get_user_team(i) == 2 )
				iCTcount++;
		
		if( iCTcount > 1 ) {
			ExecuteHamB(Ham_CS_RoundRespawn, id);
			
			g_Lifes[id]--;
		}
	}
}

public cmdShowlifes( id ) {
	if( get_pcvar_num(g_LifeSystem) == 0 ) {
		client_print(id, print_chat, "[Deathrun] Life system is disabled.");
		return PLUGIN_HANDLED;
	}
	
	if( g_Lifes[id] > 0 )
		client_print(id, print_chat, "[Deathrun] You have %i lifes.", g_Lifes[id]);
	else
		client_print(id, print_chat, "[Deathrun] You dont have lifes, kill enemy to get one!");
	
	return PLUGIN_HANDLED;
}

public Showlifes( id ) {
	set_hudmessage(0, 128, 0, 0.04, 0.71, 0, 4.0, 4.0, 0.5, 0.5, 3);
	
	if( g_Lifes[id] > 0 )
		ShowSyncHudMsg(id, g_HudSync2, "You have %i lifes.", g_Lifes[id]);
	else
		ShowSyncHudMsg(id, g_HudSync2, "You dont have lifes^nKill enemy to get one!");
}

// ================
// Events
// ================
public eResetHUD( id ) {
	if( g_isEnabled && get_pcvar_num(g_HideHud) && !is_user_bot( id ) ) {
		message_begin( MSG_ONE_UNRELIABLE, g_msgHideWeapon, _, id );
		write_byte( (1<<4 | 1<<5) );
		message_end();
		
		message_begin( MSG_ONE_UNRELIABLE, g_msgCrosshair, _, id );
		write_byte( 0 );
		message_end();
	}
}

public client_disconnect(id)
	eTerrorCheck(id);

public eMoney( id ) {
	if( g_isEnabled && get_pcvar_num(g_BlockMoney) ) {
		set_pdata_int ( id, 115, 0 );
		
		message_begin ( MSG_ONE, g_msgMoney, _, id );
		write_long ( 0 );
		write_byte ( 1 );
		message_end ();
	}
}

// =======================================================================================
// Semiclip
// =======================================================================================

public fwFullPack( es, e, ent, host, flags, player, pSet ) {
	if( !g_isEnabled )
		return FMRES_IGNORED;
	
	if( player && g_iSemiClip[ent] && g_iSemiClip[host] ) {
		set_es(es, ES_Solid, SOLID_NOT);
		set_es(es, ES_RenderMode, kRenderTransAlpha);
		set_es(es, ES_RenderAmt, 100);
	}
	return FMRES_IGNORED;
}

public fwStartFrame() {
	if( !g_isEnabled )
		return FMRES_IGNORED;
	
	static iPlayers[32], iNum, iPlayer, iPlayer2;
	get_players(iPlayers, iNum);
	
	arrayset(g_iSemiClip, 0, sizeof(g_iSemiClip));
	
	new iTeams[33] = {-1, ...};
	for( new i = 0; i < iNum; i++ ) {
		iPlayer = iPlayers[i];
		
		if( !is_user_alive(iPlayer) )
			continue;
		
		for( new j = 0; j < iNum; j++ ) {
			iPlayer2 = iPlayers[j];
			
			if(iPlayer == iPlayer2 || !is_user_alive(iPlayer2))
				continue;
			
			static Float:vOrigin1[3], Float:vOrigin2[3];
			pev(iPlayer, pev_origin, vOrigin1);
			pev(iPlayer2, pev_origin, vOrigin2);
			
			if( vector_distance( vOrigin1, vOrigin2 ) < 96) {
				if( iTeams[iPlayer] == -1 )
					iTeams[iPlayer]		= get_user_team(iPlayer);
				if( iTeams[iPlayer2] == -1 )
					iTeams[iPlayer2]	= get_user_team(iPlayer2);
				
				if( iTeams[iPlayer] == 2 && iTeams[iPlayer2] == 2 ) {
					g_iSemiClip[iPlayer]	= true;
					g_iSemiClip[iPlayer2]	= true;
				}
			}
		}
	}
	
	for( new i = 0; i < iNum; i++ ) {
		iPlayer = iPlayers[i];
		
		if( is_user_alive(iPlayer) )
			set_pev(iPlayer, pev_solid, g_iSemiClip[iPlayer] ? SOLID_NOT : SOLID_SLIDEBOX);
	}
	
	return FMRES_IGNORED;
}

// =======================================================================================
// Forwards & Block commands
// =======================================================================================

public fwHamPlayerSpawnPost( id ) {
	if( !g_isEnabled || !is_user_alive( id ) )
		return HAM_IGNORED;
	
	// An small delay for message
	if( get_pcvar_num(g_LifeSystem) != 0 )
		set_task(0.8, "Showlifes", id);
	
	fm_strip_user_weapons( id );
	fm_give_item( id, "weapon_knife" );
	
	if( get_pcvar_num(g_GiveUsp) && get_user_team(id) == 2 && (contain( g_MapName, "hauntedhouse" ) == -1) )
		set_task(1.0, "GiveUsp", id);
	
	return HAM_IGNORED;
}

public GiveUsp( id ) {
	if( is_user_alive( id ) ) {	// who knows, maybe he died in 1second <img src='http://amxx.pl/public/style_emoticons/<#EMO_DIR#>/biggrin.gif' class='bbc_emoticon' alt=':D' />
		fm_give_item( id, "weapon_usp" );
		fm_give_item( id, "ammo_45acp" );
		fm_give_item( id, "ammo_45acp" );
		fm_give_item( id, "ammo_45acp" );
		fm_give_item( id, "ammo_45acp" );
		fm_give_item( id, "ammo_45acp" );
		fm_give_item( id, "ammo_45acp" );
	}
}

public fwGameDesc() {
	if( !g_isEnabled )
		return FMRES_IGNORED;
	
	static szGameName[ 32 ];
	format(szGameName, 31, "Deathrun");
	
	forward_return(FMV_STRING, szGameName);
	
	return FMRES_SUPERCEDE;
}

public fwPlayerPostThink( id ) {
	if( g_isEnabled && is_user_alive(id) )
		set_pdata_int(id, OFFSET_BZ, get_pdata_int(id, OFFSET_BZ, 5) & ~(1<<0), 5);
	
	return FMRES_IGNORED;
}

public fwClientKill( id ) {
	if( !g_isEnabled || !is_user_alive(id) )
		return FMRES_IGNORED;
	
	client_print(id, print_center, "[Deathrun] You can't kill yourself!");
	client_print(id, print_console, "[Deathrun] You can't kill yourself!");
	
	return FMRES_SUPERCEDE;
}

public fwCmdStart( id, uc_handle, seed ) {	
	if( g_isEnabled && get_pcvar_num(g_SprayB) && get_uc(uc_handle, UC_Impulse) == 201 ) {
		if( is_user_alive(id) ) {
			set_uc(uc_handle, UC_Impulse, 0);
			client_print(id, print_center, "%L", id, "BLOCK_SPRAY");
			return FMRES_SUPERCEDE;
		}
	}
	return FMRES_IGNORED;
}

public msgStatusIcon( msg_id, msg_dest, id ) {
	new szIcon[8];
	get_msg_arg_string(2, szIcon, 7);
	
	if( equal(szIcon, "buyzone") )
		return PLUGIN_HANDLED;
	
	return PLUGIN_CONTINUE;
}

public cmdBlockRadio( id ) {
	if( g_isEnabled && get_pcvar_num(g_RadioB) && is_user_alive(id) ) {
		client_print(id, print_center, "%L", id, "BLOCK_RADIO");
		
		return PLUGIN_HANDLED;
	}
	
	return PLUGIN_CONTINUE;
}

public fnRestart()
	set_pcvar_num(g_sv_restart, 1);
	
// Get Alive -returns alive players number-
fnGetAlive()
{
	static iAlive, id;
	iAlive = 0;
	
	for (id = 1; id <= get_maxplayers(); id++)
	{
		if (is_user_alive(id))
			iAlive++;
	}
	
	return iAlive;
}

// Get Random Alive -returns index of alive player number n -
fnGetRandomAlive(n)
{
	static iAlive, id;
	iAlive = 0;
	
	for (id = 1; id <= get_maxplayers(); id++)
	{
		if (is_user_alive(id))
			iAlive++;
		
		if (iAlive == n)
			return id;
	}
	
	return -1;
}

// =======================================================================================
// Stocks
// =======================================================================================

stock fm_set_user_team(client, team) {
	set_pdata_int(client, 114, team);
	
	static const TeamInfo[FM_TEAM_MAX][] = {
		"UNASSIGNED",
		"TERRORIST",
		"CT",
		"SPECTATOR"
	};
	
	message_begin(MSG_ALL, g_msgTeamInfo);
	write_byte(client);
	write_string(TeamInfo[team]);
	message_end();
}

stock fm_strip_user_weapons(index) {
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"));
	if (!pev_valid(ent))
		return 0;
	
	dllfunc(DLLFunc_Spawn, ent);
	dllfunc(DLLFunc_Use, ent, index);
	engfunc(EngFunc_RemoveEntity, ent);
	
	return 1;
}

stock fm_give_item(index, const item[]) {
	if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5))
		return 0;
	
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
	if (!pev_valid(ent))
		return 0;
	
	new Float:origin[3];
	pev(index, pev_origin, origin);
	set_pev(ent, pev_origin, origin);
	set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
	dllfunc(DLLFunc_Spawn, ent);
	
	new save = pev(ent, pev_solid);
	dllfunc(DLLFunc_Touch, ent, index);
	if (pev(ent, pev_solid) != save)
		return ent;
	
	engfunc(EngFunc_RemoveEntity, ent);
	
	return -1;
}

// Get User Team
stock fm_get_user_team(id)
{
	return get_pdata_int(id, 114, 5);
}

// Update Player's Team on all clients (adding needed delays)
stock fm_user_team_update(id)
{
	static Float:current_time;
	current_time = get_gametime();
	
	if (current_time - g_teams_targettime >= 0.1)
	{
		set_task(0.1, "fm_set_user_team_msg", id+TASK_TEAM);
		g_teams_targettime = current_time + 0.1;
	}
	else
	{
		set_task(((g_teams_targettime + 0.1) - current_time), "fm_set_user_team_msg", id+TASK_TEAM);
		g_teams_targettime = g_teams_targettime + 0.1;
	}
}

// Send User Team Message
public fm_set_user_team_msg(taskid)
{
	// Beware: this message can now be picked up by other metamod
	// plugins (yeah, that includes AMXX plugins as well)
	
	// Set the switching team flag
	g_switchingteam[ID_TEAM] = true;
	
	// Tell everyone my new team
	emessage_begin(MSG_ALL, g_msgTeamInfo);
	ewrite_byte(ID_TEAM); // player
	ewrite_string(TEAMNAMES[fm_get_user_team(ID_TEAM)]); // team
	emessage_end();
	
	// Done switching team
	g_switchingteam[ID_TEAM] = false;
}

stock fm_set_user_frags(index, frags)
{
	set_pev(index, pev_frags, float(frags));

	return 1;
}

stock fm_set_user_deaths(id, value)
{
	set_pdata_int(id, 444, value, 5);
}

  • +
  • -
  • 0




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych