Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class XTxd
- {
- text = null;
- ID = null;
- pos = null;
- col = null;
- obj = null;
- players = null;
- isvta = false;
- isrfa = false;
- //static for these
- count = [0];
- timer = [null];
- objs = [];
- constructor(str,x,y,colr) {
- count[0]++;
- if(pos==null)
- {
- pos = [0,0];
- players = [];
- }
- text = str;
- pos = [x,y];
- col = colr;
- obj = ::CreateTextdraw(str,x,y,colr);
- local did=false;
- for(local i=0;i<XTxd.objs.len();i++)
- {
- local dat = XTxd.objs[i];
- if(dat==null)
- { XTxd.objs[i] = this; did=true; ID = i; break; }
- }
- if(did!=true)
- {
- XTxd.objs.push(this);
- ID = XTxd.objs.len()-1;
- }
- if(count[0] == 1)
- {
- timer[0] = ::NewTimer("ref",1000,0);
- }
- }
- static function refresh()
- {
- for(local i=0;i<objs.len();i++)
- {
- local o = objs[i];
- if(o!=null)
- {
- o.obj.Delete();
- o.obj = ::CreateTextdraw(o.text,o.pos[0],o.pos[1],o.col);
- o.obj.SetRelativeForAll(o.isrfa);
- if(o.isvta==true) o.obj.ShowForAll();
- else if(o.players.len()>0)
- {
- foreach (plr in o.players)
- {
- o.obj.ShowForPlayer(plr);
- }
- }
- }
- }
- }
- function ShowForPlayer(player)
- {
- players.push(player);
- }
- function ShowForAll()
- {
- isvta = true;
- }
- function HideFromPlayer(player)
- {
- if(players.find(player)!=null)
- {
- players.remove(players.find(player));
- }
- }
- function HideFromAll()
- {
- isvta = false;
- }
- function SetRelativeForAll(val)
- {
- isrfa = val;
- }
- function Delete()
- {
- obj.Delete();
- objs[ID] = null;
- --count[0];
- }
- }
- function CreateXTextdraw(str,x,y,col)
- {
- return XTxd(str,x,y,col);
- }
- function FindXTextdraw(id)
- {
- for(local i=0;i<XTxd.objs.len();i++)
- {
- if(XTxd.objs[i]!=null && id == XTxd.objs[i].ID) return XTxd.objs[i];
- }
- return null;
- }
- function ref()
- {
- XTxd.refresh();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement