Skip to content

Commit

Permalink
Add some items for ammo
Browse files Browse the repository at this point in the history
  • Loading branch information
ArKaNeMaN committed Oct 1, 2022
1 parent be555da commit 1201261
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 20 deletions.
59 changes: 52 additions & 7 deletions amxmodx/scripting/VipM-I-Default.sma
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <json>
#include <VipModular>
#include "VipM/Utils"
#include "VipM/DebugMode"

#pragma semicolon 1
#pragma compress 1
Expand All @@ -18,9 +19,14 @@ new Float:g_fSpeedMult[MAX_PLAYERS + 1] = {1.0, ...};
public VipM_IC_OnInitTypes() {
RegisterPluginByVars();

VipM_IC_RegisterType("Speed");
VipM_IC_RegisterTypeEvent("Speed", ItemType_OnRead, "@OnSpeedRead");
VipM_IC_RegisterTypeEvent("Speed", ItemType_OnGive, "@OnSpeedGive");
VipM_IC_RegisterType("InstantReloadAllWeapons");
VipM_IC_RegisterTypeEvent("InstantReloadAllWeapons", ItemType_OnGive, "@OnInstantReloadAllWeaponsGive");

VipM_IC_RegisterType("InstantReload");
VipM_IC_RegisterTypeEvent("InstantReload", ItemType_OnGive, "@OnInstantReloadGive");

VipM_IC_RegisterType("RefillBpAmmo");
VipM_IC_RegisterTypeEvent("RefillBpAmmo", ItemType_OnGive, "@OnRefillBpAmmoGive");

VipM_IC_RegisterType("Money");
VipM_IC_RegisterTypeEvent("Money", ItemType_OnRead, "@OnMoneyRead");
Expand All @@ -42,10 +48,6 @@ public VipM_IC_OnInitTypes() {
VipM_IC_RegisterTypeEvent("DefuseKit", ItemType_OnGive, "@OnDefuseKitGive");
}

MultUserSpeed(const UserId, const Float:fMultiplier) {
set_entvar(UserId, var_maxspeed, Float:get_entvar(UserId, var_maxspeed) * fMultiplier);
}

@OnPlayerSpawnPre(const UserId) {
g_fSpeedMult[UserId] = 1.0;
}
Expand All @@ -56,6 +58,45 @@ MultUserSpeed(const UserId, const Float:fMultiplier) {
}
}

@OnInstantReloadGive(const UserId, const Trie:Params) {
InstantReloadActiveWeapon(UserId);

return VIPM_CONTINUE;
}

@OnInstantReloadAllWeaponsGive(const UserId, const Trie:Params) {
InstantReloadAllWeapons(UserId);

return VIPM_CONTINUE;
}

@OnRefillBpAmmoGive(const UserId, const Trie:Params) {
new iMaxAmmos[32] = {-1, ...};

for (new WeaponIdType:iWpnId = WEAPON_P228; iWpnId < WEAPON_P90; iWpnId++) {
iMaxAmmos[rg_get_weapon_info(iWpnId, WI_AMMO_TYPE)] = rg_get_weapon_info(iWpnId, WI_MAX_ROUNDS);
}

for (new InventorySlotType:iSlot = PRIMARY_WEAPON_SLOT; iSlot <= PISTOL_SLOT; iSlot++) {
new ItemId = get_member(UserId, m_rgpPlayerItems, iSlot);
while (!is_nullent(ItemId)) {
new iAmmoType = get_member(ItemId, m_Weapon_iPrimaryAmmoType);
if (iAmmoType >= 0) {
iMaxAmmos[iAmmoType] = max(iMaxAmmos[iAmmoType], rg_get_iteminfo(ItemId, ItemInfo_iMaxAmmo1));
}
ItemId = get_member(ItemId, m_pNext);
}
}

for (new iAmmoType = 0; iAmmoType < 32; iAmmoType++) {
if (iMaxAmmos[iAmmoType] >= 0) {
set_member(UserId, m_rgAmmo, iMaxAmmos[iAmmoType], iAmmoType);
}
}

return VIPM_CONTINUE;
}

@OnSpeedRead(const JSON:jItem, const Trie:Params) {
TrieDeleteKey(Params, "Name");

Expand Down Expand Up @@ -265,3 +306,7 @@ StrToAccountSet(const Str[]) {
return -1;
}
}

MultUserSpeed(const UserId, const Float:fMultiplier) {
set_entvar(UserId, var_maxspeed, Float:get_entvar(UserId, var_maxspeed) * fMultiplier);
}
2 changes: 1 addition & 1 deletion amxmodx/scripting/VipM-L-Logic.sma
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ public VipM_OnInitModules(){

@OnNotCheck(const Trie:Params, const UserId){
return !VipM_Params_ExecuteLimitsList(Params, "Limits", UserId, Limit_Exec_AND);
}
}
2 changes: 0 additions & 2 deletions amxmodx/scripting/VipM-ModulesLimiter.sma
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public VipM_OnInitModules() {
}

public VipM_OnActivateModule(const sModuleName[]) {
// Dbg_Log("VipM_OnActivateModule(%s)", sModuleName);

if (!TrieKeyExists(g_tModulesLimits, sModuleName)) {
Dbg_Log("Module `%s` activated. (!TrieKeyExists)", sModuleName);
return VIPM_CONTINUE;
Expand Down
27 changes: 23 additions & 4 deletions amxmodx/scripting/VipM/ArrayTrieUtils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
#define TrieSizeSafe(%1) \
(%1 == Invalid_Trie ? 0 : TrieGetSize(%1))

stock ArrayDestroySafe(Array:a)
if(a != Invalid_Array)
stock ArrayDestroySafe(Array:a) {
if (a != Invalid_Array) {
ArrayDestroy(a);
}
}

stock TrieDestroySafe(Trie:t)
if(t != Invalid_Trie)
stock TrieDestroySafe(Trie:t) {
if (t != Invalid_Trie) {
TrieDestroy(t);
}
}

#define ArrayForeachArray(%1=>%2[%3]) \
ArrayForeachArrayEx(%1 => %2[%3], __i__)
Expand Down Expand Up @@ -52,3 +56,18 @@ stock TrieDestroySafe(Trie:t)
if(!ArraySizeSafe(%1)) \
ArrayDestroy(%1); \
)

stock Array:ArrayMergeCells(const Array:a1, const Array:a2) {
new Array:aMerged = ArrayClone(a1);
ArrayResize(aMerged, ArraySizeSafe(a1) + ArraySizeSafe(a2));

if (a2 == Invalid_Array) {
return aMerged;
}

for (mew i = 0; iSize = ArraySizeSafe(a2); i < iSize; i++) {
ArrayPushCell(aMerged, ArrayGetCell(a2, i));
}

return aMerged;
}
4 changes: 0 additions & 4 deletions amxmodx/scripting/VipM/CommandAliases.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include <amxmodx>
#include <json>
// #include "VipM/DebugMode"

#define COMMAND_ALIASES_COMMAND_MAX_LENGTH 64
static const DEFAULT_TEMPLATE_PLACEHOLDER[] = "<cmd>";
Expand Down Expand Up @@ -108,17 +107,14 @@ stock CommandAliases_Register(const sCmdKey[], const sCallback[], const bitCmdTy

if (bitCmdTypes & CommandAliases_CmdType_Client) {
register_clcmd(sCmd, sCallback);
// Dbg_PrintServer("[CommandAliases][Register] %s: Client - %s [%s]", sCmdKey, sCmd, sCallback);
}

if (bitCmdTypes & CommandAliases_CmdType_Console) {
register_concmd(sCmd, sCallback);
// Dbg_PrintServer("[CommandAliases][Register] %s: Console - %s [%s]", sCmdKey, sCmd, sCallback);
}

if (bitCmdTypes & CommandAliases_CmdType_Server) {
register_srvcmd(sCmd, sCallback);
// Dbg_PrintServer("[CommandAliases][Register] %s: Server - %s [%s]", sCmdKey, sCmd, sCallback);
}
}
ArrayDestroy(aCmds);
Expand Down
15 changes: 15 additions & 0 deletions amxmodx/scripting/VipM/Utils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,18 @@ stock RegisterPlugin(
// register_plugin(PluginName, PluginVersion, PluginAuthor);
// }
// }

stock InstantReloadAllWeapons(const UserId) {
for (new InventorySlotType:iSlot = PRIMARY_WEAPON_SLOT; iSlot <= PISTOL_SLOT; iSlot++) {
new ItemId = get_member(UserId, m_rgpPlayerItems, iSlot);
while (!is_nullent(ItemId)) {
set_member(ItemId, m_Weapon_iClip, rg_get_iteminfo(ItemId, ItemInfo_iMaxClip));
ItemId = get_member(ItemId, m_pNext);
}
}
}

stock InstantReloadActiveWeapon(const UserId) {
new ItemId = get_member(UserId, m_pActiveItem);
set_member(ItemId, m_Weapon_iClip, rg_get_iteminfo(ItemId, ItemInfo_iMaxClip));
}
1 change: 0 additions & 1 deletion amxmodx/scripting/VipModular.sma
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public plugin_precache() {
Modules_Init();
Forwards_RegAndCall("InitModules", ET_IGNORE);

// Cfg_LoadModulesConfig();
Vips = Cfg_LoadVipsConfigs();

if (!ArraySizeSafe(Vips)) {
Expand Down
2 changes: 1 addition & 1 deletion amxmodx/scripting/include/VipModular.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include json

stock const VIPM_LIBRARY[] = "VipModular";
#define _VIPM_VERSION "5.0.0-beta.3"
#define _VIPM_VERSION "5.0.0-beta.4"
stock const VIPM_VERSION[] = _VIPM_VERSION;
stock const VIPM_CFG_PATH[] = "plugins/VipModular";

Expand Down

0 comments on commit 1201261

Please sign in to comment.