Raised This Month: $99 Target: $400
 24% 

Updater


Post New Thread Reply   
 
Thread Tools Display Modes
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-23-2019 , 09:46   Re: Updater
Reply With Quote #621

Will this work on my home made listen server? Because it says "downloading" and doesn't download. Here's the plugin and logs:

Code:
L 01/23/2019 - 16:41:16: Download started:
L 01/23/2019 - 16:41:16:   [0]  URL: https://raw.githubusercontent.com/eyal282/AlliedmodsUpdater/master/InstantDefuse/updatefile.txt
L 01/23/2019 - 16:41:16:   [1]  Destination: addons\sourcemod\data\updater.txt
It also tries reloads itself when it succeeds doing it but I tried manual reloads. It just won't install the plugin.

Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <cstrike>
#include <clientprefs>

#undef REQUIRE_PLUGIN
#tryinclude <autoexecconfig>
#tryinclude <updater>

#define UPDATE_URL "https://raw.githubusercontent.com/eyal282/AlliedmodsUpdater/master/InstantDefuse/updatefile.txt"

new const String:PLUGIN_VERSION[] = "1.2";

new Handle:hcv_NoobMargin = INVALID_HANDLE;
new Handle:hcv_PrefDefault = INVALID_HANDLE;

new Handle:hcv_InfernoDuration = INVALID_HANDLE;
new Handle:hcv_InfernoDistance = INVALID_HANDLE;

new Handle:hCookie_Enable = INVALID_HANDLE;

new Handle:hTimer_MolotovThreatEnd = INVALID_HANDLE;

public Plugin:myinfo = 
{
	name = "Instant Defuse",
	author = "Eyal282",
	description = "Allows you to instantly defuse the bomb when all T are dead and nothing can stop the defuse.",
	version = PLUGIN_VERSION,
	url = ""
}

public OnPluginStart()
{
	#if defined _autoexecconfig_included
	
	AutoExecConfig_SetFile("InstantDefuse");
	
	#endif
	
	HookEvent("bomb_begindefuse", Event_BombBeginDefuse, EventHookMode_Post);
	HookEvent("molotov_detonate", Event_MolotovDetonate);
	HookEvent("hegrenade_detonate", Event_AttemptInstantDefuse, EventHookMode_Post);

	HookEvent("player_death", Event_AttemptInstantDefuse, EventHookMode_PostNoCopy);
	HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
	
	hcv_NoobMargin = UC_CreateConVar("instant_defuse_noob_margin", "5.2", "To prevent noobs from instantly running for their lives when instant defuse fails, instant defuse won't activate if defuse may be uncertain to the player", FCVAR_NOTIFY);
	hcv_PrefDefault = UC_CreateConVar("instant_defuse_pref_default", "1", "If 1, new players will have instant defuse preference enabled by default");
	
	hcv_InfernoDuration = UC_CreateConVar("instant_defuse_inferno_duration", "7.0", "If Valve ever changed the duration of molotov, this cvar should change with it");
	hcv_InfernoDistance = UC_CreateConVar("instant_defuse_inferno_distance", "225.0", "If Valve ever changed the maximum distance spread of molotov, this cvar should change with it");
	
	#if defined _autoexecconfig_included
	
	AutoExecConfig_ExecuteFile();

	AutoExecConfig_CleanFile();
	
	#endif
	
	hCookie_Enable = RegClientCookie("InstantDefuse_Enabled", "Whether or not to enable instant defuse when it's guaranteed to succeed", CookieAccess_Public);
	
	SetCookieMenuItem(InstantDefuseCookieMenu_Handler, 0, "Instant Defuse");
	
	#if defined _updater_included
	if (LibraryExists("updater"))
	{
		Updater_AddPlugin(UPDATE_URL);
	}
	#endif
}


#if defined _updater_included
public Updater_OnPluginUpdated()
{
	ReloadPlugin(INVALID_HANDLE);
}
#endif

public OnLibraryAdded(const String:name[])
{
	#if defined _updater_included
	if (StrEqual(name, "updater"))
	{
		Updater_AddPlugin(UPDATE_URL);
	}
	#endif
}

public InstantDefuseCookieMenu_Handler(client, CookieMenuAction:action, info, String:buffer[], maxlen)
{
	ShowInstantDefusePrefMenu(client);
} 
public ShowInstantDefusePrefMenu(client)
{
	new Handle:hMenu = CreateMenu(InstantDefusePrefMenu_Handler);
	
	new String:TempFormat[64];
	Format(TempFormat, sizeof(TempFormat), "Instant Defuse: %s", IsClientInstantDefusePref(client) ? "Enabled" : "Disabled");
	AddMenuItem(hMenu, "", TempFormat);	

	SetMenuExitBackButton(hMenu, true);
	SetMenuExitButton(hMenu, true);
	DisplayMenu(hMenu, client, 30);
}


public InstantDefusePrefMenu_Handler(Handle:hMenu, MenuAction:action, client, item)
{
	if(action == MenuAction_DrawItem)
	{
		return ITEMDRAW_DEFAULT;
	}
	else if(item == MenuCancel_ExitBack)
	{
		ShowCookieMenu(client);
	}
	else if(action == MenuAction_Select)
	{
		if(item == 0)
		{
			SetClientInstantDefusePref(client, !IsClientInstantDefusePref(client));
		}
		
		ShowInstantDefusePrefMenu(client);
	}
	return 0;
}


public OnMapStart()
{
	hTimer_MolotovThreatEnd = INVALID_HANDLE;
}

public Action:Event_RoundStart(Handle:hEvent, const String:Name[], bool:dontBroadcast)
{
	if(hTimer_MolotovThreatEnd != INVALID_HANDLE)
	{
		CloseHandle(hTimer_MolotovThreatEnd);
		hTimer_MolotovThreatEnd = INVALID_HANDLE;
	}
}

public Action:Event_BombBeginDefuse(Handle:hEvent, const String:Name[], bool:dontBroadcast)
{	
	RequestFrame(Event_BombBeginDefusePlusFrame, GetEventInt(hEvent, "userid"));
	
	return Plugin_Continue;
}

public Event_BombBeginDefusePlusFrame(UserId)
{
	new client = GetClientOfUserId(UserId);
	
	if(client == 0)
		return;
		
	AttemptInstantDefuse(client);
}

stock AttemptInstantDefuse(client, exemptNade = 0)
{
	if(!GetEntProp(client, Prop_Send, "m_bIsDefusing"))
		return;
		
	else if(!IsClientInstantDefusePref(client))
		return;
		
	new StartEnt = MaxClients + 1;
		
	new c4 = FindEntityByClassname(StartEnt, "planted_c4");
	
	if(c4 == -1)
		return;
		
	else if(FindAlivePlayer(CS_TEAM_T) != 0)
		return;
	
	else if(GetEntPropFloat(c4, Prop_Send, "m_flC4Blow") - GetConVarFloat(hcv_NoobMargin) < GetEntPropFloat(c4, Prop_Send, "m_flDefuseCountDown"))
	{
		PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 Defuse not certain enough, Good luck defusing!", "Insta-Defuse");
		return;
	}

	new ent
	if((ent = FindEntityByClassname(StartEnt, "hegrenade_projectile")) != -1 || (ent = FindEntityByClassname(StartEnt, "molotov_projectile")) != -1)
	{
		if(ent != exemptNade)
		{
			PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 There is a live nade somewhere, Good luck defusing!", "Insta-Defuse");
			return;
		}
	}	
	else if(hTimer_MolotovThreatEnd != INVALID_HANDLE)
	{
		PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 Molotov too close to bomb, Good luck defusing!", "Insta-Defuse");
		return;
	}
		
	SetEntPropFloat(c4, Prop_Send, "m_flDefuseCountDown", 0.0);
	SetEntPropFloat(c4, Prop_Send, "m_flDefuseLength", 0.0);
	SetEntProp(client, Prop_Send, "m_iProgressBarDuration", 0);
}

public Action:Event_AttemptInstantDefuse(Handle:hEvent, const String:Name[], bool:dontBroadcast)
{
	new defuser = FindDefusingPlayer();
	
	
	new ent = 0;
	
	if(StrContains(Name, "detonate") != -1)
		ent = GetEventInt(hEvent, "entityid");
		
	if(defuser != 0)
		AttemptInstantDefuse(defuser, ent);
}
public Action:Event_MolotovDetonate(Handle:hEvent, const String:Name[], bool:dontBroadcast)
{
	new Float:Origin[3];
	Origin[0] = GetEventFloat(hEvent, "x");
	Origin[1] = GetEventFloat(hEvent, "y");
	Origin[2] = GetEventFloat(hEvent, "z");
	
	new c4 = FindEntityByClassname(MaxClients + 1, "planted_c4");
	
	if(c4 == -1)
		return;
	
	new Float:C4Origin[3];
	GetEntPropVector(c4, Prop_Data, "m_vecOrigin", C4Origin);
	
	if(GetVectorDistance(Origin, C4Origin, false) > GetConVarFloat(hcv_InfernoDistance))
		return;

	if(hTimer_MolotovThreatEnd != INVALID_HANDLE)
	{
		CloseHandle(hTimer_MolotovThreatEnd);
		hTimer_MolotovThreatEnd = INVALID_HANDLE;
	}
	
	hTimer_MolotovThreatEnd = CreateTimer(GetConVarFloat(hcv_InfernoDuration), Timer_MolotovThreatEnd, _, TIMER_FLAG_NO_MAPCHANGE);
}

public Action:Timer_MolotovThreatEnd(Handle:hTimer)
{
	hTimer_MolotovThreatEnd = INVALID_HANDLE;
	
	new defuser = FindDefusingPlayer();
	
	if(defuser != 0)
		AttemptInstantDefuse(defuser);
}

stock FindDefusingPlayer()
{
	for(new i=1;i <= MaxClients;i++)
	{
		if(!IsClientInGame(i))
			continue;
			
		else if(!IsPlayerAlive(i))
			continue;
			
		else if(!GetEntProp(i, Prop_Send, "m_bIsDefusing"))
			continue;
			
		return i;
	}
	
	return 0;
}

stock FindAlivePlayer(Team)
{
	for(new i=1;i <= MaxClients;i++)
	{
		if(!IsClientInGame(i))
			continue;
			
		else if(!IsPlayerAlive(i))
			continue;
			
		else if(GetClientTeam(i) != Team)
			continue;
			
		return i;
	}
	
	return 0;
}

stock SetClientInstantDefusePref(client, bool:enabled)
{
	new String:Value[4];
	IntToString(view_as<int>(enabled), Value, sizeof(Value));
	
	SetClientCookie(client, hCookie_Enable, Value);
}

stock bool:IsClientInstantDefusePref(client)
{
	new String:Value[4];
	GetClientCookie(client, hCookie_Enable, Value, sizeof(Value));
	
	if(Value[0] == EOS)
	{
		new bool:enabled = GetConVarBool(hcv_PrefDefault);
		SetClientInstantDefusePref(client, enabled);
		return enabled;
	}
	
	return view_as<bool>(StringToInt(Value));
}

// Stolen from me, from Useful Commands.

#if defined _autoexecconfig_included

stock ConVar:UC_CreateConVar(const String:name[], const String:defaultValue[], const String:description[]="", flags=0, bool:hasMin=false, Float:min=0.0, bool:hasMax=false, Float:max=0.0)
{
	return AutoExecConfig_CreateConVar(name, defaultValue, description, flags, hasMin, min, hasMax, max);
}

#else

stock ConVar:UC_CreateConVar(const String:name[], const String:defaultValue[], const String:description[]="", flags=0, bool:hasMin=false, Float:min=0.0, bool:hasMax=false, Float:max=0.0))AutoExecConfig_CreateConVar(const char[] name, const char[] defaultValue, const char[] description="", int flags=0, bool hasMin=false, float min=0.0, bool hasMax=false, float max=0.0)
{
	return CreateConVar(name, defaultValue, description, flags, hasMin, min, hasMax, max);
}

#endif
All I need is confirmation that it just doesn't work on listen servers created by my computer.
__________________
Accepting private work. Contact me if you're interested.
If you like my work, feel free to donate in appreciation with PayPal or CSGO Skins.

Total Donated: 10$
eyal282 is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 01-24-2019 , 11:50   Re: Updater
Reply With Quote #622

Quote:
Originally Posted by eyal282 View Post
Will this work on my home made listen server?
Quote:
Originally Posted by eyal282 View Post
All I need is confirmation that it just doesn't work on listen servers created by my computer.

From previous threads, such as for example "Latest Metamod doesn't work on listen servers?", Post #13:
Quote:
Originally Posted by psychonic View Post
MM:S and SM don't support listen servers. They might work, they might not - a lot of it depends on the game and Valve updates.
It doesn't seem like there is official support for what you are trying to do, and you're most likely on your own, if you play around with listen servers.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread]
DarkDeviL is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-24-2019 , 11:51   Re: Updater
Reply With Quote #623

Quote:
Originally Posted by arne1288 View Post
From previous threads, such as for example "Latest Metamod doesn't work on listen servers?", Post #13:


It doesn't seem like there is official support for what you are trying to do, and you're most likely on your own, if you play around with listen servers.
Okay
__________________
Accepting private work. Contact me if you're interested.
If you like my work, feel free to donate in appreciation with PayPal or CSGO Skins.

Total Donated: 10$
eyal282 is offline
olokos
Member
Join Date: Jun 2016
Old 03-18-2019 , 08:14   Re: Updater
Reply With Quote #624

@GoD-Tony could you update the plugin source on 1st page? I can see several people fixing the plugin themselves in this threads recent posts, but first post has not been updated since 2016 :/
olokos is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 03-19-2019 , 19:47   Re: Updater
Reply With Quote #625

Quote:
Originally Posted by olokos View Post
@GoD-Tony could you update the plugin source on 1st page? I can see several people fixing the plugin themselves in this threads recent posts, but first post has not been updated since 2016 :/
GoD-Tony has not posted on the forum in 11 months.
__________________
ddhoward is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 07-01-2019 , 08:40   Re: Updater
Reply With Quote #626

Could you make an update fail if the size and last edit date of both files identical? I need a gamedata updater that'll restart the server if successfully updated but I don't want to restart the server massively even after update if the offset is just wrong.
__________________
Accepting private work. Contact me if you're interested.
If you like my work, feel free to donate in appreciation with PayPal or CSGO Skins.

Total Donated: 10$
eyal282 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:34.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode