alliedmodders / sourcemod

SourceMod - Source Engine Scripting and Administration
http://www.sourcemod.net/
974 stars 422 forks source link

SetEntPropString - string_t support for source engine < 2007 #1287

Closed DarthMan closed 4 years ago

DarthMan commented 4 years ago

Help us help you

Environment

Description

Tried to use SetEntPropString on a custom-made entity, and I've got an error telling me that string_t is not supported by this game.

I look at the source code of Fortress Forever at first, as this game runs on an older engine, and it seems that the struct exists so normally should be supported. However, after a bit more investitagion, by looking here https://cs.alliedmods.net/sourcemod/source/core/smn_entities.cpp#2384 , it seems that SetEntPropString will throw an error if engine < orange box. It would be nice to have this feature added in the latest SourceMod versions, both 1.10 stable and 1.11 dev .

KyleSanderson commented 4 years ago

This is a bit of a larger ask. If you jump to the definition of why it wasn't added it's because a helper was added to Orangebox and isn't present on ep1. Not that it's impossible, but it's going to take some reversing for sure and may be very brittle. I agree this would be awesome to add, but if you have another way to accomplish what you're looking for that would be the avenue I would explore at this time.

https://cs.alliedmods.net/sourcemod/source/core/HalfLife2.cpp#1370

DarthMan commented 4 years ago

This is a bit of a larger ask. If you jump to the definition of why it wasn't added it's because a helper was added to Orangebox and isn't present on ep1. Not that it's impossible, but it's going to take some reversing for sure and may be very brittle. I agree this would be awesome to add, but if you have another way to accomplish what you're looking for that would be the avenue I would explore at this time.

https://cs.alliedmods.net/sourcemod/source/core/HalfLife2.cpp#1370

No, for what I'm trying to do, there is no other workaround. Also, Set/GetEntPropString is the only way to set and get m_iGlobalname string.

psychonic commented 4 years ago

but it's going to take some reversing for sure and may be very brittle

Negative. The same method works, and uses functionality we already have elsewhere. And it's no more brittle than SDKTools gamedata, which rarely changes for games on this ancient engine version.

It's not too bad to do. The entity lookup part can be just looping ents until the first valid one is found (which will almost always be 0 anyway). And then, the slightly messier part is copying the DispatchKeyValues gamedata from SDKTools and adding the actual calling of it.

I was too lazy to do it when adding support for the other engines since ep1 has a narrow audience, and IServerTools made most of this trivial on newer.

DarthMan commented 4 years ago

but it's going to take some reversing for sure and may be very brittle

Negative. The same method works, and uses functionality we already have elsewhere. And it's no more brittle than SDKTools gamedata, which rarely changes for games on this ancient engine version.

It's not too bad to do. The entity lookup part can be just looping ents until the first valid one is found (which will almost always be 0 anyway). And then, the slightly messier part is copying the DispatchKeyValues gamedata from SDKTools and adding the actual calling of it.

I was too lazy to do it when adding support for the other engines since ep1 has a narrow audience, and IServerTools made most of this trivial on newer.

Could you please give it a shot? This feature could be very useful on my server.

psychonic commented 4 years ago

Could you please give it a shot? This feature could be very useful on my server.

I don't have a desire to spend the time on it, but I can answer questions if someone else wants to tackle it.

DarthMan commented 4 years ago

Well, perhaps someone can work on it. But I understand since most of the players play CSGO only.