ItsMods

Full Version: check Distance not working?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
PHP Code:
    location spawn("script_model", (0,0,0));
    
location setModel("themodel");    
    if(
getDvar("mapname") == "mp_nuked") { location.origin = (19.8764, -3.11185, -68.2495);} 
PHP Code:
    while(1)
    {
        for(
0level.players.sizei++)
        {
            
player level.players[i];
            
playerdistance Distance2D(location.origin,player.origin);
            if(
isAlive(player){
                if(
playerdistance10 ){
                    
player sayall("asdf");
                }            
            }
        }
        
wait .5;
    } 
I dont know why but the player says asdf even when the model is on the other side of the map =O Can someone pls help me?
Try using distance() instead of distance2d() ?
Thx but doenst work Sad
Try outputting the variable values at various times in the script to debug it.

iprintlnbold("Playerdistance: " + playerdistance);

You can check the values of the variables and check if there's a problem. Try it for others aswell, print out the location.origin etc