Raised This Month: $ Target: $400
 0% 

[TS] Strip a players weapon?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Infest
Member
Join Date: Mar 2005
Old 09-23-2016 , 06:07   [TS] Strip a players weapon?
Reply With Quote #1

I have found trying to quickly change a players weapon, and drop their current weapon (with client_cmd drop) to be too inefficient when dealing with players with a high latency.

These two implementations appear to strip my weapon, but do not update my hud, I can also not attack or pick up weapons after I use these function:
fm_strip_user_weapons(id)
strip_user_weapons(id)

http://i.imgur.com/fLASqWc.png

https://forums.alliedmods.net/showpo...52&postcount=1
I tried playing with this function too but it fails on debug number 3 (fails to find an entity by string search I assume)
http://i.imgur.com/eW3uNqG.png

I called this function with the following:
PHP Code:
new iWeapon get_user_weapon(id__
new 
sWeaponName[32]
get_weaponname(iWeaponsWeaponNamesizeof(sWeaponName)-1)
ham_strip_weapon(idsWeaponName
so I believe I am feeding this function the correct/intended string

Is stripping a players weapon possible in TS?

Last edited by Infest; 09-23-2016 at 09:44.
Infest is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-23-2016 , 15:32   Re: [TS] Strip a players weapon?
Reply With Quote #2

Quote:
I have found trying to quickly change a players weapon, and drop their current weapon (with client_cmd drop) to be too inefficient when dealing with players with a high latency.
Look for engclient_cmd. When using client_cmd command is firstly sent to client, then client send it to engine and as you saw it can be delayed.
engclient_cmd emulate the command and send it directly to the server. Since command is never sent to client there is no delay. As a note, if you send a command with engclient_cmd it won't be received by plugins and/or modules(a common case is when a plugin is trying to hook drop command it does register_clcmd("drop", ...)).
If you want this kind of hooking, for amxx 1.8.3 dev use amxclient_cmd. For 1.8.2 you have no way around englient_cmd, unfortunately.

Quote:
These two implementations appear to strip my weapon, but do not update my hud, I can also not attack or pick up weapons after I use these function:
fm_strip_user_weapons(id)
strip_user_weapons(id)
For your information, most of fakemeta_util functions are simply conversions from already existing modules. They are slower because of being implementated in a plugin and not in a module, and should not be used. Also fm_strip_user_weapons does not even reset the user weapon.

To update the hud you can use user_has_weapon and set the 3rd param to 0(this means weapon will be removed from player's weapon list, which fix the hud). It has the same behaviour as doing pev_weapons & ~ (1 << weaponid).

About shooting and weapon pickup something inside dll is not reset properly, but since I know nothing about TS I can't say for sure. Can you upload the linux mod dll in your next post so I can check?
__________________
HamletEagle is offline
Infest
Member
Join Date: Mar 2005
Old 09-23-2016 , 20:33   Re: [TS] Strip a players weapon?
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
Look for engclient_cmd. When using client_cmd command is firstly sent to client, then client send it to engine and as you saw it can be delayed.
engclient_cmd emulate the command and send it directly to the server. Since command is never sent to client there is no delay. As a note, if you send a command with engclient_cmd it won't be received by plugins and/or modules(a common case is when a plugin is trying to hook drop command it does register_clcmd("drop", ...)).
If you want this kind of hooking, for amxx 1.8.3 dev use amxclient_cmd. For 1.8.2 you have no way around englient_cmd, unfortunately.
Ah interesting, I wasn't aware there was a difference. I switched to engclient_cmd, although I had to add a 0.05 delay to the command, else it would crash the server. I'll test with a high latency player and see if this will work as a viable workaround.


Quote:
Originally Posted by HamletEagle View Post
To update the hud you can use user_has_weapon and set the 3rd param to 0(this means weapon will be removed from player's weapon list, which fix the hud). It has the same behaviour as doing pev_weapons & ~ (1 << weaponid).

About shooting and weapon pickup something inside dll is not reset properly, but since I know nothing about TS I can't say for sure. Can you upload the linux mod dll in your next post so I can check
user_has_weapon(id, iWeapon, 0) and set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<iWeapon)) updated the HUD unfortunately.

Here is both ts_i386.so and ts_i686.so linux dll's for you to take a look at. (not sure which one you needed)
Attached Files
File Type: so ts_i386.so (1.66 MB, 30 views)
File Type: so ts_i686.so (1.66 MB, 124 views)

Last edited by Infest; 09-23-2016 at 20:34.
Infest is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-24-2016 , 04:35   Re: [TS] Strip a players weapon?
Reply With Quote #4

Quote:
user_has_weapon(id, iWeapon, 0) and set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<iWeapon)) updated the HUD unfortunately.
It worked or not? I'm not sure to understand.
__________________
HamletEagle is offline
Infest
Member
Join Date: Mar 2005
Old 09-24-2016 , 05:02   Re: [TS] Strip a players weapon?
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
It worked or not? I'm not sure to understand.
My bad, I meant it did not update the hud correctly
Infest is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:36.


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