Raised This Month: $12 Target: $400
 3% 

[ STOCK/INC ] Find player in box


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 05-31-2018 , 16:29   [ STOCK/INC ] Find player in box
Reply With Quote #1

.: Find player in box :.



Hello, I've made this simple stock to find alive players in a imaginary box. Box color is white as default.

Usage:
Code:
/* Find player in box  *  * @param (float/vector) flVecBoxOrigin   Origin of the box at where will be created  * @param (float) flBoxSize               Size of the box  * @param (int) iDisplayBox               Time in 0.1s that the box will be stay displayed (0 doesn't show)  * @param (int) iIgnoredPlayer            Player index that won't will be checked (0 doesn't skip anyone)  *  * @return (int)    First player found index, 0 if no one was  found.  */ stock findPlayerInBox(const Float:flVecOrigin[3], Float:flBoxSize, iDisplayBox=0, iIgnoredPlayer=0)

There are several ways to customize this code, such as store all players in an array, get entities instead of players, get players on a specific team... but I'm lazy now, maybe later.
Attached Files
File Type: inc find_player_in_box.inc (2.3 KB, 204 views)
__________________









Last edited by CrazY.; 06-11-2018 at 15:34.
CrazY. is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 06-01-2018 , 07:38   Re: [ STOCK/INC ] Find player in box
Reply With Quote #2

Quote:
if (mins.x <= flVecPlayerMaxs[0]
&& mins.y <= flVecPlayerMaxs[1]
&& mins.z <= flVecPlayerMaxs[2]
&& maxs.x >= flVecPlayerMins[0]
&& maxs.y >= flVecPlayerMins[1]
&& maxs.z >= flVecPlayerMins[2])
return pPlayer;
How should this work?
__________________
My English is A0
E1_531G is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-01-2018 , 09:59   Re: [ STOCK/INC ] Find player in box
Reply With Quote #3

Basically this intersects vectors. I've updated the code, since I did wrong in that part, more precisely like c++.
__________________









Last edited by CrazY.; 06-01-2018 at 10:24.
CrazY. is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 06-01-2018 , 12:44   Re: [ STOCK/INC ] Find player in box
Reply With Quote #4

Quote:
Originally Posted by CrazY. View Post
Basically this intersects vectors. I've updated the code, since I did wrong in that part, more precisely like c++.
I know what it does. I pointed on your mistake about inexistent variables 'maxs' and 'mins' and also dot-notation.
__________________
My English is A0
E1_531G is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 06-04-2018 , 13:16   Re: [ STOCK/INC ] Find player in box
Reply With Quote #5

What if the player is just touching the box? I mean half body inside, half outside of the box.

Check code for hull collisions on sdk to understand.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-04-2018 , 13:54   Re: [ STOCK/INC ] Find player in box
Reply With Quote #6

Code doesn't detect when player touch the box, instead check if player absmin/absmax is inside of the box mins/maxs. You can start a TE_BOX message based on player's vectors to see what I'm trying to explain.
__________________








CrazY. is offline
Reply


Thread Tools
Display Modes

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 11:47.


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