Skocz do zawartości
cyziek

[Rozwiązane] Kabelki przeróbka

Rekomendowane odpowiedzi

Cześć. Czy mógłby ktoś przerobić plugin Quick Defuse, tak aby menu kebelków pokazywało by się tylko gdy zostało do wybuchu:

  • 10 sekund lub mniej dla gracza który nie posiada defuse kit
  • 5s lub mniej dla gracza który posiada defuse kit?

Chodzi o to aby kabelki nie były nadużywane przez osoby, którym i tak pozostało dużo czasu na rozbrojenie paki.

 

Jeśli można to prosiłbym o kod źródłowy, bo chciałbym sobie później przerobić aby menu kabelków rozpoczynało się od 4 klawisza, aby przypadkowo przełączając na kosę nie wybrać kabelka.

Udostępnij tę odpowiedź


Odnośnik do odpowiedzi
Udostępnij na innych stronach

Nie testowane:

Spoiler
/*
 *		QuickDefuse - by pRED*
 *
 *		CT's get a menu to select a wire to cut when they defuse the bomb
 *			- Choose the right wire - Instant Defuse
 *			- Choose the wrong wire - Instant Explosion
 *
 *		T's also get the option to select the correct wire, otherwise it's random
 *
 *		Ignoring the menu's or selecting exit will let the game continue normally
 *
 */

#include <sourcemod>
#include <sdktools>

#define TIMELEFT_DEFUSE 5.0
#define TIMELEFT_NO_DEFUSE 10.0

#define PLUGIN_VERSION "0.3"

new wire
new Handle:cvar_tchoice

new String:wirecolours[4][] = {"Blue","Yellow","Red","Green"}

float g_C4PlantTime = -1.0;
ConVar c4Time;

public Plugin:myinfo = 
{
	name = "QuickDefuse",
	author = "pRED*",
	description = "Let's CT's choose a wire for quick defusion",
	version = PLUGIN_VERSION,
	url = "http://www.sourcemod.net/"
};

public OnPluginStart()
{
	CreateConVar("sm_quickdefuse_version", PLUGIN_VERSION, "Quick Defuse Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY)

	HookEvent("bomb_begindefuse", Event_Defuse, EventHookMode_Post)
	HookEvent("bomb_beginplant", Event_Plant, EventHookMode_Post)
	HookEvent("bomb_planted", Event_Planted, EventHookMode_PostNoCopy)
	
	HookEvent("bomb_abortdefuse", Event_Abort, EventHookMode_Post)
	HookEvent("bomb_abortplant", Event_Abort, EventHookMode_Post)
	
	cvar_tchoice = CreateConVar("qd_tchoice", "1", "Sets whether Terrorists can select a wire colour (QuickDefuse)")

	c4Time = FindConVar("mp_c4timer");
}

public Event_Plant(Handle:event, const String:name[], bool:dontBroadcast)
{
	new clientId = GetEventInt(event, "userid")
	new client = GetClientOfUserId(clientId)
	
	wire = 0;
	//let the planter choose a wire
	
	if (GetConVarInt(cvar_tchoice))
	{	
		new Handle:panel = CreatePanel()
	
		SetPanelTitle(panel, "Choose a Wire:" )
	
		DrawPanelText(panel, " ")
		
		DrawPanelText(panel, "The CT's can try guess this for an instant defuse")
		DrawPanelText(panel, "Exit, or ignore this for a random wire")
		
		DrawPanelText(panel, " ")
		
		DrawPanelItem(panel,wirecolours[0])
		DrawPanelItem(panel,wirecolours[1])
		DrawPanelItem(panel,wirecolours[2])
		DrawPanelItem(panel,wirecolours[3])
		
		
		DrawPanelText(panel, " ");
		DrawPanelItem(panel, "Exit")
		
		SendPanelToClient(panel, client, PanelPlant, 5)
			
		CloseHandle(panel)
	}
}

public Event_Planted(Handle:event, const String:name[], bool:dontBroadcast)
{
	g_C4PlantTime = GetGameTime();

	if (wire == 0)
		wire = GetRandomInt(1,4)		
}

float getBombExplodeTime() {
	return (c4Time.FloatValue - (GetGameTime() - g_C4PlantTime));
}


public Event_Defuse(Handle:event, const String:name[], bool:dontBroadcast)
{
	new clientId = GetEventInt(event, "userid")
	new client = GetClientOfUserId(clientId)
	new bool:kit = GetEventBool(event, "haskit")

	if (getBombExplodeTime() > (kit ? TIMELEFT_DEFUSE : TIMELEFT_NO_DEFUSE))
		return;
	
	//show a menu to the client offering a choice to pull/cut the wire
			
	new Handle:panel = CreatePanel()

	SetPanelTitle(panel, "Choose a Wire:" )
	DrawPanelText(panel, "Ignore this to defuse normally")

	DrawPanelText(panel, " ")
	
	DrawPanelText(panel, "Get it right and the bomb is defused")
	DrawPanelText(panel, "Get it wrong and the bomb instantly explodes")
	
	
	if (!kit)
	{
		DrawPanelText(panel, "With no defuse kit you have a 50% chance of the bomb exploding")
		DrawPanelText(panel, "even if you choose the right wire")
	}
	

	DrawPanelText(panel, " ")
	
	DrawPanelItem(panel,"Blue")
	DrawPanelItem(panel,"Yellow")
	DrawPanelItem(panel,"Red")
	DrawPanelItem(panel,"Green")
	
	
	DrawPanelText(panel, " ");
	DrawPanelItem(panel, "Exit")
	
	if (kit)
		SendPanelToClient(panel, client, PanelDefuseKit, 5)
	else
		SendPanelToClient(panel, client, PanelNoKit, 5)
		
	CloseHandle(panel)
}

public PanelPlant(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select && param2 > 0 && param2 < 5) //User selected a valid wire colour
	{
		wire = param2
		PrintToChat(param1,"\x01\x04[QuickDefuse] You chose the %s wire",wirecolours[param2-1])
	}
}

public PanelDefuseKit(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select && param2 > 0 && param2 < 5) //User selected a valid wire colour
	{
		new bombent = FindEntityByClassname(-1,"planted_c4")
	
		if (bombent)
		{
			new String:name[32]
			GetClientName(param1,name,sizeof(name))
		
			if (param2 == wire)
			{
				SetEntPropFloat(bombent, Prop_Send, "m_flDefuseCountDown", 1.0)
				PrintToChatAll("\x01\x04[QuickDefuse] %s correctly cut the %s wire for an instant C4 defusal (1:4 odds)",name,wirecolours[param2-1])
			}
			else
			{	
				SetEntPropFloat(bombent, Prop_Send, "m_flC4Blow", 1.0)
				PrintToChatAll("\x01\x04[QuickDefuse] %s detonated the C4 with an incorrect wire choice of %s (3:4 odds) The correct wire was %s",name,wirecolours[param2-1],wirecolours[wire-1])
			}
		}
	}
}

public PanelNoKit(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select && param2 > 0 && param2 < 5) //User selected a valid wire colour
	{
		new bombent = FindEntityByClassname(-1,"planted_c4")
	
		if (bombent)
		{
			new String:name[32]
			GetClientName(param1,name,sizeof(name))
			
			if (param2 == wire && GetRandomInt(0,1))
			{
				SetEntPropFloat(bombent, Prop_Send, "m_flDefuseCountDown", 1.0)
				PrintToChatAll("\x01\x04[QuickDefuse] %s correctly pulled the %s wire for an instant C4 defusal (1:8 odds)",name,wirecolours[param2-1])
			}
			else
			{
				SetEntPropFloat(bombent, Prop_Send, "m_flC4Blow", 1.0)
				if (param2 != wire)
					PrintToChatAll("\x01\x04[QuickDefuse] %s detonated the C4 with an incorrect wire choice of %s (7:8 odds) The correct wire was %s",name,wirecolours[param2-1],wirecolours[wire-1])
				else
					PrintToChatAll("\x01\x04[QuickDefuse] %s chose the correct wire (%s) but the C4 still detonated!",name,wirecolours[param2-1])
			}
		}
	}
}



public Event_Abort(Handle:event, const String:name[], bool:dontBroadcast)
{
	new clientId = GetEventInt(event, "userid")
	new client = GetClientOfUserId(clientId)
	
	CancelClientMenu(client)
}

 

 

Udostępnij tę odpowiedź


Odnośnik do odpowiedzi
Udostępnij na innych stronach

Działa, tylko zastanawia mnie to 50% szansy pomimo prawidłowego kabla dla osób bez defa. Raczej nie powinno tego być

Udostępnij tę odpowiedź


Odnośnik do odpowiedzi
Udostępnij na innych stronach
Spoiler
/*
 *		QuickDefuse - by pRED*
 *
 *		CT's get a menu to select a wire to cut when they defuse the bomb
 *			- Choose the right wire - Instant Defuse
 *			- Choose the wrong wire - Instant Explosion
 *
 *		T's also get the option to select the correct wire, otherwise it's random
 *
 *		Ignoring the menu's or selecting exit will let the game continue normally
 *
 */

#include <sourcemod>
#include <sdktools>

#define TIMELEFT_DEFUSE 5.0
#define TIMELEFT_NO_DEFUSE 10.0

#define PLUGIN_VERSION "0.3"

new wire
new Handle:cvar_tchoice

new String:wirecolours[4][] =  { "Blue", "Yellow", "Red", "Green" }

float g_C4PlantTime = -1.0;
ConVar c4Time;

public Plugin:myinfo = 
{
	name = "QuickDefuse", 
	author = "pRED*", 
	description = "Let's CT's choose a wire for quick defusion", 
	version = PLUGIN_VERSION, 
	url = "http://www.sourcemod.net/"
};

public OnPluginStart()
{
	CreateConVar("sm_quickdefuse_version", PLUGIN_VERSION, "Quick Defuse Version", FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY)
	
	HookEvent("bomb_begindefuse", Event_Defuse, EventHookMode_Post)
	HookEvent("bomb_beginplant", Event_Plant, EventHookMode_Post)
	HookEvent("bomb_planted", Event_Planted, EventHookMode_PostNoCopy)
	
	HookEvent("bomb_abortdefuse", Event_Abort, EventHookMode_Post)
	HookEvent("bomb_abortplant", Event_Abort, EventHookMode_Post)
	
	cvar_tchoice = CreateConVar("qd_tchoice", "1", "Sets whether Terrorists can select a wire colour (QuickDefuse)")
	
	c4Time = FindConVar("mp_c4timer");
}

public Event_Plant(Handle:event, const String:name[], bool:dontBroadcast)
{
	new clientId = GetEventInt(event, "userid")
	new client = GetClientOfUserId(clientId)
	
	wire = 0;
	//let the planter choose a wire
	
	if (GetConVarInt(cvar_tchoice))
	{
		new Handle:panel = CreatePanel()
		
		SetPanelTitle(panel, "Choose a Wire:")
		
		DrawPanelText(panel, " ")
		
		DrawPanelText(panel, "The CT's can try guess this for an instant defuse")
		DrawPanelText(panel, "Exit, or ignore this for a random wire")
		
		DrawPanelText(panel, " ")
		
		DrawPanelItem(panel, wirecolours[0])
		DrawPanelItem(panel, wirecolours[1])
		DrawPanelItem(panel, wirecolours[2])
		DrawPanelItem(panel, wirecolours[3])
		
		
		DrawPanelText(panel, " ");
		DrawPanelItem(panel, "Exit")
		
		SendPanelToClient(panel, client, PanelPlant, 5)
		
		CloseHandle(panel)
	}
}

public Event_Planted(Handle:event, const String:name[], bool:dontBroadcast)
{
	g_C4PlantTime = GetGameTime();
	
	if (wire == 0)
		wire = GetRandomInt(1, 4)
}

float getBombExplodeTime() {
	return (c4Time.FloatValue - (GetGameTime() - g_C4PlantTime));
}


public Event_Defuse(Handle:event, const String:name[], bool:dontBroadcast)
{
	new clientId = GetEventInt(event, "userid")
	new client = GetClientOfUserId(clientId)
	new bool:kit = GetEventBool(event, "haskit")
	
	if (getBombExplodeTime() > (kit ? TIMELEFT_DEFUSE : TIMELEFT_NO_DEFUSE))
		return;
	
	//show a menu to the client offering a choice to pull/cut the wire
	
	new Handle:panel = CreatePanel()
	
	SetPanelTitle(panel, "Choose a Wire:")
	DrawPanelText(panel, "Ignore this to defuse normally")
	
	DrawPanelText(panel, " ")
	
	DrawPanelText(panel, "Get it right and the bomb is defused")
	DrawPanelText(panel, "Get it wrong and the bomb instantly explodes")
	
	
	if (!kit)
	{
		DrawPanelText(panel, "With no defuse kit you have a 50% chance of the bomb exploding")
		DrawPanelText(panel, "even if you choose the right wire")
	}
	
	
	DrawPanelText(panel, " ")
	
	DrawPanelItem(panel, "Blue")
	DrawPanelItem(panel, "Yellow")
	DrawPanelItem(panel, "Red")
	DrawPanelItem(panel, "Green")
	
	
	DrawPanelText(panel, " ");
	DrawPanelItem(panel, "Exit")
	
	if (kit)
		SendPanelToClient(panel, client, PanelDefuseKit, 5)
	else
		SendPanelToClient(panel, client, PanelNoKit, 5)
	
	CloseHandle(panel)
}

public PanelPlant(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select && param2 > 0 && param2 < 5) //User selected a valid wire colour
	{
		wire = param2
		PrintToChat(param1, "\x01\x04[QuickDefuse] You chose the %s wire", wirecolours[param2 - 1])
	}
}

public PanelDefuseKit(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select && param2 > 0 && param2 < 5) //User selected a valid wire colour
	{
		new bombent = FindEntityByClassname(-1, "planted_c4")
		
		if (bombent)
		{
			new String:name[32]
			GetClientName(param1, name, sizeof(name))
			
			if (param2 == wire)
			{
				SetEntPropFloat(bombent, Prop_Send, "m_flDefuseCountDown", 1.0)
				PrintToChatAll("\x01\x04[QuickDefuse] %s correctly cut the %s wire for an instant C4 defusal (1:4 odds)", name, wirecolours[param2 - 1])
			}
			else
			{
				SetEntPropFloat(bombent, Prop_Send, "m_flC4Blow", 1.0)
				PrintToChatAll("\x01\x04[QuickDefuse] %s detonated the C4 with an incorrect wire choice of %s (3:4 odds) The correct wire was %s", name, wirecolours[param2 - 1], wirecolours[wire - 1])
			}
		}
	}
}

public PanelNoKit(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select && param2 > 0 && param2 < 5) //User selected a valid wire colour
	{
		new bombent = FindEntityByClassname(-1, "planted_c4")
		
		if (bombent)
		{
			new String:name[32]
			GetClientName(param1, name, sizeof(name))
			
			if (param2 == wire)
			{
				SetEntPropFloat(bombent, Prop_Send, "m_flDefuseCountDown", 1.0)
				PrintToChatAll("\x01\x04[QuickDefuse] %s correctly pulled the %s wire for an instant C4 defusal (1:8 odds)", name, wirecolours[param2 - 1])
			}
			else
			{
				SetEntPropFloat(bombent, Prop_Send, "m_flC4Blow", 1.0)
				PrintToChatAll("\x01\x04[QuickDefuse] %s detonated the C4 with an incorrect wire choice of %s (7:8 odds) The correct wire was %s", name, wirecolours[param2 - 1], wirecolours[wire - 1])
			}
		}
	}
}



public Event_Abort(Handle:event, const String:name[], bool:dontBroadcast)
{
	new clientId = GetEventInt(event, "userid")
	new client = GetClientOfUserId(clientId)
	
	CancelClientMenu(client)
} 

 

Usunięte 50% szans.

Udostępnij tę odpowiedź


Odnośnik do odpowiedzi
Udostępnij na innych stronach

Wiadomość wygenerowana automatycznie

 

Problem został rozwiązany

Jeżeli się z tym nie zgadzasz, raportuj ten post

Udostępnij tę odpowiedź


Odnośnik do odpowiedzi
Udostępnij na innych stronach
Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.

×
×
  • Dodaj nową pozycję...