AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [QUESTION] Checking for player alive/connected (https://forums.alliedmods.net/showthread.php?t=273633)

Depresie 10-23-2015 13:11

[QUESTION] Checking for player alive/connected
 
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?

Bugsy 10-23-2015 15:15

Re: [QUESTION] Checking for player alive/connected
 
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.

Depresie 10-24-2015 04:42

Re: [QUESTION] Checking for player alive/connected
 
okay, thanks bugsy ^_^


All times are GMT -4. The time now is 22:12.

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