alliedmodders / sourcemod

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

Feature Request: DispatchKeyValueInt #1761

Closed Mart-User closed 2 years ago

Mart-User commented 2 years ago

SM has DispatchKeyValue/DispatchKeyValueFloat/DispatchKeyValueVector available.

Having a wrapper to int would be useful for scenarios where we use int and int cvars as the value.

To achieve that with int values, currently is necessary to create a buffer string, format it, then uses it as DispatchKeyValue;

e.g: DispatchKeyValue(entity, "key", buffer);

From what I researched the current methods read some symbols and seem that "Int" is not available as one of them.

But I believe this could be implemented by changing "extensions/sdktools/vnatives.cpp"

IMO would help in scripting, some similar stuff was done like "GetCmdArgInt", etc.

Anyway, is just a request, if it doesn't make sense, just be polite and close.

asherkin commented 2 years ago

It looks like this would be reasonable to add, but it does introduce some risk. As you've identified, the interface we have from the engine that is used by SM doesn't have an int overload, but it looks like the base entity itself actually does - this means we'd need to do our own formatting and dispatch it as a string, so would not call the int overload on the entity, but it looks like no entities overload the non-string versions (and while not enforced, that appears to be the pattern).

https://cs.alliedmods.net/hl2sdk-csgo/source/game/shared/baseentity_shared.cpp#523-530

You could also just implement this as a stock, as all the native behaviour is already exposed.