I became interested in this conversation and about psychonic answer.
Quote:
Originally Posted by Bubka3
I don't understand this. What I do understand is I'd have to figure out the default value for each gun which would be annoying at best.
Quote:
Originally Posted by psychonic
Or do an SDKCall to GetMaxClip1 on the weapon.
I haven't use before any SDKCall and don't have knowledge how to set those parameters.
I could have just ask from @psychonic, "How to do it ? Show us !"
Instead of easier way to get answer, I search for it.
// CBaseCombatWeapon::
// First SDKCall parameter, entity index (weapon).
StartPrepSDKCall(SDKCall_Entity);
// virtual function index (offset)
//PrepSDKCall_SetVirtual(310); // Use gamedata file instead, OS Win/Linux/Mac
if(!PrepSDKCall_SetFromConf(gameconf, SDKConf_Virtual, "GetMaxClip1"))
{
SetFailState("PrepSDKCall_SetFromConf false, nothing found");
}
CloseHandle(gameconf);
// GetMaxClip1(void)const
// SDKCall return as integer value.
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_ByValue);
new Handle:hCall= EndPrepSDKCall();
new weapon_entity_index = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
if( weapon_entity_index != -1 )
{
new value;
value = SDKCall(hCall, weapon_entity_index);
PrintToChat(client, "weapon index %i SDKCall GetMaxClip1 return value %i", weapon_entity_index, value);
}
CloseHandle(hCall);
return Plugin_Handled;
}
- What I quick test, HL2DM, CS:S and DOD:S return right value.
- CSGO and TF2 instead return random value.
This is one method to get weapon max ammount ammo in Clip1.
Another way can be done also..
- when entity created, store in global variable weapon clip1 ammo.
- read weapon script file from server (loose file or inside VPK pack)
- use extensions
Hope one SDKCall tutorial more not cause disapproval
Did you check the return value of CBaseCombatWeapon::UsesClipsForAmmo1 before checking CBaseCombatWeapon::GetMaxClip1 / CBaseCombatWeapon::GetDefaultClip1?
__________________
Not currently working on SourceMod plugin development.
Did you check the return value of CBaseCombatWeapon::UsesClipsForAmmo1 before checking CBaseCombatWeapon::GetMaxClip1 / CBaseCombatWeapon::GetDefaultClip1?
Nope. I was interested only this, GetMaxClip1 will return -1 if not use any ammo type. (Knife, grenades)
These can be check also with GetEntProp "m_iPrimaryAmmoType"
But if I remember rigth, grenades ammotype clip1 return as 255.
If you meant that ?
*edit
There is also Clip2 which HL2MP weapons use. Maybe dod also. And in cs:s mp5navy use both clip with same ammo (bug)