Raised This Month: $ Target: $400
 0% 

[HELP] Check if players aren't touching


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kapitana
Member
Join Date: Apr 2014
Old 03-12-2016 , 04:40   [HELP] Check if players aren't touching
Reply With Quote #1

Hello AlliedModders,
I know that using: register_forward(FM_Touch, "fwdTouch") checks if players are touching ... but is there a way to see if players aren't touching anymore.
If someone knows a way to do it, please share.
Thnx in advance
kapitana is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-12-2016 , 07:29   Re: [HELP] Check if players aren't touching
Reply With Quote #2

Do you want to get the moment two entities stop colliding or do you just want to check if 2 entities aren't colliding at some given moment?
klippy is offline
kapitana
Member
Join Date: Apr 2014
Old 03-12-2016 , 07:43   Re: [HELP] Check if players aren't touching
Reply With Quote #3

The moment two entities stop colliding...
kapitana is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 03-12-2016 , 07:51   Re: [HELP] Check if players aren't touching
Reply With Quote #4

if(is_user_alive(ent)) is_touching[id]=true; else is_touching[id]=false;

I mean on every touch check if touched enity is player and if it is then you set touching boolean of the player to true and if it's not player then false.

Then you just use boolean in other function, for example:

register_clcmd("say /test", "cmd_test")

public cmd_test(id)
{

if(!is_user_alive(id) || is_touching[id]) return;

//do something...

}
siriusmd99 is offline
kapitana
Member
Join Date: Apr 2014
Old 03-12-2016 , 08:00   Re: [HELP] Check if players aren't touching
Reply With Quote #5

Something like this?

public fwdTouch(booster, plr)
{
if(!(0 < plr <= maxPlayers) || !is_user_alive(plr))
return FMRES_IGNORED;

if((0 < booster <= maxPlayers) && is_user_alive(booster))
g_touched[plr] = true
else
g_touched[plr] = false

return FMRES_IGNORED;
}
kapitana is offline
kapitana
Member
Join Date: Apr 2014
Old 03-12-2016 , 08:02   Re: [HELP] Check if players aren't touching
Reply With Quote #6

I got it working! ...
Thnx for the help
kapitana is offline
SkumTomteN
Veteran Member
Join Date: Oct 2013
Location: Asgard
Old 03-12-2016 , 08:07   Re: [HELP] Check if players aren't touching
Reply With Quote #7

Edit: didnt see u got it working, just gonna leave it this here anyway.

PHP Code:
#include <amxmodx>
#include <engine>

new bool:g_Touched[33];
public 
plugin_init()
{
    
register_touch("player""player""fw_Touch")
}
public 
fw_Touch(ToucherTouched)
{
    
g_Touched[Touched] = true;
    
client_print(0print_chat"Toucher: %i | Touched: %i"ToucherTouched)

__________________
Contact: Steam
Videos: Youtube

Last edited by SkumTomteN; 03-12-2016 at 08:10.
SkumTomteN 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 20:42.


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