Runtime 10 on cs_set_weapon_ammo (0.20 RC5)
I cannot for the life of me figure out why this is getting a runtime error....
cs_set_weapon_ammo(id, 5) I did a server print also to make sure the "id" was correct and it came back as "1" which is my ID since I'm the only one in the server (my test server). I tried changing the ammo ammount, at first I was using another function to return the max ammo but then I just changed it to 5 and its still doing it. Also I tried cs_set_user_bpammo(id, wpnid, 5) but that apparently doesn't do anything..... no error no nothing.... Im confused... |
cs_set_weapon_ammo() does not take a player entity, it takes a weapon entity
|
might want to note that in the include :P
it just says "index" like every other command in there, I assumed that meant player index. So.... best way to do that then is to find out the entity ID of the weapon the player is holding then use that? |
uhhh.... do weapons in players hand even have entity ids?
I tried using this function on a weapon on the ground and it doesn't runtime, but I can't really tell its doing anything. Is it possible to find the entity ID of a weapon a player is holding (I don't think it even has one.... :/) So.... what exactly would be the purpose of this function? |
You can get the entity of a weapon id on a player by getting the name of the weapon and searching for it by classname. if the entity_get_edict of the EV_ENT_owner is the player, then you have a match :)
|
THANKS BAILOPAN
that was just the little hint I needed. I figured it out and its mostly working.... cept I'm setting the clip full of the max ammo you can carry with the gun (looks funny having 90 ammo in the clip). I think I just want to set it to the max clip ammo for each gun. Anyway.... I'll post code when I'm done so other people can borrow it. ------------------ Here is a sample plugins to see how it all works out. I included and extra stock I had that is related, some people might have a use for it for other things. This plugin basically would give everyone on the server unlimited ammo for every gun (not grenades) Code:
|
jtp, this is something I'd love to incorporate into a plugin I am working on, but the code here doesn't work for me (using the TP4 version of amxx 0.20)...
I added variable dump comments to every step of the changeWeapon routine and everything looks right, the ids are all correct and it gets to the point where the weapon I have _should_ be getting its clip set, but it doesnt. I even hardcoded in the number 12 for the USP I was testing with instead of using the clip lookup routine and it didnt change anything, the cs_set_weapon_ammo() just doesn't do anything for me. What amxx platform have you tested this on? If 0.20 did you test with TP4 ? If its a matter of just installing the latest nightly build I have no problem doing that, was hoping to wait until the final release of 0.20 ... Thanks! -Mug |
FIX:
add this line Code:
after Code:
|
Quote:
|
| All times are GMT -4. The time now is 17:16. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.