Raised This Month: $ Target: $400
 0% 

Checking if player is near model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoGoGo
Senior Member
Join Date: Apr 2008
Old 12-23-2008 , 11:43   Checking if player is near model
Reply With Quote #1

Hi,

I made a plugin who makes a model (like in Cs Surf Board) and I want to decect if palyer is near this model. I tried "FM_Touch" but you must touch model it is not what I want, I want to chceck being near model (few steps).
__________________
Aaaaaa!
GoGoGo is offline
L//
Senior Member
Join Date: Aug 2008
Location: Not found
Old 12-23-2008 , 12:49   Re: Checking if player is near model
Reply With Quote #2

Description

entity_range - Returns the distance between two entities.

Syntax

Float: entity_range ( ida, idb )

Engine code:

PHP Code:
new float:distance 500.0

public client_PreThink(id)
{
    if(
entity_range(idMY_ENT_ID) < distance)
    {
        
client_print(idprint_chat"My Stuff")
    }

L// is offline
Send a message via MSN to L//
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 12-23-2008 , 12:53   Re: Checking if player is near model
Reply With Quote #3

Quote:
Originally Posted by L// View Post
Description

entity_range - Returns the distance between two entities.

Syntax

Float: entity_range ( ida, idb )

Engine code:

PHP Code:
new float:distance 500.0

public client_PreThink(id)
{
    if(
entity_range(idMY_ENT_ID) < distance)
    {
        
client_print(idprint_chat"My Stuff")
    }

Better: <fakemeta_util>:

Code:
stock Float:fm_distance_to_box(const Float:point[3], const Float:mins[3], const Float:maxs[3]) {
    new Float:dist[3];
    for (new i = 0; i < 3; ++i) {
        if (point[i] > maxs[i])
            dist[i] = point[i] - maxs[i];
        else if (mins[i] > point[i])
            dist[i] = mins[i] - point[i];
    }

    return vector_length(dist);
}
__________________

Community / No support through PM
danielkza is offline
GoGoGo
Senior Member
Join Date: Apr 2008
Old 12-23-2008 , 15:32   Re: Checking if player is near model
Reply With Quote #4

Code:
if(entity_range(id, model) < distance ){  
    set_task(1.0,"OMG",id)
    return PLUGIN_HANDLED 
}
It shows error - tag mismatch. If you add 300.0 instead distance, the error will not appear.
__________________
Aaaaaa!
GoGoGo is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-23-2008 , 15:36   Re: Checking if player is near model
Reply With Quote #5

Make sure 'distance' is a Float.
Code:
new Float:distance
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
GoGoGo
Senior Member
Join Date: Apr 2008
Old 12-23-2008 , 15:51   Re: Checking if player is near model
Reply With Quote #6

Oh I had
Quote:
new float:distance
not
Quote:
new Float:distance
TNX
__________________
Aaaaaa!
GoGoGo is offline
GoGoGo
Senior Member
Join Date: Apr 2008
Old 12-23-2008 , 15:58   Re: Checking if player is near model
Reply With Quote #7

One more tag mismatch:

new Float:distance
distance = register_cvar("amx_dist", "300.0")
What's wrong?
__________________
Aaaaaa!
GoGoGo is offline
shine771
Senior Member
Join Date: Jun 2007
Old 12-23-2008 , 16:02   Re: Checking if player is near model
Reply With Quote #8

PHP Code:
new pcvar,Float:distance
pcvar 
register_cvar("amx_dist","300.0")

distance get_pcvar_float(pcvar
shine771 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 09:15.


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