AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] How to use SetHamItemInfo correctly? (https://forums.alliedmods.net/showthread.php?t=240839)

yokomo 05-23-2014 05:08

[Help] How to use SetHamItemInfo correctly?
 
Hi, i have a problem using this native.

Code:

/**
 * Sets a parameter on the fly of the current hook.
 * Use this on parameters that are iteminfo result handles.
 *
 * @param iteminfo_handle    Item info handle.
 * @param type                Item info type. See HamItemInfo_ constants.
 */
native SetHamItemInfo(iteminfo_handle, HamItemInfo:type, any:...);

I've tried in pre/post forward but still no update on my clip/bp ammo.
my code


Ham module from amx183:
Code:

amxx version
AMX Mod X 1.8.3-dev+55456ea (http://www.amxmodx.org)
Authors:
        David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
        Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
        Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
        Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: May  3 2014, 06:42:35
Build ID: 3806:55456eaf17d1767111cebccc37e94e20d8ec778f
Core mode: JIT+ASM32


NiHiLaNTh 05-23-2014 05:23

Re: [Help] How to use SetHamItemInfo correctly?
 
Try registering it in plugin_precache. I remember playing with and it only worked in precache.

yokomo 05-23-2014 08:34

Re: [Help] How to use SetHamItemInfo correctly?
 
Quote:

Originally Posted by NiHiLaNTh (Post 2141446)
Try registering it in plugin_precache. I remember playing with and it only worked in precache.

Awww you are right, i need to register hook post in "plugin_precache()". But strange i set iMaxAmmo1 to 100 but only show max 90 for AK47.

Arkshine 05-23-2014 10:06

Re: [Help] How to use SetHamItemInfo correctly?
 
There is something wrong somewhere. When I get the AK, and I want to buy ammos, I see Money called until I can't afford to buy them. It sounds like when it loops to give ammos, some check doesn't do the expected job to stop it. Maybe something wrong with if (player->m_rgAmmo[nAmmo] >= weapon->iMaxAmmo1()), is iMaxAmmo1 holding proper value? It should, as I see well the new value in WeaponList message and this uses ItemInfoArray to pass the value. Problem seems to be elsewhere.

Arkshine 05-23-2014 12:48

Re: [Help] How to use SetHamItemInfo correctly?
 
I know partially why it doesn't work.

It's because, for example AK47, MaxAmmo is 90 and is hardcoded in C762NatoAmmo::AddAmmo(), more as param in GiveAmmo.

So all you need to do is to hook Ham_GiveAmmo and changing last param with your new value.

I've tested it, it works fine.

yokomo 05-23-2014 15:10

Re: [Help] How to use SetHamItemInfo correctly?
 
Quote:

Originally Posted by Arkshine (Post 2141605)
I know partially why it doesn't work.

It's because, for example AK47, MaxAmmo is 90 and is hardcoded in C762NatoAmmo::AddAmmo(), more as param in GiveAmmo.

So all you need to do is to hook Ham_GiveAmmo and changing last param with your new value.

I've tested it, it works fine.

Thanks for your investigation, i will try on my code. :up:


All times are GMT -4. The time now is 09:41.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.