Raised This Month: $32 Target: $400
 8% 

Simple Velocity (in u/s) Displayer!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
beastedout
Member
Join Date: Aug 2018
Old 08-29-2018 , 03:57   Simple Velocity (in u/s) Displayer!
Reply With Quote #1

Need a simple plugin which shows client (and their spectators) their velocity in u/s in hud (PrintHintText).
Extended Speed Meter has so many extra features I don't want. Tried removing things I don't want but it's too hard coded for me.
Help Appreciated!!

Last edited by beastedout; 08-29-2018 at 11:56.
beastedout is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 08-29-2018 , 11:59   Re: Simple Velocity (in u/s) Displayer!
Reply With Quote #2

PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

public Action OnPlayerRunCmd(int iClientint &iButtons)
{
    if (
IsClientInGame(iClient))
    {
        if (
IsPlayerAlive(iClient))
        {
            
float fVelocity[3];
            
fVelocity GetEntPropFloat(iClientProp_Data"m_flGroundSpeed");
            
            
PrintHintText(iClient"%f"fVelocity);
        }
    }


Last edited by mug1wara; 08-29-2018 at 15:15.
mug1wara is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 08-29-2018 , 15:05   Re: Simple Velocity (in u/s) Displayer!
Reply With Quote #3

Quote:
Originally Posted by mug1wara View Post
PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

public Action OnPlayerRunCmd(int iClientint &iButtons)
{
    if (
IsClientInGame(iClient))
    {
        if (
IsPlayerAlive(iClient))
        {
            
float fVelocity[3];
            
GetEntPropVector(iClientProp_Data"m_vecVelocity"fVelocity);
            
            
PrintHintText(iClient"%f"fVelocity);
        }
    }

It's missing GetVectorLength() to get the velocity.
__________________
micapat is offline
beastedout
Member
Join Date: Aug 2018
Old 08-30-2018 , 03:29   Re: Simple Velocity (in u/s) Displayer!
Reply With Quote #4

Quote:
Originally Posted by mug1wara View Post
PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

public Action OnPlayerRunCmd(int iClientint &iButtons)
{
    if (
IsClientInGame(iClient))
    {
        if (
IsPlayerAlive(iClient))
        {
            
float fVelocity[3];
            
fVelocity GetEntPropFloat(iClientProp_Data"m_flGroundSpeed");
            
            
PrintHintText(iClient"%f"fVelocity);
        }
    }

error 033: array must be indexed (variable "fVelocity")
beastedout is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 08-30-2018 , 13:26   Re: Simple Velocity (in u/s) Displayer!
Reply With Quote #5

remove [3]
mug1wara is offline
drespy
Member
Join Date: Jul 2018
Old 08-30-2018 , 23:00   Re: Simple Velocity (in u/s) Displayer!
Reply With Quote #6

is it possible to create in HUD Text?
I think it would look interesting

https://forums.alliedmods.net/showthread.php?t=295215
__________________
|Contact me via Steam|

drespy is offline
SHUFEN
Senior Member
Join Date: Jun 2014
Location: Japan, Tokyo
Old 08-31-2018 , 00:13   Re: Simple Velocity (in u/s) Displayer!
Reply With Quote #7

Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

public Plugin myinfo = {
	name = "Simple Speed Meter",
	author = "SHUFEN from POSSESSION.tokyo",
	description = "",
	version = "1.0",
	url = "https://possession.tokyo"
};

public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3],
								int weapon, int subtype, int cmdnum, int tickcount, int seed, const int mouse[2]) {
	if (!IsClientInGame(client)) return;
	float vVel[3];
	GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel);
	float fVelocity = SquareRoot(Pow(vVel[0], 2.0) + Pow(vVel[1], 2.0));
	SetHudTextParamsEx(0.65, 0.95, 0.1, {255, 255, 255, 255}, {0, 0, 0, 255}, 0, 0.0, 0.0, 0.0);
	ShowHudText(client, 3, "%.2f", fVelocity);
}
Attached Files
File Type: sp Get Plugin or Get Source (SimpleSpeedMeter.sp - 301 views - 790 Bytes)
SHUFEN is offline
Send a message via Skype™ to SHUFEN
beastedout
Member
Join Date: Aug 2018
Old 08-31-2018 , 08:01   Re: Simple Velocity (in u/s) Displayer!
Reply With Quote #8

Quote:
Originally Posted by SHUFEN.jp View Post
Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

public Plugin myinfo = {
	name = "Simple Speed Meter",
	author = "SHUFEN from POSSESSION.tokyo",
	description = "",
	version = "1.0",
	url = "https://possession.tokyo"
};

public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3],
								int weapon, int subtype, int cmdnum, int tickcount, int seed, const int mouse[2]) {
	if (!IsClientInGame(client)) return;
	float vVel[3];
	GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel);
	float fVelocity = SquareRoot(Pow(vVel[0], 2.0) + Pow(vVel[1], 2.0));
	SetHudTextParamsEx(0.65, 0.95, 0.1, {255, 255, 255, 255}, {0, 0, 0, 255}, 0, 0.0, 0.0, 0.0);
	ShowHudText(client, 3, "%.2f", fVelocity);
}
Working Thanks!
beastedout is offline
drespy
Member
Join Date: Jul 2018
Old 08-31-2018 , 13:01   Re: Simple Velocity (in u/s) Displayer!
Reply With Quote #9

Quote:
Originally Posted by SHUFEN.jp View Post
Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

public Plugin myinfo = {
	name = "Simple Speed Meter",
	author = "SHUFEN from POSSESSION.tokyo",
	description = "",
	version = "1.0",
	url = "https://possession.tokyo"
};

public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3],
								int weapon, int subtype, int cmdnum, int tickcount, int seed, const int mouse[2]) {
	if (!IsClientInGame(client)) return;
	float vVel[3];
	GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel);
	float fVelocity = SquareRoot(Pow(vVel[0], 2.0) + Pow(vVel[1], 2.0));
	SetHudTextParamsEx(0.65, 0.95, 0.1, {255, 255, 255, 255}, {0, 0, 0, 255}, 0, 0.0, 0.0, 0.0);
	ShowHudText(client, 3, "%.2f", fVelocity);
}
Nice work! thanks.
__________________
|Contact me via Steam|

drespy 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 00:40.


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