PDA

View Full Version : setting current clip bullets


meiao
01-26-2007, 09:52 PM
I'm using dod_set_user_ammo(id, wid, value)
but it only sets the remaining clips, not current clip.

I was told that this line, would set current clip (to 0):
set_pdata_int(gunid,108,0);

I believe i got the gunid correct. Anyway, here is the rest of the code:

public client_death (killer, victim, wpnindex, hitplace, TK){
//suicide
if (killer == victim){
return PLUGIN_HANDLED
}
new currentent = -1, gunid = 0
new Float:origin[3];
entity_get_vector(killer,EV_VEC_origin,origin);

//here I take the ammo for every possible weapon
//except the pistols and grenades
//so there is a bunch of dod_set_user_ammo(...)

while((currentent = find_ent_in_sphere(currentent,origin,Float:1.0)) != 0) {
new classname[32]
entity_get_string(currentent,EV_SZ_classname,class name,31)
console_print(0, "%s", classname)
if (!equal(classname, "player") &&
!equal(classname, "weapon_amerknife") &&
!equal(classname, "weapon_gerknife") &&
!equal(classname, "weapon_spade") &&
!equal(classname, "weapon_luger") &&
!equal(classname, "weapon_colt") &&
!equal(classname, "weapon_stickgrenade") &&
!equal(classname, "weapon_handgrenade")
){
gunid = currentent
break
}

}
set_pdata_int(gunid,108,0); // set their ammo
return PLUGIN_HANDLED
}


I've left the console_print just so I could see if it got the right weapon. Will be taken out when it is in production.


What I want is a plugin that whenever you kill someone, you're left only with your knife, pistol, grenades and a empty main gun.

=|[76AD]|= TatsuSaisei
01-27-2007, 05:40 PM
What I want is a plugin that whenever you kill someone, you're left only with your knife, pistol, grenades and a empty main gun.
why not just strip the player of all their weapons when they kill, then simply reequipt them with only the weapons you want them to have....

meiao
01-27-2007, 06:40 PM
I've done that.
But I couldn't keep their current bullets (for pistols), nor grenades.

dod_get_user_ammo always returned 0.
I'll try that again with get_user_ammo.

But I thought it might be easier to take all bullets from 1 weapon.

=|[76AD]|= TatsuSaisei
01-28-2007, 02:03 AM
I've done that.
But I couldn't keep their current bullets (for pistols), nor grenades.

valid point.. I was a bit hasty in my reply...

Wilson [29th ID]
01-28-2007, 11:17 AM
http://www.dodplugins.net/forums/showthread.php?t=230

meiao
01-29-2007, 04:02 PM
;3850']http://www.dodplugins.net/forums/showthread.php?t=230

If you take a closer look to my code, you'll see that it is a modified version of the code found on that thread.

It doesn't work, at least for me on my linux dedicated server.

Wilson [29th ID]
01-30-2007, 04:25 AM
oooh! linux server. You need the linux offset.

Try set_pdata_int(gunid,108,0,4);

if that doesn't work, try set_pdata_int(gunid,108,0,5);

The last digit is the linux offset and it's probably one of those.

meiao
01-30-2007, 06:10 PM
Worked like a charm.

Thanks.