Raised This Month: $ Target: $400
 0% 

[QUESTION] Checking for player alive/connected


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-23-2015 , 13:11   [QUESTION] Checking for player alive/connected
Reply With Quote #1

Is it needed to check if user is alive or connected in curweapon or ham_reload ?

also, if i want to do something with the owner of the weapon, in ham_primary_attack, for example i have this stock to get the owner
PHP Code:
stock ham_cs_get_weapon_ent_owner(entity)
{
    return 
get_pdata_cbase(entityOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS);

do i need to check if the user is connected or alive in ham_primary_attack?

Last edited by Depresie; 10-23-2015 at 13:12.
Depresie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-23-2015 , 15:15   Re: [QUESTION] Checking for player alive/connected
Reply With Quote #2

CurWeapon you do not need to check.

When you register any hook on a non-player entity, such as a weapon with Ham_PrimaryAttack or Ham_Reload, you should always check if the associated entity is a player (1-maxplayers) and if there's a chance of some delay between actions, ie a grenade throw resulting in an explosion a few seconds later, you should also check if connected. In some cases an 'is player' check may not be needed but it's a cheap check for good measure.
__________________

Last edited by Bugsy; 10-23-2015 at 15:18.
Bugsy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-24-2015 , 04:42   Re: [QUESTION] Checking for player alive/connected
Reply With Quote #3

okay, thanks bugsy ^_^
Depresie 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 22:12.


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