diff --git a/gsc.cpp b/gsc.cpp index 82aac12..3b23bfb 100644 --- a/gsc.cpp +++ b/gsc.cpp @@ -228,7 +228,9 @@ scr_function_t scriptFunctions[] = #if COMPILE_WEAPONS == 1 {"getweaponmaxammo", gsc_weapons_getweaponmaxammo, 0}, + {"setweaponmaxammo", gsc_weapons_setweaponmaxammo, 0}, {"getweaponclipsize", gsc_weapons_getweaponclipsize, 0}, + {"setweaponclipsize", gsc_weapons_setweaponclipsize, 0}, {"getweapondamage", gsc_weapons_getweapondamage, 0}, {"setweapondamage", gsc_weapons_setweapondamage, 0}, {"getweaponmeleedamage", gsc_weapons_getweaponmeleedamage, 0}, diff --git a/gsc_weapons.cpp b/gsc_weapons.cpp index d9b1b84..127530b 100644 --- a/gsc_weapons.cpp +++ b/gsc_weapons.cpp @@ -235,6 +235,56 @@ void gsc_weapons_setweapondamage() stackPushBool(qtrue); } +void gsc_weapons_setweaponmaxammo() +{ + int id; + int ammo; + + if ( ! stackGetParams("ii", &id, &ammo)) + { + stackError("gsc_weapons_setweaponmaxammo() one or more arguments is undefined or has a wrong type"); + stackPushUndefined(); + return; + } + + if (!isValidWeaponId(id)) + { + stackError("gsc_weapons_setweaponmaxammo() weapon index is out of bounds"); + stackPushUndefined(); + return; + } + + WeaponDef_t *weapon = BG_WeaponDefs(id); + weapon->iMaxAmmo = ammo; + + stackPushBool(qtrue); +} + +void gsc_weapons_setweaponclipsize() +{ + int id; + int clipSize; + + if ( ! stackGetParams("ii", &id, &clipSize)) + { + stackError("gsc_weapons_setweaponclipsize() one or more arguments is undefined or has a wrong type"); + stackPushUndefined(); + return; + } + + if (!isValidWeaponId(id)) + { + stackError("gsc_weapons_setweaponclipsize() weapon index is out of bounds"); + stackPushUndefined(); + return; + } + + WeaponDef_t *weapon = BG_WeaponDefs(id); + weapon->iClipSize = clipSize; + + stackPushBool(qtrue); +} + void gsc_weapons_setweaponmeleedamage() { int id; diff --git a/gsc_weapons.hpp b/gsc_weapons.hpp index 41cdb10..05e14bd 100644 --- a/gsc_weapons.hpp +++ b/gsc_weapons.hpp @@ -5,7 +5,9 @@ #include "gsc.hpp" void gsc_weapons_getweaponmaxammo(); +void gsc_weapons_setweaponmaxammo(); void gsc_weapons_getweaponclipsize(); +void gsc_weapons_setweaponclipsize(); void gsc_weapons_getweapondamage(); void gsc_weapons_setweapondamage(); void gsc_weapons_getweaponmeleedamage();