
/* AMX Mod script. 
* 
* (c) Copyright 2002, OLO 
* This file is provided as is (no warranties). 
* 
*/ 


#include <amxmod> /* read this file to learn the functions */ 

/* cvars: 
*  sets frequency of scrolling message 
*  amx_scroll_time < time in sec. > 
* 
*  message to scroll at center 
*  amx_scroll_msg < message > 
* 
*/ 

new start_pos 
new end_pos 
new scroll_msg[384] 
new display_msg[384] 
new Float:x_pos 
new length 

public motd_msg() 
{ 
   new a, i = 0 
   for(a = start_pos; a < end_pos; ++a) 
      display_msg[i++] = scroll_msg[a] 
   display_msg[i] = 0 
   if (end_pos < length) 
      end_pos++ 
   if (x_pos > 0.35) 
      x_pos -= 0.0063 
   else { 
      start_pos++ 
      x_pos = 0.35 
   } 
   set_hudmessage(200, 100, 0, x_pos, 0.90, 0, 0.05, 0.15, 0.05, 0.05, 2) 
   show_hudmessage(0,display_msg) 
} 

public motd_msg_init() 
{ 
   get_cvar_string("amx_scroll_msg",scroll_msg,384) 
   new hostname[64] /* replace %hostname% with name of server */ 
   get_cvar_string("hostname",hostname,64)    
   replace(scroll_msg,384,"%hostname%",hostname) 
   length = strlen(scroll_msg) 
   end_pos = 1 
   start_pos = 0 
   x_pos = 0.65 
   set_task( 0.1 , "motd_msg",0,"",0,"a", length + 48) 
} 

public set_hud_message() 
{ 
   new Float:time = get_cvar_float("amx_scroll_time") 
   new ntime = floatround(time) 
   server_print("[AMX] Scrolling messages displaying frequency: %d:%02d.",ntime/60,ntime%60) 
   if (time > 0.0) 
      set_task(time,"motd_msg_init",0,"",0,"b") 
   else 
      server_print("[AMX] Scrolling messages disabled.") 
} 

public plugin_init() 
{ 
   register_plugin("Scrolling Messages","0.6","default") 
   register_cvar("amx_scroll_msg","") 
   register_cvar("amx_scroll_time","45") 
   set_task(5.0,"set_hud_message") /* 5 sec. after map start, initialize hud message */ 
   return PLUGIN_CONTINUE 
} 

