Would you like to react to this message? Create an account in a few clicks or log in to continue.



 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

 

 It is done!

Go down 
2 posters
AuthorMessage
[TG] Chief (alex) -Admin-
TG Leader
TG Leader
[TG] Chief (alex) -Admin-


Posts : 1525
Reputation : 59
Join date : 2009-05-17
Age : 31
Location : I am from norway, north norway!

It is done! Empty
PostSubject: It is done!   It is done! EmptySat Jan 16, 2010 12:46 am

The people have spoken.

This is the first code! Requested by Tatoma:

It finds the closest player:
Code:
function ClosestPlayer( ply )
   local target = nil
   local playerpos = ply:GetPos()
   local Distance_shortest = 999999999
   for k,v in pairs(ents.FindByClass("player")) do
      local TargetPos = v:GetPos()
      local Now_Distance = playerpos:Distance( TargetPos )
      if Now_Distance <= Distance_shortest then
         Distance_shortest = Now_Distance
         target = v
      end
   end
   if !(target == nil) then
      print("The closest player is: "..target:Nick())
      print("He/She is "..Distance_shortest.." units away!")
   else
      print("You have no target")
   end      
end
Back to top Go down
http://www.thegoatriders.com
tatoma4

tatoma4


Posts : 208
Reputation : 9
Join date : 2009-09-23
Age : 29
Location : Finland

It is done! Empty
PostSubject: Re: It is done!   It is done! EmptySat Jan 16, 2010 12:53 am

Yeippee, now we can provide other with code. Easier to spot bugs in bigger group of coders.
Back to top Go down
http://koti.mbnet.fi/tatoma/jtnepic.flv
 
It is done!
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
 :: Coding-
Jump to: