Raised This Month: $51 Target: $400
 12% 

Solved How to hook into an internal float in a Source game, and change that value?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 02-05-2023 , 18:11   How to hook into an internal float in a Source game, and change that value?
Reply With Quote #1

Edit: This has been solved by the absolute madman Bacardi.
They made an incredible plugin that basically restores the beta Pipebomb Launcher. And, for that, I am forever grateful.


Hi, sorry if I do anything wrong. I'm brand new to the site.

Anyway,
I have been working with SourcePawn for a bit now, and I've made a few plugins. None of them ever released.
But this most recent plugin of mine really sent me over the edge.
I am not an expert coder. Not by a long shot.
So I created an account here, because I need help with this.

The plugin I'm working on is a plugin for TF2 which allows Stickybombs (tf_projectile_pipe_remote) to roll around like the Grenades (tf_projectile_pipe) do.
Problem is, I have absolutely no idea what I'm doing, or what I'm doing wrong.

Here's what I'm trying to do:
1. I want to hook into an internal variable (in this case, a float).
2. I want to set that variable to something else.

This float is "m_flMinSleepTime", a timer that gets set to 0 when the Stickybomb spawns. When this timer hits 0, the Stickybomb will stick to any wall or floor upon contact. I want to set that timer to an absurdly high number, so that the Stickybomb will never stick to anything.

If there's a better way to do this, such as somehow disabling the sticking altogether instead of setting the timer to an absurdly high number, please let me know.

Here's a snippet of my code (taken and modified from another plugin by Lerrdy):

void CheckModel(int entity) {
float timer = GetEntProp(entity, Prop_Send, "m_flMinSleepTime", 0);

if (timer == 0) {
//char sModelName[PLATFORM_MAX_PATH];
//char m_flMinSleepTime[];
//GetEntPropString(entity, Prop_Data, "m_ModelName", sModelName, sizeof(sModelName));
GetEntPropFloat(entity, Prop_Data, "m_flMinSleepTime"); //This is far too advanced for me...

//ReplaceString(sModelName, sizeof(sModelName), ".mdl", ".phy", true);
ReplaceString("m_flMinSleepTime", sizeof("m_flMinSleepTime"), "0", "9999999999999999.0", true);

//bool bDoesHavePhysics = FileExists(sModelName, true, NULL_STRING);
//if (!bDoesHavePhysics)
// SetEntProp(entity, Prop_Data, "m_nSolidType", 0);
}
}

I know, there's alot of comments. They're all failed attempts.
Again, I am not an expert coder. In any language.

Any and all help would be greatly appreciated.

Thanks,
TotalChaos.

Last edited by TotalChaos SourcePawner; 02-06-2023 at 21:44.
TotalChaos SourcePawner is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 02-05-2023 , 19:25   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #2

The `m_flMinSleepTime` variable doesn't look like it is exposed as a datamap or netprop which usually is access via sourcemod easily. If you wanted to actually write to or read from this variable with just sourcemod scripting then you would want to use `StoreToAddress` and `LoadFromAddress` functions`. You would need the base CBaseEntity address object and then an offset to where `m_flMinSleepTime` would be stored. Alternatively you could most likely use `SetEntData` with the entity index and correct offset. However looking at the tf2 code it looks like you could just type this in the srcds console to get the results you are wanting:
`sm_cvar tf_grenade_force_sleeptime 9999999999999`

https://sm.alliedmods.net/new-api/entity/SetEntData
https://sm.alliedmods.net/new-api/so...StoreToAddress
https://sm.alliedmods.net/new-api/so...oadFromAddress
__________________
I highly recommend joining the SourceMod Discord Server for real time support.

Last edited by backwards; 02-05-2023 at 19:28.
backwards is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 02-05-2023 , 19:36   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #3

Thank you for replying, backwards.
I didn't quite understand most of what you said.
Again, I am not an expert at coding.

Also, m_flMinSleepTime only gets set to whatever tf_grenade_force_sleeptime is set to when somebody like a Pyro comes by and airblasts the Stickybomb. It also gets set to tf_grenade_force_sleeptime when any type of damage is done to it that would normally move Stickybombs.

So, no. I can't use tf_grenade_force_sleeptime, as it's not checked when a Stickybomb is spawned.
TotalChaos SourcePawner is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 02-05-2023 , 19:56   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #4

Yeah my apologies, I don't play TF2 at all. I looked at the engine.dll and the offest seems to be 345 for m_flMinSleepTime.

You should be able to set its value this way under windows:
PHP Code:
SetEntDataFloat(tf_projectile_pipe_remote_entity34599999999999true); 
*edit*: You might actually have to multiply that value by 4 so that it would be 1380
__________________
I highly recommend joining the SourceMod Discord Server for real time support.

Last edited by backwards; 02-05-2023 at 19:59.
backwards is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 02-05-2023 , 20:14   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #5

Thank you very much for replying, backwards.
I have absolutely no idea how you did that.

Where exactly do I put that code? I tried using it and all I got was undefined symbol errors.

Here's the full plugin, with extra modified code from another plugin which I wasn't able to get working.
Attached Files
File Type: sp Get Plugin or Get Source (sa_enablemotiononobject.sp - 45 views - 6.7 KB)

Last edited by TotalChaos SourcePawner; 02-05-2023 at 20:17.
TotalChaos SourcePawner is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 02-05-2023 , 20:22   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #6

I think this is what you are trying to do:
PHP Code:
void CheckModel(int entity)
{
    
float m_flMinSleepTime GetEntDataFloat(entity1280);
    
    if (
m_flMinSleepTime == 0)
        
SetEntDataFloat(entity128099999999999.9true);

__________________
I highly recommend joining the SourceMod Discord Server for real time support.

Last edited by backwards; 02-05-2023 at 20:23.
backwards is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 02-05-2023 , 20:30   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #7

Thanks again, backwards.

Well, the code compiles just fine. Not even any warnings.
However, it still didn't work.
Stickybombs still stick to walls, even if there's a Stickybomb already spawned in.
TotalChaos SourcePawner is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 02-05-2023 , 20:33   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #8

Quote:
Originally Posted by TotalChaos SourcePawner View Post
Thanks again, backwards.

Well, the code compiles just fine. Not even any warnings.
However, it still didn't work.
Stickybombs still stick to walls, even if there's a Stickybomb already spawned in.
Maybe it's not equalto zero and the code after never gets executed. You are running the server on windows and not linux right?
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 02-05-2023 , 20:39   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #9

Thanks again for the reply, backwards.

1. It's definitely equal to 0. Here's a small piece of code from the 2008 leak: "m_flMinSleepTime = 0;"
The float gets set to that under "void CTFGrenadePipebombProjectile::Spawn()".

2. As an answer to your question, neither.
I'm not running a dedicated server, but actually a listen server.
I run SourceMod on a listen server for my own private use/fun. This goes for other games besides TF2 as well, but that's not the point.
I am running the listen server on Windows 10, if that helps.

Edit: I commented out the "if (m_flMinSleepTime == 0)" part, and it still doesn't work.

Last edited by TotalChaos SourcePawner; 02-05-2023 at 21:02.
TotalChaos SourcePawner is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 02-05-2023 , 21:36   Re: How to hook into an internal float in a Source game, and change that value?
Reply With Quote #10

Please don't leave me in the dark, backwards.
This almost always happens to me. I look to the community for an answer to a question I have, and nine times out of ten I don't get any replies.
This is much further than I ever expected to get.
TotalChaos SourcePawner 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 11:11.


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