Raised This Month: $ Target: $400
 0% 

[CS:S/CS:GO/TF2] shavit's bhoptimer (v2.5.5a 08/August/2019)


Post New Thread Reply   
 
Thread Tools Display Modes
Ampe_sand
Junior Member
Join Date: Jun 2016
Old 06-15-2016 , 14:51   Re: [CS:S/CS:GO] shavit's simple bhop timer (1.4b 21/September/2015)
Reply With Quote #561

Hi, I'm quite new to server managing, plugins, and the like, so I've got a few noob questions.

First of all, I have 4 styles set to no replay and bot_quota set to 2, but for some reason all six bots are still in the server. I've tried numerous things, but nothing seems to work.

Second of all, when I type !wr, the style list shows up, but when I select a style, the menu just goes away and shows nothing. It's odd because if I type !delete, there is a similar menu, and I can see the times.

Third of all, when I restart the server, sometimes a certain bot does not show up. For example, I complete the map on Forwards and the bot shows up. Then I restart the server and the bot is not there. Sometiems it does this, but other times the bot stays.

I'm a bit new to all of this, so if anybody could be help, it would be much appreciated!

Thanks,

Ampersand
Ampe_sand is offline
joe101
Member
Join Date: Jun 2013
Location: Brazil
Old 06-15-2016 , 18:32   Re: [CS:S/CS:GO] shavit's simple bhop timer (1.4b 21/September/2015)
Reply With Quote #562

Hey Shavit, is there a way to make so when a player selects a style it runs a command for the player? (I want to make a no autobhop style, but I don't use the standard autobhop that comes with your plugin for auto bhopping so the standard no autobhop style won't work, by doing it I would make the command run a command that disables auto bhop for the player). Thanks.
joe101 is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 06-15-2016 , 19:01   Re: [CS:S/CS:GO] shavit's simple bhop timer (1.4b 21/September/2015)
Reply With Quote #563

Quote:
Originally Posted by Ampe_sand View Post
Hi, I'm quite new to server managing, plugins, and the like, so I've got a few noob questions.

First of all, I have 4 styles set to no replay and bot_quota set to 2, but for some reason all six bots are still in the server. I've tried numerous things, but nothing seems to work.

Second of all, when I type !wr, the style list shows up, but when I select a style, the menu just goes away and shows nothing. It's odd because if I type !delete, there is a similar menu, and I can see the times.

Third of all, when I restart the server, sometimes a certain bot does not show up. For example, I complete the map on Forwards and the bot shows up. Then I restart the server and the bot is not there. Sometiems it does this, but other times the bot stays.

I'm a bit new to all of this, so if anybody could be help, it would be much appreciated!

Thanks,

Ampersand
Could you post your databases.cfg file (with passwords censored of course)? Also, posting your shavit.inc file would be helpful.
Make sure that you compile the plugin using SourceMod 1.8 (or above) and using the edited shavit.inc file!

Quote:
Originally Posted by joe101 View Post
Hey Shavit, is there a way to make so when a player selects a style it runs a command for the player? (I want to make a no autobhop style, but I don't use the standard autobhop that comes with your plugin for auto bhopping so the standard no autobhop style won't work, by doing it I would make the command run a command that disables auto bhop for the player). Thanks.
At this moment, this isn't possible.
You could post the standalone autobhop plugin you use and I'd help you modify it so it is compatible with my timer!
__________________
retired
shavit is offline
joe101
Member
Join Date: Jun 2013
Location: Brazil
Old 06-15-2016 , 19:10   Re: [CS:S/CS:GO] shavit's simple bhop timer (1.4b 21/September/2015)
Reply With Quote #564

Hey man, if you could do this I'd not know how to thank you! Anyways, the plugin I'm using is https://forums.alliedmods.net/showthread.php?t=132391, the only reason I'm using it is because you can customize the max speed.
joe101 is offline
Ampe_sand
Junior Member
Join Date: Jun 2016
Old 06-15-2016 , 19:58   Re: [CS:S/CS:GO] shavit's simple bhop timer (1.4b 21/September/2015)
Reply With Quote #565

Quote:
Originally Posted by shavit View Post
Could you post your databases.cfg file (with passwords censored of course)? Also, posting your shavit.inc file would be helpful.
Make sure that you compile the plugin using SourceMod 1.8 (or above) and using the edited shavit.inc file!
databases.cfg file:
Code:
"Databases"
{
	"driver_default"		"mysql"
	
	// When specifying "host", you may use an IP address, a hostname, or a socket file path

	"default"
	{
		"driver"			"default"
		"host"			"epershand.site.nfoservers.com"
		"database"			"epershand_admins"
		"user"			"epershand"
		"pass"			"**********"
		//"timeout"			"0"
		"port"				"3306"
	}
	
	"storage-local"
	{
		"driver"			"sqlite"
		"database"			"sourcemod-local"
	}

	"clientprefs"
	{
		"driver"			"sqlite"
		"host"			"localhost"
		"database"			"clientprefs-sqlite"
		"user"			"root"
		"pass"			""
		//"timeout"			"0"
		//"port"			"0"
	}

   	 "shavit"
   	 {
   	    "driver"				"mysql"
    	    "host"				"epershand.site.nfoservers.com"
    	    "database"			"epershand_shavit"
    	    "user"				"epershand"
    	    "pass"				"**********"
	    "port"				"3306"
   	 }
}
Currently, the database for the timer holds 3 tables: mapzones, playertimes, and users. Hopefully that information helps. I also checked and made sure that I compiled the plugin using SourceMod 1.8.

My last issue regarding the replay bots seems to have been fixed, but the other two have not.


Here's my shavit.inc file:
Code:
/*
 * Shavit's Timer - .inc file
 * by: shavit
 *
 * This file is part of shavit's Timer.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
*/

#if defined _shavit_included
	#endinput
#endif
#define _shavit_included

//#pragma newdecls required

#define SHAVIT_VERSION "1.5b"

#define PREFIX "\x04[Timer]\x01"

#define MAX_STYLES 6
#define MAX_ZONES 7

// game types
enum ServerGame(+=1)
{
	Game_CSS = 0,
	Game_CSGO,
	Game_Unknown
};

// bhop styles
// enum - for easier customization of settings
enum BhopStyle(+=1)
{
	Style_Forwards = 0,
	Style_Sideways,
	Style_WOnly,
	Style_Scroll,
	Style_400Velocity,
	Style_HSW
};

#if defined USES_STYLE_PROPERTIES
#define STYLE_NONE				(0)
#define STYLE_AUTOBHOP			(1 << 0) // enable autobhop
#define STYLE_BLOCK_W			(1 << 1) // block +forward
#define STYLE_BLOCK_A			(1 << 2) // block +moveleft
#define STYLE_BLOCK_S			(1 << 3) // block +back
#define STYLE_BLOCK_D			(1 << 4) // block +moveright
#define STYLE_EASYBHOP			(1 << 5) // enable easybhop (disable stamina reset)
#define STYLE_VEL_LIMIT			(1 << 6) // allow velocity limits
#define STYLE_BLOCK_USE			(1 << 7) // block +use
#define STYLE_UNRANKED			(1 << 8) // unranked style. no ranking points and no records. (UNTESTED: REPORT ISSUES!)
#define STYLE_NOREPLAY			(1 << 9) // disable replay bot for this style. don't use for unranked styles.
#define STYLE_PRESPEED			(1 << 10) // allow prespeeding regardless of the prespeed setting
#define STYLE_HSW_ONLY			(1 << 11) // force half-sideways

int gI_StyleProperties[MAX_STYLES] =
{
	STYLE_AUTOBHOP|STYLE_EASYBHOP, // Forwards
	STYLE_AUTOBHOP|STYLE_EASYBHOP|STYLE_BLOCK_A|STYLE_BLOCK_D|STYLE_NOREPLAY, // Sideways
	STYLE_AUTOBHOP|STYLE_EASYBHOP|STYLE_BLOCK_A|STYLE_BLOCK_D|STYLE_BLOCK_S|STYLE_NOREPLAY, // W-Only
	STYLE_EASYBHOP|STYLE_NOREPLAY, // Scroll
	STYLE_VEL_LIMIT|STYLE_NOREPLAY, // 400 Velocity
	STYLE_AUTOBHOP|STYLE_EASYBHOP|STYLE_HSW_ONLY // HSW
};
#endif

#if defined USES_STYLE_VELOCITY_LIMITS
#define VELOCITY_UNLIMITED 0.0

// only applies if STYLE_VEL_LIMIT is defined for a style
// use VELOCITY_UNLIMITED to ignore
float gF_VelocityLimit[MAX_STYLES] =
{
	VELOCITY_UNLIMITED, // Forwards
	VELOCITY_UNLIMITED, // Sideways
	VELOCITY_UNLIMITED, // W-Only
	VELOCITY_UNLIMITED, // Scroll
	400.00, // 400 Velocity
	VELOCITY_UNLIMITED // HSW
};
#endif

#if defined USES_STYLE_NAMES
// style names
char gS_BhopStyles[MAX_STYLES][] =
{
	"Normal",
	"Sideways",
	"W-Only",
	"Scroll",
	"Legit",
	"Half-Sideways"
};
#endif

#if defined USES_STYLE_HTML_COLORS
// style HTML colors, for CS:GO HUD
char gS_StyleHTMLColors[MAX_STYLES][] =
{
	"797FD4",
	"B54CB3",
	"9A59F0",
	"279BC2",
	"C9BB8B",
	"B54CBB"
};
#endif

#if defined USES_SHORT_STYLE_NAMES
// short names - up to 8 characters please
char gS_ShortBhopStyles[MAX_STYLES][] =
{
	"N",
	"SW",
	"W",
	"SCROLL",
	"LEGIT",
	"HSW"
};
#endif

// map zones
#define MULTIPLEZONES_LIMIT 32

enum MapZones(+=1)
{
	Zone_Start = 0,
	Zone_End,
	Zone_Respawn,
	Zone_Stop,
	Zone_Slay,
	Zone_Freestyle,
	Zone_NoVelLimit
};

// let's not throw errors k?
stock bool IsValidClient(int client, bool bAlive = false) // when bAlive is false = technical checks, when it's true = gameplay checks
{
	return (client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsClientSourceTV(client) && (!bAlive || IsPlayerAlive(client)));
}

// time formatting!
stock void FormatSeconds(float time, char[] newtime, int newtimesize, bool precise = true)
{
	int iTemp = RoundToFloor(time);

	int iHours = 0;

	if(iTemp > 3600)
	{
		iHours = RoundToFloor(iTemp / 3600.0);
		iTemp %= 3600;
	}

	char[] sHours = new char[8];

	if(iHours < 10)
	{
		FormatEx(sHours, 8, "0%d", iHours);
	}

	else
	{
		FormatEx(sHours, 8, "%d", iHours);
	}

	int iMinutes = 0;

	if(iTemp >= 60)
	{
		iMinutes = RoundToFloor(iTemp / 60.0);
		iTemp %= 60;
	}

	char[] sMinutes = new char[8];

	if(iMinutes < 10)
	{
		FormatEx(sMinutes, 8, "0%d", iMinutes);
	}

	else
	{
		FormatEx(sMinutes, 8, "%d", iMinutes);
	}

	float fSeconds = ((iTemp) + time - RoundToFloor(time));

	char[] sSeconds = new char[16];

	if(fSeconds < 10)
	{
		FormatEx(sSeconds, 16, "0%.03f", fSeconds);
	}

	else
	{
		FormatEx(sSeconds, 16, "%.03f", fSeconds);
	}

	if(iHours > 0)
	{
		FormatEx(newtime, newtimesize, "%s:%s:%ss", sHours, sMinutes, sSeconds);
	}

	else if(iMinutes > 0)
	{
		FormatEx(newtime, newtimesize, "%s:%ss", sMinutes, sSeconds);
	}

	else
	{
		if(precise)
		{
			FormatEx(newtime, newtimesize, "%.03fs", fSeconds);
		}

		else
		{
			FormatEx(newtime, newtimesize, "%.01fs", fSeconds);
		}
	}
}

/**
 * Called when a player's timer starts.
 * (WARNING: Will be called every tick when the player stands at the start zone!)
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnStart(int client);

/**
 * Called when a player uses the restart command.
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnRestart(int client);

/**
 * Called when a player uses the !end command.
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnEnd(int client);

/**
 * Called when a player's timer stops. (stop =/= finish a map)
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnStop(int client);

/**
 * Called when a player finishes a map. (touches the end zone)
 *
 * @param client					Client index.
 * @param style						Style the record was done on.
 * @param time						Record time.
 * @param jumps						Jumps amount.
 * @noreturn
 */
forward void Shavit_OnFinish(int client, BhopStyle style, float time, int jumps);

/**
 * Called when there's a new WR on the map.
 *
 * @param client					Client index.
 * @param style						Style the record was done on.
 * @param time						Record time.
 * @param jumps						Jumps amount.
 * @noreturn
 */
forward void Shavit_OnWorldRecord(int client, BhopStyle style, float time, int jumps);

/**
 * Called when a player's timer paused.
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnPause(int client);

/**
 * Called when a player's timer resumed.
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnResume(int client);

/**
 * Returns the game type the server is running.
 *
 * @return							Game type. (See "enum ServerGame")
 */
native ServerGame Shavit_GetGameType();

/**
 * Returns the database handle the timer is using.
 *
 * @param hSQL						Handle to store the database on.
 * @noreturn
 */
native void Shavit_GetDB(Database &hSQL);

/**
 * (re)Starts the timer for a player.
 * Will not teleport the player to anywhere, it's handled inside the mapzones plugin.
 *
 * @param client					Client index.
 * @noreturn
 */
native void Shavit_StartTimer(int client);

/**
 * Stops the timer for a player.
 * Will not teleport the player to anywhere, it's handled inside the mapzones plugin.
 *
 * @param client					Client index.
 * @noreturn
 */
native void Shavit_StopTimer(int client);

/**
 * Finishes the map for a player, with his current timer stats.
 * Will not teleport the player to anywhere, it's handled inside the mapzones plugin.
 *
 * @param client					Client index.
 * @noreturn
 */
native void Shavit_FinishMap(int client);

/**
 * Stores the player's timer stats on variables
 *
 * @param client					Client index.
 * @param time						Time passed since the player started.
 * @param jumps						How many times the player jumped since he started.
 * @param style						Style, check "enum BhopStyle"
 * @param started					Timer started?
 * @noreturn
 */
native void Shavit_GetTimer(int client, float &time, int &jumps, BhopStyle &style, bool &started);

/**
 * Saves the WR time for the current map on a variable.
 *
 * @param style						Style to get the WR for.
 * @param time						Reference to the time variable. 0.0 will be returned if no records.
 * @noreturn
 */
native void Shavit_GetWRTime(BhopStyle style, float &time);

/**
 * Saves the WR's record ID for the current map on a variable.
 * Unused in base plugins, as of pre-1.4b.
 *
 * @param style						Style to get the WR for.
 * @param time						Reference to the time variable. 0.0 will be returned if no records.
 * @noreturn
 */
native void Shavit_GetWRRecordID(BhopStyle style, int &recordid);

/**
 * Saves the WR's player name on the map on a variable.
 *
 * @param style						Style to get the WR for.
 * @param wrname					Reference to the name variable.
 * @param wrmaxlength				Max length for the string.
 * @noreturn
 */
native void Shavit_GetWRName(BhopStyle style, char[] wrname, int wrmaxlength);

/**
 * Saves the player's personal best time on a variable.
 *
 * @param client					Client index.
 * @param style						Style to get the PB for.
 * @param time						Reference to the time variable. 0.0 will be returned if no personal record.
 * @noreturn
 */
native void Shavit_GetPlayerPB(int client, BhopStyle style, float &time);

/**
 * Checks if a mapzone exists.
 *
 * @param type						Mapzone type. (Check "enum MapZones")
 * @return							1 if exists, 0 if doesn't exist.
 */
native int Shavit_ZoneExists(MapZones type);
// ^ I could make it return a boolean instead, but I blame SM 1.7 for not letting me :/. You can use view_as<bool>() though :D

/**
 * Checks if a player is inside a mapzone
 *
 * @param client					Client index.
 * @param type						Mapzone type. (Check "enum MapZones")
 * @return							1 if is in the mapzone, 0 if isn't.
 */
native int Shavit_InsideZone(int client, MapZones type);

/**
 * Pauses a player's timer.
 *
 * @param client					Client index.
 * @noreturn
 */
native void Shavit_PauseTimer(int client);

/**
 * Resumes a player's timer.
 *
 * @param client					Client index.
 * @noreturn
 */
native void Shavit_ResumeTimer(int client);

/**
 * Retrieve the engine time of the replay bot's first frame.
 *
 * @param style						Bhop style.
 * @param time						Reference to save the time on.
 * @noreturn
 */
native void Shavit_GetReplayBotFirstFrame(BhopStyle style, float &time);

/**
 * Retrieve the replay bot's client index.
 *
 * @param style						Bhop style.
 * @return							Client index for the replay bot.
 */
native int Shavit_GetReplayBotIndex(BhopStyle style);

/**
 * Retrieve the replay bot's current played frame.
 *
 * @param style						Bhop style.
 * @return							Current played frame.
 */
native int Shavit_GetReplayBotCurrentFrame(BhopStyle style);

/**
 * Use this native when printing anything in chat if it's related to the timer.
 * This native will auto-assign colors and a chat prefix.
 *
 * @param client					Client index.
 * @param format					Formattiing rules.
 * @param any						Variable number of format parameters.
 * @return							PrintToChat()
 */
native int Shavit_PrintToChat(int client, const char[] format, any ...);

// same as Shavit_PrintToChat() but loops through the whole server
// code stolen from the base halflife.inc file
stock Shavit_PrintToChatAll(const char[] format, any ...)
{
	char[] buffer = new char[255];

	for(int i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i))
		{
			// SetGlobalTransTarget(i); when we're out of beta
			VFormat(buffer, 255, format, 2);
			Shavit_PrintToChat(i, "%s", buffer);
		}
	}
}

public SharedPlugin __pl_shavit =
{
	name = "shavit",
	file = "shavit-core.smx",
#if defined REQUIRE_PLUGIN
	required = 1,
#else
	required = 0,
#endif
};
Thanks again,

Ampersand.

Last edited by Ampe_sand; 06-15-2016 at 19:59.
Ampe_sand is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 06-16-2016 , 08:02   Re: [CS:S/CS:GO] shavit's simple bhop timer (1.4b 21/September/2015)
Reply With Quote #566

Quote:
Originally Posted by joe101 View Post
Hey man, if you could do this I'd not know how to thank you! Anyways, the plugin I'm using is https://forums.alliedmods.net/showthread.php?t=132391, the only reason I'm using it is because you can customize the max speed.
You can use the STYLE_VEL_LIMIT flag for a style within my timer though. Try getting it to work and please report back; it's a bad habit to run unnecessary/duplicated plugins on your servers. Use this tutorial: https://www.youtube.com/watch?v=XZKU8b9188g

Quote:
Originally Posted by Ampe_sand View Post
databases.cfg file:
Code:
"Databases"
{
	"driver_default"		"mysql"
	
	// When specifying "host", you may use an IP address, a hostname, or a socket file path

	"default"
	{
		"driver"			"default"
		"host"			"epershand.site.nfoservers.com"
		"database"			"epershand_admins"
		"user"			"epershand"
		"pass"			"**********"
		//"timeout"			"0"
		"port"				"3306"
	}
	
	"storage-local"
	{
		"driver"			"sqlite"
		"database"			"sourcemod-local"
	}

	"clientprefs"
	{
		"driver"			"sqlite"
		"host"			"localhost"
		"database"			"clientprefs-sqlite"
		"user"			"root"
		"pass"			""
		//"timeout"			"0"
		//"port"			"0"
	}

   	 "shavit"
   	 {
   	    "driver"				"mysql"
    	    "host"				"epershand.site.nfoservers.com"
    	    "database"			"epershand_shavit"
    	    "user"				"epershand"
    	    "pass"				"**********"
	    "port"				"3306"
   	 }
}
Currently, the database for the timer holds 3 tables: mapzones, playertimes, and users. Hopefully that information helps. I also checked and made sure that I compiled the plugin using SourceMod 1.8.

My last issue regarding the replay bots seems to have been fixed, but the other two have not.


Here's my shavit.inc file:
Code:
/*
 * Shavit's Timer - .inc file
 * by: shavit
 *
 * This file is part of shavit's Timer.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
*/

#if defined _shavit_included
	#endinput
#endif
#define _shavit_included

//#pragma newdecls required

#define SHAVIT_VERSION "1.5b"

#define PREFIX "\x04[Timer]\x01"

#define MAX_STYLES 6
#define MAX_ZONES 7

// game types
enum ServerGame(+=1)
{
	Game_CSS = 0,
	Game_CSGO,
	Game_Unknown
};

// bhop styles
// enum - for easier customization of settings
enum BhopStyle(+=1)
{
	Style_Forwards = 0,
	Style_Sideways,
	Style_WOnly,
	Style_Scroll,
	Style_400Velocity,
	Style_HSW
};

#if defined USES_STYLE_PROPERTIES
#define STYLE_NONE				(0)
#define STYLE_AUTOBHOP			(1 << 0) // enable autobhop
#define STYLE_BLOCK_W			(1 << 1) // block +forward
#define STYLE_BLOCK_A			(1 << 2) // block +moveleft
#define STYLE_BLOCK_S			(1 << 3) // block +back
#define STYLE_BLOCK_D			(1 << 4) // block +moveright
#define STYLE_EASYBHOP			(1 << 5) // enable easybhop (disable stamina reset)
#define STYLE_VEL_LIMIT			(1 << 6) // allow velocity limits
#define STYLE_BLOCK_USE			(1 << 7) // block +use
#define STYLE_UNRANKED			(1 << 8) // unranked style. no ranking points and no records. (UNTESTED: REPORT ISSUES!)
#define STYLE_NOREPLAY			(1 << 9) // disable replay bot for this style. don't use for unranked styles.
#define STYLE_PRESPEED			(1 << 10) // allow prespeeding regardless of the prespeed setting
#define STYLE_HSW_ONLY			(1 << 11) // force half-sideways

int gI_StyleProperties[MAX_STYLES] =
{
	STYLE_AUTOBHOP|STYLE_EASYBHOP, // Forwards
	STYLE_AUTOBHOP|STYLE_EASYBHOP|STYLE_BLOCK_A|STYLE_BLOCK_D|STYLE_NOREPLAY, // Sideways
	STYLE_AUTOBHOP|STYLE_EASYBHOP|STYLE_BLOCK_A|STYLE_BLOCK_D|STYLE_BLOCK_S|STYLE_NOREPLAY, // W-Only
	STYLE_EASYBHOP|STYLE_NOREPLAY, // Scroll
	STYLE_VEL_LIMIT|STYLE_NOREPLAY, // 400 Velocity
	STYLE_AUTOBHOP|STYLE_EASYBHOP|STYLE_HSW_ONLY // HSW
};
#endif

#if defined USES_STYLE_VELOCITY_LIMITS
#define VELOCITY_UNLIMITED 0.0

// only applies if STYLE_VEL_LIMIT is defined for a style
// use VELOCITY_UNLIMITED to ignore
float gF_VelocityLimit[MAX_STYLES] =
{
	VELOCITY_UNLIMITED, // Forwards
	VELOCITY_UNLIMITED, // Sideways
	VELOCITY_UNLIMITED, // W-Only
	VELOCITY_UNLIMITED, // Scroll
	400.00, // 400 Velocity
	VELOCITY_UNLIMITED // HSW
};
#endif

#if defined USES_STYLE_NAMES
// style names
char gS_BhopStyles[MAX_STYLES][] =
{
	"Normal",
	"Sideways",
	"W-Only",
	"Scroll",
	"Legit",
	"Half-Sideways"
};
#endif

#if defined USES_STYLE_HTML_COLORS
// style HTML colors, for CS:GO HUD
char gS_StyleHTMLColors[MAX_STYLES][] =
{
	"797FD4",
	"B54CB3",
	"9A59F0",
	"279BC2",
	"C9BB8B",
	"B54CBB"
};
#endif

#if defined USES_SHORT_STYLE_NAMES
// short names - up to 8 characters please
char gS_ShortBhopStyles[MAX_STYLES][] =
{
	"N",
	"SW",
	"W",
	"SCROLL",
	"LEGIT",
	"HSW"
};
#endif

// map zones
#define MULTIPLEZONES_LIMIT 32

enum MapZones(+=1)
{
	Zone_Start = 0,
	Zone_End,
	Zone_Respawn,
	Zone_Stop,
	Zone_Slay,
	Zone_Freestyle,
	Zone_NoVelLimit
};

// let's not throw errors k?
stock bool IsValidClient(int client, bool bAlive = false) // when bAlive is false = technical checks, when it's true = gameplay checks
{
	return (client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsClientSourceTV(client) && (!bAlive || IsPlayerAlive(client)));
}

// time formatting!
stock void FormatSeconds(float time, char[] newtime, int newtimesize, bool precise = true)
{
	int iTemp = RoundToFloor(time);

	int iHours = 0;

	if(iTemp > 3600)
	{
		iHours = RoundToFloor(iTemp / 3600.0);
		iTemp %= 3600;
	}

	char[] sHours = new char[8];

	if(iHours < 10)
	{
		FormatEx(sHours, 8, "0%d", iHours);
	}

	else
	{
		FormatEx(sHours, 8, "%d", iHours);
	}

	int iMinutes = 0;

	if(iTemp >= 60)
	{
		iMinutes = RoundToFloor(iTemp / 60.0);
		iTemp %= 60;
	}

	char[] sMinutes = new char[8];

	if(iMinutes < 10)
	{
		FormatEx(sMinutes, 8, "0%d", iMinutes);
	}

	else
	{
		FormatEx(sMinutes, 8, "%d", iMinutes);
	}

	float fSeconds = ((iTemp) + time - RoundToFloor(time));

	char[] sSeconds = new char[16];

	if(fSeconds < 10)
	{
		FormatEx(sSeconds, 16, "0%.03f", fSeconds);
	}

	else
	{
		FormatEx(sSeconds, 16, "%.03f", fSeconds);
	}

	if(iHours > 0)
	{
		FormatEx(newtime, newtimesize, "%s:%s:%ss", sHours, sMinutes, sSeconds);
	}

	else if(iMinutes > 0)
	{
		FormatEx(newtime, newtimesize, "%s:%ss", sMinutes, sSeconds);
	}

	else
	{
		if(precise)
		{
			FormatEx(newtime, newtimesize, "%.03fs", fSeconds);
		}

		else
		{
			FormatEx(newtime, newtimesize, "%.01fs", fSeconds);
		}
	}
}

/**
 * Called when a player's timer starts.
 * (WARNING: Will be called every tick when the player stands at the start zone!)
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnStart(int client);

/**
 * Called when a player uses the restart command.
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnRestart(int client);

/**
 * Called when a player uses the !end command.
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnEnd(int client);

/**
 * Called when a player's timer stops. (stop =/= finish a map)
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnStop(int client);

/**
 * Called when a player finishes a map. (touches the end zone)
 *
 * @param client					Client index.
 * @param style						Style the record was done on.
 * @param time						Record time.
 * @param jumps						Jumps amount.
 * @noreturn
 */
forward void Shavit_OnFinish(int client, BhopStyle style, float time, int jumps);

/**
 * Called when there's a new WR on the map.
 *
 * @param client					Client index.
 * @param style						Style the record was done on.
 * @param time						Record time.
 * @param jumps						Jumps amount.
 * @noreturn
 */
forward void Shavit_OnWorldRecord(int client, BhopStyle style, float time, int jumps);

/**
 * Called when a player's timer paused.
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnPause(int client);

/**
 * Called when a player's timer resumed.
 *
 * @param client					Client index.
 * @noreturn
 */
forward void Shavit_OnResume(int client);

/**
 * Returns the game type the server is running.
 *
 * @return							Game type. (See "enum ServerGame")
 */
native ServerGame Shavit_GetGameType();

/**
 * Returns the database handle the timer is using.
 *
 * @param hSQL						Handle to store the database on.
 * @noreturn
 */
native void Shavit_GetDB(Database &hSQL);

/**
 * (re)Starts the timer for a player.
 * Will not teleport the player to anywhere, it's handled inside the mapzones plugin.
 *
 * @param client					Client index.
 * @noreturn
 */
native void Shavit_StartTimer(int client);

/**
 * Stops the timer for a player.
 * Will not teleport the player to anywhere, it's handled inside the mapzones plugin.
 *
 * @param client					Client index.
 * @noreturn
 */
native void Shavit_StopTimer(int client);

/**
 * Finishes the map for a player, with his current timer stats.
 * Will not teleport the player to anywhere, it's handled inside the mapzones plugin.
 *
 * @param client					Client index.
 * @noreturn
 */
native void Shavit_FinishMap(int client);

/**
 * Stores the player's timer stats on variables
 *
 * @param client					Client index.
 * @param time						Time passed since the player started.
 * @param jumps						How many times the player jumped since he started.
 * @param style						Style, check "enum BhopStyle"
 * @param started					Timer started?
 * @noreturn
 */
native void Shavit_GetTimer(int client, float &time, int &jumps, BhopStyle &style, bool &started);

/**
 * Saves the WR time for the current map on a variable.
 *
 * @param style						Style to get the WR for.
 * @param time						Reference to the time variable. 0.0 will be returned if no records.
 * @noreturn
 */
native void Shavit_GetWRTime(BhopStyle style, float &time);

/**
 * Saves the WR's record ID for the current map on a variable.
 * Unused in base plugins, as of pre-1.4b.
 *
 * @param style						Style to get the WR for.
 * @param time						Reference to the time variable. 0.0 will be returned if no records.
 * @noreturn
 */
native void Shavit_GetWRRecordID(BhopStyle style, int &recordid);

/**
 * Saves the WR's player name on the map on a variable.
 *
 * @param style						Style to get the WR for.
 * @param wrname					Reference to the name variable.
 * @param wrmaxlength				Max length for the string.
 * @noreturn
 */
native void Shavit_GetWRName(BhopStyle style, char[] wrname, int wrmaxlength);

/**
 * Saves the player's personal best time on a variable.
 *
 * @param client					Client index.
 * @param style						Style to get the PB for.
 * @param time						Reference to the time variable. 0.0 will be returned if no personal record.
 * @noreturn
 */
native void Shavit_GetPlayerPB(int client, BhopStyle style, float &time);

/**
 * Checks if a mapzone exists.
 *
 * @param type						Mapzone type. (Check "enum MapZones")
 * @return							1 if exists, 0 if doesn't exist.
 */
native int Shavit_ZoneExists(MapZones type);
// ^ I could make it return a boolean instead, but I blame SM 1.7 for not letting me :/. You can use view_as<bool>() though :D

/**
 * Checks if a player is inside a mapzone
 *
 * @param client					Client index.
 * @param type						Mapzone type. (Check "enum MapZones")
 * @return							1 if is in the mapzone, 0 if isn't.
 */
native int Shavit_InsideZone(int client, MapZones type);

/**
 * Pauses a player's timer.
 *
 * @param client					Client index.
 * @noreturn
 */
native void Shavit_PauseTimer(int client);

/**
 * Resumes a player's timer.
 *
 * @param client					Client index.
 * @noreturn
 */
native void Shavit_ResumeTimer(int client);

/**
 * Retrieve the engine time of the replay bot's first frame.
 *
 * @param style						Bhop style.
 * @param time						Reference to save the time on.
 * @noreturn
 */
native void Shavit_GetReplayBotFirstFrame(BhopStyle style, float &time);

/**
 * Retrieve the replay bot's client index.
 *
 * @param style						Bhop style.
 * @return							Client index for the replay bot.
 */
native int Shavit_GetReplayBotIndex(BhopStyle style);

/**
 * Retrieve the replay bot's current played frame.
 *
 * @param style						Bhop style.
 * @return							Current played frame.
 */
native int Shavit_GetReplayBotCurrentFrame(BhopStyle style);

/**
 * Use this native when printing anything in chat if it's related to the timer.
 * This native will auto-assign colors and a chat prefix.
 *
 * @param client					Client index.
 * @param format					Formattiing rules.
 * @param any						Variable number of format parameters.
 * @return							PrintToChat()
 */
native int Shavit_PrintToChat(int client, const char[] format, any ...);

// same as Shavit_PrintToChat() but loops through the whole server
// code stolen from the base halflife.inc file
stock Shavit_PrintToChatAll(const char[] format, any ...)
{
	char[] buffer = new char[255];

	for(int i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i))
		{
			// SetGlobalTransTarget(i); when we're out of beta
			VFormat(buffer, 255, format, 2);
			Shavit_PrintToChat(i, "%s", buffer);
		}
	}
}

public SharedPlugin __pl_shavit =
{
	name = "shavit",
	file = "shavit-core.smx",
#if defined REQUIRE_PLUGIN
	required = 1,
#else
	required = 0,
#endif
};
Thanks again,

Ampersand.
I'm afraid that it happens because the MySQL server isn't local. I'll try to figure out a fix when I have time.
__________________
retired
shavit is offline
Ampe_sand
Junior Member
Join Date: Jun 2016
Old 06-16-2016 , 20:20   Re: [CS:S/CS:GO] shavit's simple bhop timer (1.4b 21/September/2015)
Reply With Quote #567

Good news, I got pretty much everything working except for the World Record list not showing. I'm sure if I mess with it long enough I can get it to work.
Ampe_sand is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 06-17-2016 , 07:01   Re: [CS:S/CS:GO] shavit's simple bhop timer (1.4b 21/September/2015)
Reply With Quote #568

Quote:
Originally Posted by Ampe_sand View Post
Good news, I got pretty much everything working except for the World Record list not showing. I'm sure if I mess with it long enough I can get it to work.
actually there's an error since the latest -wr update, i'll fix it today
__________________
retired
shavit is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 06-17-2016 , 07:23   Re: [CS:S/CS:GO] shavit's simple bhop timer (1.4b 21/September/2015)
Reply With Quote #569

Quote:
Originally Posted by Ampe_sand View Post
Good news, I got pretty much everything working except for the World Record list not showing. I'm sure if I mess with it long enough I can get it to work.
https://github.com/shavitush/bhoptim...66d31f627576df
__________________
retired
shavit is offline
Ampe_sand
Junior Member
Join Date: Jun 2016
Old 06-17-2016 , 12:17   Re: [CS:S/CS:GO] shavit's simple bhop timer (1.4b 21/September/2015)
Reply With Quote #570

Quote:
Originally Posted by shavit View Post
Thanks, it finally works!
Ampe_sand is offline
Reply



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 12:09.


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