ItsMods
Help check Distance not working? - Printable Version

+- ItsMods (https://www.itsmods.com)
+-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html)
+--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html)
+--- Thread: Help check Distance not working? (/Thread-Help-check-Distance-not-working.html)



check Distance not working? - masterbob - 08-09-2011

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(i = 0; i < level.players.size; i++) { player = level.players[i]; playerdistance = Distance2D(location.origin,player.origin); if(isAlive(player){ if(playerdistance< 10 ){ 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?


RE: check Distance not working? - Pozzuh - 08-09-2011

Try using distance() instead of distance2d() ?


RE: check Distance not working? - masterbob - 08-09-2011

Thx but doenst work Sad


RE: check Distance not working? - Phl3x_ - 08-10-2011

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