AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Checking for a Valid Player (id) (https://forums.alliedmods.net/showthread.php?t=6527)

Mugwump 10-05-2004 12:18

Checking for a Valid Player (id)
 
After looking at some debug stack traces I see some signs that a few natives are being called with ids that do not refer to valid players, I am assuming they are 0 but havent debugged further on that end yet.

Will is_valid_ent( id ) work to tell me if a passed playerid refers to a valid player, or if not is there another preferred way to handle this?

Thanks!
-Mugwump

Votorx 10-05-2004 12:50

is_valid_ent(id) will work.

BAILOPAN 10-05-2004 13:44

is_user_connected()

Mugwump 10-05-2004 14:40

Good to know is_valid_ent() will work, thanks.

Bailopan, if is_user_connected(id) is passed an invalid ID will it simply return false or will it produce a runtime error (Invalid Player) like the fun module natives do?

-Mug

BAILOPAN 10-05-2004 14:56

is_valid_ent will return true if an entity or player entity is valid.
is_user_connected will return true if a player is connected and in game (stripped down is_valid_ent for players).

Mugwump 10-05-2004 15:22

Thats perfect then, thanks for suggesting that function.

-Mug


All times are GMT -4. The time now is 17:18.

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