AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_weapon or native? (https://forums.alliedmods.net/showthread.php?t=229359)

baneado 11-06-2013 08:50

get_user_weapon or native?
 
I have a simple doubt, in a plugin there is a variable that contains the current weapon having a player.
This variable exists for prevent calling get_user_weapon many times, because would be called in events like takedamage, traceattack...

The variable works perfectly in the plugin, buy I have some subplugins that are using get_user_weapon in client_PreThink or other forwards, and the question is

What is more efficient method: calling get_user_weapon or make native with the main plugin to use it instead of get_user_weapon ?

I say get_user_weapon like an example, but the same with is_user_alive, is_user_connected...

Thanks :)

^SmileY 11-06-2013 10:23

Re: get_user_weapon or native?
 
In case of get_user_weapon you allowed to cache using CurWeapon Event, and checking in takedamage or other events.

In case of is_user*, this need to be called when the function starts (takedamage, etc)

:)

alan_el_more 11-06-2013 11:09

Re: get_user_weapon or native?
 
Quote:

Originally Posted by ^SmileY (Post 2057538)
In case of get_user_weapon you allowed to cache using CurWeapon Event, and checking in takedamage or other events.

In case of is_user*, this need to be called when the function starts (takedamage, etc)

:)

You don't answer his question.
He want to know which method is more efficient

^SmileY 11-06-2013 11:16

Re: get_user_weapon or native?
 
Quote:

Originally Posted by alan_el_more (Post 2057553)
You don't answer his question.
He want to know which method is more efficient

Really? What do you think I mean by this post?
Who asked you surely know what I'm answering.

baneado 11-06-2013 12:17

Re: get_user_weapon or native?
 
Quote:

Originally Posted by ^SmileY (Post 2057556)
Really? What do you think I mean by this post?
Who asked you surely know what I'm answering.

No, you don't understand me.

^SmileY 11-06-2013 17:32

Re: get_user_weapon or native?
 
For forwards, you need to make it to use with other plugins, i recommend to use using CurWeapon event, because it is only called when player really change bettwen weapons.

:)

hornet 11-07-2013 00:20

Re: get_user_weapon or native?
 
Quote:

Originally Posted by ^SmileY (Post 2057713)
For forwards, you need to make it to use with other plugins, i recommend to use using CurWeapon event, because it is only called when player really change bettwen weapons.

:)

No not really. CurWeapon is called every time the clip ammo is updated, which means every time you fire a shot or when you change weapons.

@Baneado its hard to say unless you show your code or explain what your trying to do otherwise its really going to be XY problem. However, I can't imagine why you would need to use get_user_weapon() inside client_PreThink.

ConnorMcLeod 11-07-2013 00:47

Re: get_user_weapon or native?
 
I second that.

Anyway, your question is abstract, we need to know exactly what you are doing in plugins with PreThink so we can tell you if there are alternatives or not.
For sure, PreThink is a bad function to hook in many situations.

Phant 11-07-2013 01:07

Re: get_user_weapon or native?
 
In "miscstats" (CS) plugin we have interesting bug: when player kill another player for example, with AWP and fast switch to weapon to knife, then plugin (client_death() function) get CSW_KNIFE as weapon of kill...
This case? How to fix?

^SmileY 11-07-2013 06:00

Re: get_user_weapon or native?
 
Quote:

Originally Posted by hornet (Post 2057796)
No not really. CurWeapon is called every time the clip ammo is updated, which means every time you fire a shot or when you change weapons.

@Baneado its hard to say unless you show your code or explain what your trying to do otherwise its really going to be XY problem. However, I can't imagine why you would need to use get_user_weapon() inside client_PreThink.

Using a flag to detect if is active in CurWeapon? LOL


All times are GMT -4. The time now is 23:13.

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