+ Reply to Thread
Results 1 to 4 of 4

Thread: Surf Velocity Meter

  1. #1
    Former Event Manager
    Points: 10,924, Level: 45
    Level completed: 17%, Points required for next Level: 376
    Overall activity: 0%
    ArathusX has a brilliant future ArathusX has a brilliant future ArathusX has a brilliant future ArathusX has a brilliant future ArathusX has a brilliant future ArathusX has a brilliant future ArathusX has a brilliant future ArathusX has a brilliant future ArathusX has a brilliant future ArathusX has a brilliant future ArathusX has a brilliant future ArathusX's Avatar
    Join Date
    May 2012
    Posts
    258
    Points
    10,924
    Total Donations For

    [DtK] [Jedi] ArathusX     $ 0.00

    Surf Velocity Meter

    Hey Everyone,

    Well recently DTK Surf went all combat, and a lot of people have been really enjoying playing. However something was missing.

    I present to you, a Velocity Meter.

    This plugin shows your velocity as you move, as well as your kills and deaths! (Thought that might help while flying around.)
    Name:  dtk_surf_1.png Views: 74 Size:  2.4 KB

    The CODE! :
    Code:
    #include <sourcemod>
    
    public Plugin:myinfo =
    {
        name = "DtK Velocity HUD",
        author = "ArathusX & Bauxe",
        description = "Display velocity, kills and deaths",
        version = "1.0",
        url = "http://www.dying2kill.com.au/"
    };
    
    enum playerData
    {
        p_Frags,
        p_Deaths,
        Float:p_Velocity
    }
    
    new playersArray[MAXPLAYERS][playerData];
    
    public OnPluginStart()
    {
        ServerCommand("sv_hudhint_sound 0");
    
        HookEvent("player_death", Event_player_Death);
    }
    
    public OnClientConnected(client)
    {
        playersArray[client][p_Frags] = 0;
        playersArray[client][p_Deaths] = 0;
    }
    
    public Action:Event_player_Death(Handle:event, const String:name[], bool:dontBroadcast)
    {
        new client = GetClientOfUserId(GetEventInt(event, "userid"));
        new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
        
        playersArray[client][p_Deaths] = playersArray[client][p_Deaths] + 1;
        
        if(attacker != client)
        {
            playersArray[attacker][p_Frags] = playersArray[attacker][p_Frags] + 1;
        }
    }
    
    public Action:OnPlayerRunCmd(client)
    {
        if(IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client))
        {
            decl Float:fVelocity[3];
            GetEntPropVector(client, Prop_Data, "m_vecVelocity", fVelocity);
            
            playersArray[client][p_Velocity] = SquareRoot(Pow(fVelocity[0], 2.0) + Pow(fVelocity[1], 2.0));
            
            
            PrintHintText(client, "|DtK| Combat Surf\nVelocity: %.2f\nKills: %i\nDeaths: %i", playersArray[client][p_Velocity], playersArray[client][p_Frags], playersArray[client][p_Deaths]);
        }
    }
    Hopefully this will help you guys out

    Cheers ArathusX,
    ~Last night I lay in bed looking up at the stars when i thought to myself... where the heck is the ceiling?~



  2. The Following 3 Users Say Thank You to ArathusX For This Useful Post:


  3. #2
    Death Reincarnate
    Points: 12,358, Level: 48
    Level completed: 12%, Points required for next Level: 442
    Overall activity: 97.0%



    shredder has much to be proud of shredder has much to be proud of shredder has much to be proud of shredder has much to be proud of shredder has much to be proud of shredder has much to be proud of shredder has much to be proud of shredder has much to be proud of shredder has much to be proud of shredder's Avatar
    Join Date
    Apr 2013
    Location
    New Zealand
    Posts
    373
    Points
    12,358
    Total Donations For

    [DtK] [Jedi] shredder     $ 10.00
    Is there a way to turn it off and on etc?
     

    CPU:AMD Ryzen 5 5600G
    GPU:Gigabyte RTX 3060 12GB
    RAM:32GB Kingston HyperX RGB @3600MHz DDR4
    Motherboard:ASRock B550 PG Riptide
    Mouse:Razer Cobra RGB Gaming Mouse
    KeyboardLogitech G512 Carbon

  4. #3
    Senior Member
    Points: 14,832, Level: 52
    Level completed: 88%, Points required for next Level: 68
    Overall activity: 0%



    Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe's Avatar
    Join Date
    Feb 2012
    Posts
    1,121
    Points
    14,832
    Total Donations For

    [DtK] [Jedi] Bauxe     $ 20.00
    Quote Originally Posted by shredder View Post
    Is there a way to turn it off and on etc?
    We could add it pretty easily.


  5. #4
    Senior Member
    Points: 14,832, Level: 52
    Level completed: 88%, Points required for next Level: 68
    Overall activity: 0%



    Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe's Avatar
    Join Date
    Feb 2012
    Posts
    1,121
    Points
    14,832
    Total Donations For

    [DtK] [Jedi] Bauxe     $ 20.00
    Arathus and myself spent a few hours today going over the plugin, rewriting a few bits, and adding extra functionality (to maintain the functionality of the current velocity plugin, with the added features requested by the surf administration team).





    The current commands can be used to toggle display: !velmet, !meter, !vel, !velocity, !speed, !hud

    By default, display of the velocity meter will be on, however the plugin makes use of cookies to save the display (ie. if disabled, after leaving and rejoining the server, it will stay disabled).


    Code:
    #include <sourcemod>
    #include <clientprefs>
    
    public Plugin:myinfo =
    {
    	name = "DtK Velocity HUD",
    	author = "ArathusX & Bauxe",
    	description = "Display velocity, kills and deaths",
    	version = "1.2",
    	url = "http://www.dying2kill.com.au/"
    }
    
    enum playerData
    {
    	p_Frags,
    	p_Deaths,
    	Float:p_Velocity,
    	Float:p_MaxVel,
    	bool:p_enabled
    }
    
    new playersArray[MAXPLAYERS][playerData];
    new Handle:p_VelEnCookie = INVALID_HANDLE;
    new String:cValue[8];
    
    
    
    public OnPluginStart()
    {
    	ServerCommand("sv_hudhint_sound 0");
    
    	HookEvent("player_death", Event_player_Death);
    	HookEvent("round_end", Event_round_end);
    	HookEvent("round_start", Event_round_start);
    	
    	RegConsoleCmd("sm_velmet", Cmd_VelMet, "HUD On/Off");
    	RegConsoleCmd("sm_meter", Cmd_VelMet, "HUD On/Off");
    	RegConsoleCmd("sm_vel", Cmd_VelMet, "HUD On/Off");
    	RegConsoleCmd("sm_velocity", Cmd_VelMet, "HUD On/Off");
    	RegConsoleCmd("sm_speed", Cmd_VelMet, "HUD On/Off");
    	RegConsoleCmd("sm_hud", Cmd_VelMet, "HUD On/Off");
    	
    	p_VelEnCookie = RegClientCookie("velmet_velencookie", "VelMet VelEn Cookie", CookieAccess_Protected);
    	
    	for(new i = 1; i < MAXPLAYERS; i++)
    	{
    		if(!AreClientCookiesCached(i))
    		{
    			continue;
    		}
    		
    		OnClientCookiesCached(i);
    	}
    }
    
    public OnClientConnected(client)
    {
    	playersArray[client][p_Frags] = 0;
    	playersArray[client][p_Deaths] = 0;
    	
    	if(AreClientCookiesCached(client))
    	{
    		OnClientCookiesCached(client);
    	}
    	
    }
    
    public OnClientCookiesCached(client)
    {
    	GetClientCookie(client, p_VelEnCookie, cValue, sizeof(cValue));
    	
    	playersArray[client][p_enabled] = true;
    	
    	if(cValue[0] != '\0')
    	{
    		playersArray[client][p_enabled] = (cValue[0] != '\0' && StringToInt(cValue));
    	}
    	
    }
    
    public Action:Event_player_Death(Handle:event, const String:name[], bool:dontBroadcast)
    {
    	new client = GetClientOfUserId(GetEventInt(event, "userid"));
    	new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
    	
    	playersArray[client][p_Deaths] = playersArray[client][p_Deaths] + 1;
    	
    	if(attacker != client)
    	{
    		playersArray[attacker][p_Frags] = playersArray[attacker][p_Frags] + 1;
    	}
    }
    
    public Action:OnPlayerRunCmd(client)
    {
    
    	if(IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client))
    	{
    		
    		decl Float:fVelocity[3];
    		GetEntPropVector(client, Prop_Data, "m_vecVelocity", fVelocity);
    	
    		playersArray[client][p_Velocity] = SquareRoot(Pow(fVelocity[0], 2.0) + Pow(fVelocity[1], 2.0) + Pow(fVelocity[2], 2.0));
    		
    		if(playersArray[client][p_Velocity] > playersArray[client][p_MaxVel])
    		{
    			playersArray[client][p_MaxVel] = playersArray[client][p_Velocity];
    		}
    		
    		if(playersArray[client][p_enabled])
    		{						
    			PrintHintText(client, "[ VelMet Surf Velocity ]\nVelocity: %.2f\nKills: %i\nDeaths: %i", playersArray[client][p_Velocity], playersArray[client][p_Frags], playersArray[client][p_Deaths]);
    		}		
    
    	}
    
    }
    
    public Action:Event_round_end(Handle:event, const String:name[], bool:dontBroadcast)
    {
    	
    		new Float:roundMax;
    		new clientMax;
    		decl String:p_name[64];
    		
    		roundMax = 0.0;
    		
    		for(new i = 1; i < MAXPLAYERS; i++)
    		{
    			if(IsClientInGame(i) && !IsFakeClient(i) && playersArray[i][p_MaxVel] > 0.0)
    			{			
    				if(roundMax < playersArray[i][p_MaxVel])
    				{
    					GetClientName(i, p_name, sizeof(p_name));
    					clientMax = i;
    					roundMax = playersArray[i][p_MaxVel];
    				}
    			
    				PrintToChat(i, "\x05[VelMet] \x01My Max Velocity: %.2f.", playersArray[i][p_MaxVel]);
    			}		
    		}
    		
    		GetClientName(clientMax, p_name, sizeof(p_name));
    		
    		if(roundMax > 0.0)
    		{
    			PrintToChatAll("\x05[VelMet] \x01%s had the Highest Velocity, with: %.2f.", p_name, roundMax);
    		}
    	
    }
    
    public Action:Event_round_start(Handle:event, const String:name[], bool:dontBroadcast)
    {
    		for(new i = 0; i < MAXPLAYERS; i++)
    		{
    			playersArray[i][p_MaxVel] = 0.0;
    		}
    }
    
    //COMMANDS
    
    public Action:Cmd_VelMet(client, args)
    {
    	if(IsClientInGame(client) && !IsFakeClient(client))
    	{
    		decl String:str[8];
    		
    		if(playersArray[client][p_enabled])
    		{
    			playersArray[client][p_enabled] = false;
    			IntToString(playersArray[client][p_enabled], str, sizeof(str));
    			SetClientCookie(client, p_VelEnCookie, str);
    			
    			PrintToChat(client, "\x05[VelMet] \x01Velocity HUD Disabled.");
    		}
    		else
    		{
    			playersArray[client][p_enabled] = true;
    			IntToString(playersArray[client][p_enabled], str, sizeof(str));
    			SetClientCookie(client, p_VelEnCookie, str);
    			
    			PrintToChat(client, "\x05[VelMet] \x01Velocity HUD Enabled.");
    		}
    	}
    	
    	return Plugin_Handled
    }

    If any further changes need to be made, be sure to let either Arathus or myself know!

  6. The Following User Says Thank You to Bauxe For This Useful Post:


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts