From 25184aa9c7e573874ac8724d6ed8110a5539e392 Mon Sep 17 00:00:00 2001 From: Psykotikism <34087316+Psykotikism@users.noreply.github.com> Date: Fri, 6 May 2022 06:53:57 -0700 Subject: [PATCH] Add "DispatchKeyValueInt" stock (#1764) --- plugins/include/sdktools_functions.inc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/include/sdktools_functions.inc b/plugins/include/sdktools_functions.inc index 2255f6b3..0cb25975 100644 --- a/plugins/include/sdktools_functions.inc +++ b/plugins/include/sdktools_functions.inc @@ -169,6 +169,23 @@ native bool DispatchSpawn(int entity); */ native bool DispatchKeyValue(int entity, const char[] keyName, const char[] value); +/** + * Dispatches a KeyValue into given entity using an integer value. + * + * @param entity Destination entity index. + * @param keyName Name of the key. + * @param value Integer value. + * @return True on success, false otherwise. + * @error Invalid entity index or lack of mod support. + */ +stock bool DispatchKeyValueInt(int entity, const char[] keyName, int value) +{ + char str[12]; + FormatEx(str, sizeof(str), "%d", value); + + return DispatchKeyValue(entity, keyName, str); +} + /** * Dispatches a KeyValue into given entity using a floating point value. * @@ -373,7 +390,7 @@ native void EntityCollisionRulesChanged(int entity); * Sets an entity's owner (CBaseEntity::SetEntityOwner). * * @param entity The entity index. - * @param owner The owner entity index, can be invalid. + * @param owner The owner entity index, can be invalid. * @error Invalid entity or lack of mod support. */ native void SetEntityOwner(int entity, int owner=INVALID_ENT_REFERENCE);