Problem with Ham_Item_Deploy and _cl_autowepswitch 1
Hello,
I've been using the folowing code to get a player's id when a weapon deploy is registered PHP Code:
Apparently it takes some time for pev_owner to update. If a player using _cl_autowepswitch 1 is picking up a weapon from the ground pev_owner will still be set to the entity id when the function is called. I guess a weapon on the ground is it's own owner and therefore pev_owner = entity id. So my function will give me invalid user ids. I've been trying to use set_task(1.0,...) to force a little pause and give it time to update but you can still get index out of bounds if you spam dropping weapons while facing a wall. Is there any better way to get the player id? |
Re: Problem with Ham_Item_Deploy and _cl_autowepswitch 1
PHP Code:
|
Re: Problem with Ham_Item_Deploy and _cl_autowepswitch 1
I don't understand what's going on there but it works. Thank you :)
|
Re: Problem with Ham_Item_Deploy and _cl_autowepswitch 1
You need to know that pev_owner is filled with the owner id when AttachToPlayer is called, by using the offset it's faster cause it's filled when AddToPlayer get called, which happen earlier than AttachToPlayer
|
Re: Problem with Ham_Item_Deploy and _cl_autowepswitch 1
Quote:
Thanks |
Re: Problem with Ham_Item_Deploy and _cl_autowepswitch 1
PHP Code:
|
Re: Problem with Ham_Item_Deploy and _cl_autowepswitch 1
Can you show as a full code because the snippet you posted nothing is wrong.
|
Re: Problem with Ham_Item_Deploy and _cl_autowepswitch 1
Plugin prevents players from shooting with primary weapons if blockshooting flag is set. Works on windows server, but on unix servers players can still shoot. I currently do not have access to the unix servers' logs so I can't check if it throws any error messages
PHP Code:
|
Re: Problem with Ham_Item_Deploy and _cl_autowepswitch 1
Quote:
it should be 4 not 5, because 5 is diff for player entities. For weapon ents its +4. |
Re: Problem with Ham_Item_Deploy and _cl_autowepswitch 1
What a stupid mistake to make... :cry: I was only looking at the get_pdata_cbase offset and completely forgot the other one
Thanks for your help |
| All times are GMT -4. The time now is 17:44. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.