Raised This Month: $ Target: $400
 0% 

[CS:GO] Altering weapon run speed values


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tylerius
Junior Member
Join Date: Feb 2013
Old 02-20-2013 , 05:01   [CS:GO] Altering weapon run speed values
Reply With Quote #1

Hey all, I've been lurking here for a while but finally decided to make an account! I'm fairly new to scripting so I thought this might be a good place to ask for advice.

In this case, I was wondering about the weapon run speed values in GO (listed here: http://forums.steampowered.com/forum....php?t=2591368)

If I wanted to modify a value or two on that list, would I be required to script something for it? I'm asking because I haven't been able to find any good knife run speed plugins, but I almost feel like I'm overcomplicating this whole thing.

I have some more questions, but I figure I should start out with the most noobish ones first. Thanks all.
Tylerius is offline
apocalyptic
Senior Member
Join Date: Feb 2013
Location: China
Old 02-20-2013 , 11:10   Re: [CS:GO] Altering weapon run speed values
Reply With Quote #2

In CS, different weapons have different maximum movement speed, so you can do this:
PHP Code:
set_user_maxspeed(client,speed
But in CS:GO, you just need one float number to set everything:
PHP Code:
SetClientSpeed(client,speed
When speed is set to 1.0, that means you have a normal speed, if 0.0, you will be completely frozen (even you are in the air). If you switch weapons, your maximum speed will be set automaticly.
So if you just need a faster speed when you are hoding a knife, you can try this:
PHP Code:
public OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_WeaponSwitchPostOnWeaponSwitchPost)
}

public 
OnWeaponSwitchPost(clientweapon)
{
//once a player switchs a weapon
    
new String:weapon[24]
    
GetClientWeapon(client,weapon,24)//find out what weapon is in his hand
    
if (StrEqual(weapon,"weapon_knife"))//if he is hoding a knife
        
SetClientSpeed(client,speed)//set the speed, "speed" is the value you need to set
    
else//if he is hoding something other
        
SetClientSpeed(client,1.0)//set to default
}

public 
OnClientDisconnect(client)
{
    
SDKUnhook(clientSDKHook_WeaponSwitchPostOnWeaponSwitchPost)

Forgive my poor English.
apocalyptic is offline
Tylerius
Junior Member
Join Date: Feb 2013
Old 02-20-2013 , 21:04   Re: [CS:GO] Altering weapon run speed values
Reply With Quote #3

First off: Thanks a ton apocalyptic. I have my code written out but I have a couple errors (honestly, I'm sure they're probably huge noob errors too).

The main thing, I think, is the SetClientSpeed. spcomp.exe says that it's an undefined symbol.

The error is as written: error 017: undefined symbol "SetClientSpeed"

Thanks again.
Tylerius is offline
apocalyptic
Senior Member
Join Date: Feb 2013
Location: China
Old 02-20-2013 , 22:35   Re: [CS:GO] Altering weapon run speed values
Reply With Quote #4

Sorry, I forgot somthing. :-(
You need to add this below:
PHP Code:
public SetClientSpeed(client,speed)
{
      
SetEntPropFloat(clientProp_Send"m_flLaggedMovementValue"speed)

And don't forget to do this before:
PHP Code:
#include <entity> 
apocalyptic is offline
Tylerius
Junior Member
Join Date: Feb 2013
Old 02-21-2013 , 00:33   Re: [CS:GO] Altering weapon run speed values
Reply With Quote #5

Awesome, thank you! No errors anymore, either (just a couple warnings). A quick question though, if I wanted to also add in SetEntityGravity, how would I go about this? When I put in both conditions (speed and gravity) I get an error 029 on the if/else. I'm guessing it's another noob formatting thing.

Thanks again, and your English is pretty good ;)
Tylerius is offline
apocalyptic
Senior Member
Join Date: Feb 2013
Location: China
Old 02-21-2013 , 00:57   Re: [CS:GO] Altering weapon run speed values
Reply With Quote #6

Like speed, you can set a custom gravity too. 1.0 is normal. If you set an entity's gravity to 0.0, it will never fall.
But you don't need to make a custom function for this, SourceMod already had one.
PHP Code:
public OnWeaponSwitchPost(clientweapon
{
    new 
String:weapon[24
    
GetClientWeapon(client,weapon,24)
    if (
StrEqual(weapon,"weapon_knife"))
    {
        
SetClientSpeed(client,speed)
        
SetClientGravity(client,gravity)//<----set gravity here
    
}
    else
    {
        
SetClientSpeed(client,1.0)
        
SetClientGravity(client,1.0)//<----set to default too
    
}

apocalyptic is offline
azalty
AlliedModders Donor
Join Date: Feb 2020
Location: France
Old 06-23-2022 , 12:57   Re: [CS:GO] Altering weapon run speed values
Reply With Quote #7

Quote:
Originally Posted by apocalyptic View Post
Like speed, you can set a custom gravity too. 1.0 is normal. If you set an entity's gravity to 0.0, it will never fall.
But you don't need to make a custom function for this, SourceMod already had one.
PHP Code:
public OnWeaponSwitchPost(clientweapon
{
    new 
String:weapon[24
    
GetClientWeapon(client,weapon,24)
    if (
StrEqual(weapon,"weapon_knife"))
    {
        
SetClientSpeed(client,speed)
        
SetClientGravity(client,gravity)//<----set gravity here
    
}
    else
    {
        
SetClientSpeed(client,1.0)
        
SetClientGravity(client,1.0)//<----set to default too
    
}

I think it's SetEntityGravity, not SetClientGravity

"m_flLaggedMovementValue" doesn't really change your speed, but just updates your character faster. It has a very annoying side effect: it makes you fall faster/slower but doesn't actually change your gravity (you'll still get the same amount of damage).

Shavit's timer uses DHooks to set a fixed speed.
Below is a code part that might work. Untested.

Code:
#include <dhooks>

DynamicHook gH_GetPlayerMaxSpeed = null;

public void OnPluginStart()
{
		if ((iOffset = GameConfGetOffset(hGameData, "CCSPlayer::GetPlayerMaxSpeed")) == -1)
		{
			SetFailState("Couldn't get the offset for \"CCSPlayer::GetPlayerMaxSpeed\" - make sure your gamedata is updated!");
		}

		gH_GetPlayerMaxSpeed = DHookCreate(iOffset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, CCSPlayer__GetPlayerMaxSpeed);
}

public MRESReturn CCSPlayer__GetPlayerMaxSpeed(int pThis, DHookReturn hReturn)
{
	// Return MRES_Ignored if you don't want to override the speed.

	hReturn.Value = 250.0; // The speed you want to set

	return MRES_Override;
}

public void OnClientPutInServer(int client)
{
		if (gH_GetPlayerMaxSpeed)
		{
			DHookEntity(gH_GetPlayerMaxSpeed, true, client);
		}
}
Source: https://github.com/shavitush/bhoptim...shavit-misc.sp
__________________
GitHub | Discord: @azalty | Steam

Last edited by azalty; 06-23-2022 at 13:01.
azalty is offline
Tylerius
Junior Member
Join Date: Feb 2013
Old 02-23-2013 , 04:42   Re: [CS:GO] Altering weapon run speed values
Reply With Quote #8

After spending some time tinkering with things it works perfectly now. Thanks a bunch apocalyptic. Couldn't have done it without you.
Tylerius is offline
ehsan.blade
Junior Member
Join Date: Mar 2013
Old 03-13-2013 , 03:57   Re: [CS:GO] Altering weapon run speed values
Reply With Quote #9

hiiii,
would you please please please make this as a plugin for me? I really want this and I don't know how to write a script or make a plugin.
thanks very much in advance.
ehsan.blade is offline
Tylerius
Junior Member
Join Date: Feb 2013
Old 03-18-2013 , 02:13   Re: [CS:GO] Altering weapon run speed values
Reply With Quote #10

Quote:
Originally Posted by ehsan.blade View Post
hiiii,
would you please please please make this as a plugin for me? I really want this and I don't know how to write a script or make a plugin.
thanks very much in advance.
For sure! I'm away from my computer with the script on it right now but when I get back in a couple days I'll PM it to you.
Tylerius 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 04:12.


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