PDA

View Full Version : Possible better solution for weapon removal



ZERO
03-19-2012, 08:40 PM
I am not looking into a better way of doing weapon removal per race. Rather than have all the same code repeated all over and using methods that I hope may reduce crashes I will instead try to use a 3rd party weapon restriction plugin on a player by player basis. This should actually reduce code in the races and allows us to use what should be the safest method of weapon removal by simply restricting the weapon in that plugin and then unresisting when needed.

It is also possible that I may just fine the code in here and use that but I think that using this plugin could be useful b/c it could allow us to restrict without destroying things like bombs and kits for some races.

ZERO
03-19-2012, 08:59 PM
Perhaps if I copy the natives from that program I can use them as an include to better remove weapons. I am posting idea code below for refrence later:

restrict.inc

/**
* Drops and removes clients weapon
*
* @param client Client index
* @param weaponIndex Weapon index to drop and remove
*
* @error Invalid client or weapon index.
* @return true if weapon was removed false otherwise
*/
native bool:Restrict_RemoveWeaponDrop(client, weaponIndex);

ZERO
03-19-2012, 09:38 PM
Holy shit I managed to dig up the source code:

CS_DropWeapon(client, entity, true, true);
if(AcceptEntityInput(entity, "Kill"))

This is the method used by the most popular weapon restrect mod to remove a weapon from a player and destory it. I will be converting all races to use this method as I update them in the future!

ZERO
03-19-2012, 10:01 PM
This method is confirmed working I will be using this now as best use code.

blackmail242
03-19-2012, 10:04 PM
would this be implemented say towards the vagabond for kits?

brett friggin favre
03-19-2012, 10:09 PM
Holy shit I managed to dig up the source code:

CS_DropWeapon(client, entity, true, true);
if(AcceptEntityInput(entity, "Kill"))

This is the method used by the most popular weapon restrect mod to remove a weapon from a player and destory it. I will be converting all races to use this method as I update them in the future!

coupled with the above comment, would it mean that vagabonds destroy kits that they would otherwise pick up?

ZERO
03-19-2012, 10:59 PM
No I was thainking I could outsource the need for the code but that plugin does not support such a freautre.

I was basically trying to do something else and then developed the technology to hopefully prevent the left hand glitch once and for all in the process. Or at the very least greatly minimize is more then before.

brett friggin favre
03-21-2012, 08:55 PM
gotten the left hand glitch 3 times as vaga today

ZERO
03-21-2012, 09:51 PM
When did you get the glitch? This is very strange, was it occuring at all prior to this change? I am using cssweapondrop which should be the safest possible way to remove it from the client.

brett friggin favre
03-21-2012, 09:54 PM
When did you get the glitch? This is very strange, was it occuring at all prior to this change? I am using cssweapondrop which should be the safest possible way to remove it from the client.

i don't remember it ever happening before the change, maybe once. one time i was just coming out of invis and my scout was left hand, once i was in invis and my knife left handed, then i was just in spawn at round start and my scout left handed.

ZERO
03-21-2012, 10:55 PM
Strange, did it crash during any of those glitches?

I just came up with what may be actually the best solution. I will still destroy the item in this way as it appears to be effective in that it removes the item from the player and then destroys it without issue.

I will then add code that tells the user to select a knife or the item in the slot they should have and that should be the same as the user pressing the button.

---------- Post added at 11:55 PM ---------- Previous post was at 11:43 PM ----------

The coming out of invis suggests something very interesting. I wonder if the real problem here is lag. In that you are given a weapon but the restriction for that weapon was not lifted in time. This would be solved with a timer.

For now I am forcing selection of the scout at spawn and the knife at teleport.

If the theory at the top is correct you should still be able to get the following glitches:

Left hand scout coming out of a teleport
Scout can vanish at spawn or left hand glitch at spawn

If you get any of those after the next update let me know and I will try a new method to patch this