Raised This Month: $ Target: $400
 0% 

Problem with Ham_Item_Deploy and _cl_autowepswitch 1


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Aydeev
Junior Member
Join Date: Oct 2014
Old 11-06-2014 , 10:44   Problem with Ham_Item_Deploy and _cl_autowepswitch 1
Reply With Quote #1

Hello,

I've been using the folowing code to get a player's id when a weapon deploy is registered

PHP Code:
...
RegisterHam(Ham_Item_DeployszWeaponName"Ham_Item_Deploy_hook"0)
...

public 
Ham_Item_Deploy_hook(ent)
{

new 
userid pev(entpev_owner)

// working with the user id
//if (...

When testing with bots i noticed they were causing "index out of bounds" errors on the if statement and after some testing i figured out why:

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?
Aydeev is offline
 



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 17:44.


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