AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Checking if player is near model (https://forums.alliedmods.net/showthread.php?t=82443)

GoGoGo 12-23-2008 11:43

Checking if player is near model
 
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).

L// 12-23-2008 12:49

Re: Checking if player is near model
 
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")
    }



danielkza 12-23-2008 12:53

Re: Checking if player is near model
 
Quote:

Originally Posted by L// (Post 732052)
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);
}


GoGoGo 12-23-2008 15:32

Re: Checking if player is near model
 
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.

Exolent[jNr] 12-23-2008 15:36

Re: Checking if player is near model
 
Make sure 'distance' is a Float.
Code:
new Float:distance

GoGoGo 12-23-2008 15:51

Re: Checking if player is near model
 
Oh I had
Quote:

new float:distance
not
Quote:

new Float:distance
TNX

GoGoGo 12-23-2008 15:58

Re: Checking if player is near model
 
One more tag mismatch:

new Float:distance
distance = register_cvar("amx_dist", "300.0")
What's wrong?

shine771 12-23-2008 16:02

Re: Checking if player is near model
 
PHP Code:

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

distance get_pcvar_float(pcvar



All times are GMT -4. The time now is 09:15.

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