/*
AMX 2004 http://amxmod.net
no warranty, use at your own risk

  File Name: origins.sma
Script Name: Origins - XYZ
    Version: 0.1
Amx Version: 0.9.8 but sould work on 0.9.x and igher
  Tested On: 0.9.8 cs 1.6 nosteam, should work on any cs or hl mod
	     
     Author: _KaszpiR_, original idea by Galactimo
    Website: http://nvt.prv.pl/ see download section
	     
   Overview: 
	
useful for map editing 
displays origins X Y X on player hud that called a command (useful when a couple of persons are making a map togeter)
usage
amx_origins <number from 0 to 5> - get the defined origin xyz, see amx_origin 6 for help.

i suggest using amx_origins 5 so you will get all 4 numbers together, 
or binding it to a key, lets say 
bind mouse1 "+attack;amx_origin 5;wait;-attack"

or more complicated one like
bind mouse1 "+attack;amx_origin 5;wait;-attack;wait;wait;wait;wait;screenshot"

btw you better not use excessive hud displayig addons during a use of a plugin
also aim carefully

addons should work without problem in when player alive and spect mode
and under steam use condump comand and see the created files then, but i would prefer screenshot 
cause origins sometimes gives nothing without the opened map editor :P 

    Install:	
	Directions for versions AMX 0.9.7 and above (other may be sligtly different)
	put .sma to amx/examples
	run compile.bat  or ./compile
	copy amx/examples/compliled/origins.amx to amx/plugins/origins.amx
	add to amx/plugins/plugins.ini the below line
		plugins.amx
	start game with desired map
	use amx_origins 5 or similiar
    
 Known bugs:	- i hae not enough time to test it, maybe there are problems but rather 
			minor ones and concerned about spectacting while not being in bsp walls (you may get zeros then)

  Dev Notes:	
		- changge whole plugin if you want :P
  
      To Do: 
		- drawing simple things like beam or ball point on specified xyz?
		- give ideas that may help you on amx forum (find a proper thread or mail me, see www on top of this document)
 Change Log:
		0.1:
		- first beta release


*/




#include <amxmod> 



public plugin_init() 
{ 
   register_plugin("Origins - XYZ","0.1","_KaszpiR_") 
   register_clcmd("amx_origins","origins",0," <number from 0 to 5> - get the defined origin xyz, see amx_origin 6 for help.")
} 


public origins(id){
   new origin[3]
   new a[4]
/* Gets origin from player.
* Modes:
* 0 - current position.
* 1 - position from eyes (weapon aiming).
* 2 - end position from player position.
* 3 - end position from eyes (hit point for weapon). 
* 4 - position of last bullet hit (only CS). */
//native get_user_origin(index, origin[3], mode = 0);

   read_argv(1,a,4)
   new m = strtonum(a)
   if(!m) m = 0
   if(m>6 || m<0) {
      m=5
      client_print(id,print_chat,"[AMX] ORIGIN - Availale amx_origin values : ^n0 - current pos^n1 - pos from eyes^n2 - end position from player position^n3 - end position from eyes (hit point for weapon)^n - position of last bullet hit (only CS)^5 - print all above at once")
   }
 
   if(m==5){
    for(m=0;m<4;m++){
      get_user_origin(id,origin,m)
      set_hudmessage(255,200,0,0.7,0.3+m*0.05,0,0.1,30.0,0.1,0.1,m)
      show_hudmessage(id,"(m=%d) X:%d Y:%d Z:%d ",m,origin[0],origin[1],origin[2] ) 
      client_print(id,print_console,"(m=%d) X:%d Y:%d Z:%d ",m,origin[0],origin[1],origin[2] ) 
      // hmm we got 0, 1,2,3,4 =  5 lines but 4 chans alwyas one chan will be missing from the m = 5 diplya but console ouptut is okay
    }
    m++
    get_user_origin(id,origin,m)
    client_print(id,print_chat,"(m=%d) X:%d Y:%d Z:%d ",m,origin[0],origin[1],origin[2] ) 

   }
   else
   {
      get_user_origin(id,origin,m)
      set_hudmessage(255,200,0,0.7,0.3+m*0.05,0,0.1,30.0,0.1,0.1,m)
      show_hudmessage(id,"(m=%d) X:%d Y:%d Z:%d ",m,origin[0],origin[1],origin[2] ) 
      client_print(id,print_console,"(m=%d) X:%d Y:%d Z:%d ",m,origin[0],origin[1],origin[2] ) 
   }
   client_print(id,print_console,"----------------------",origin[0],origin[1],origin[2] ) 

   return PLUGIN_HANDLED
}