From 8d4a162014a7fb4e7f666cf118470f7ef6eb5a09 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 7 Apr 2017 14:15:00 +0100 Subject: [PATCH] Player List Updated and auto rank system --- control.lua | 2 +- source.lua | 148 +++++++++++++++++++++------------------------------- 2 files changed, 61 insertions(+), 89 deletions(-) diff --git a/control.lua b/control.lua index 18047028..65f1d1dc 100644 --- a/control.lua +++ b/control.lua @@ -1 +1 @@ -entityRemoved={}entityCache={}guis={frames={},buttons={}}defaults={itemRotated={},test=0,ranks={{name='Owner',shortHand='Owner',tag='[Owner]',power=0,colour={r=170,g=0,b=0}},{name='Community Manager',shortHand='CM',tag='[Com Mngr]',power=1,colour={r=150,g=68,b=161}},{name='Developer',shortHand='Dev',tag='[Dev]',power=1,colour={r=179,g=125,b=46}},{name='Admin',shortHand='Admin',tag='[Admin]',power=2,colour={r=170,g=41,b=170}},{name='Mod',shortHand='Mod',tag='[Mod]',power=3,colour={r=233,g=63,b=233}},{name='Donner',shortHand='P2W',tag='[P2W]',power=4,colour={r=233,g=63,b=233}},{name='Member',shortHand='Mem',tag='[Member]',power=5,colour={r=24,g=172,b=188}},{name='Regular',shortHand='Reg',tag='[Regukar]',power=5,colour={r=24,g=172,b=188}},{name='Guest',shortHand='',tag='[Guest]',power=6,colour={r=255,g=159,b=27}},{name='Jail',shortHand='Owner',tag='[Owner]',power=7,colour={r=170,g=0,b=0}}},autoRank={badgamernl='Owner',arty714='Community Manager',Cooldude2606='Developer',eissturm='Admin',PropangasEddy='Admin'}}warningAllowed=nil;timeForRegular=180;CHUNK_SIZE=32;function loadVar(a)game.print('load')if a==nil then local b=nil;if game.players[1].gui.left.hidden then b=game.players[1].gui.left.hidden.caption else b=game.players[1].gui.left.add{type='frame',name='hidden',caption=table.tostring(defaults)}.caption;game.players[1].gui.left.hidden.style.visible=false end;gTable=loadstring('return '..b)()game.print(b)else gTable=a end;itemRotated=gTable.itemRotated;test=gTable.test;ranks=gTable.ranks;autoRank=gTable.autoRank end;function saveVar()gTable.itemRotated=itemRotated;gTable.test=test;gTable.ranks=ranks;gTable.autoRank=autoRank;game.print('save '..table.tostring(gTable))game.players[1].gui.left.hidden.caption=table.tostring(gTable)end;local function c(d,e)if d.find_entities_filtered{area=e,type="decorative"}then for f,g in pairs(d.find_entities_filtered{area=e,type="decorative"})do if g.name~="red-bottleneck"and g.name~="yellow-bottleneck"and g.name~="green-bottleneck"then g.destroy()end end end end;local function h(d,i,j,k,l)c(d,{{i,j},{i+k,j+l}})end;local function m()local d=game.surfaces["nauvis"]for n in d.get_chunks()do h(d,n.x*CHUNK_SIZE,n.y*CHUNK_SIZE,CHUNK_SIZE-1,CHUNK_SIZE-1)end;callRank("Decoratives have been removed")end;script.on_event(defines.events.on_chunk_generated,function(o)c(o.surface,o.area)end)function getRank(p)if p then for f,q in pairs(ranks)do if p.tag==q.tag then return q end end end end;function stringToRank(string)if type(string)=='string'then for f,q in pairs(ranks)do if q.name==string then return q end end end end;function callRank(r,q)if q==nil then q=3 else q=q.power end;for f,p in pairs(game.players)do rankPower=getRank(p).power;if rankPower<=q then p.print(r)end end end;function ticktohour(s)local t=tostring(math.floor(s/(216000*game.speed)))return t end;function ticktominutes(s)local u=math.floor(s/(3600*game.speed))return u end;function callRank(r)for f,p in pairs(game.connected_players)do if p.admin then p.print(r)end end end;function autoMessage()game.print('There are '..#game.connected_players..' players online')game.print('This map has been on for '..ticktohour(game.tick)..' Hours and '..ticktominutes(game.tick)-60*ticktohour(game.tick)..' Minutes')game.print('Please join us on:')game.print('Discord: https://discord.gg/RPCxzgt')game.print('Forum: explosivegaming.nl')game.print('Steam: http://steamcommunity.com/groups/tntexplosivegaming')game.print('To see these links again goto: Readme > Server Info')end;function table.val_to_str(v)if"string"==type(v)then v=string.gsub(v,"\n","\\n")if string.match(string.gsub(v,"[^'\"]",""),'^"+$')then return"'"..v.."'"end;return'"'..string.gsub(v,'"','\\"')..'"'else return"table"==type(v)and table.tostring(v)or tostring(v)end end;function table.key_to_str(w)if"string"==type(w)and string.match(w,"^[_%a][_%a%d]*$")then return w else return"["..table.val_to_str(w).."]"end end;function table.tostring(x)local y,z={},{}for w,v in ipairs(x)do table.insert(y,table.val_to_str(v))z[w]=true end;for w,v in pairs(x)do if not z[w]then table.insert(y,table.key_to_str(w).."="..table.val_to_str(v))end end;return"{"..table.concat(y,",").."}"end;function addFrame(A)guis.frames[A]={}addButton('close',function(p,B)B.parent.parent.parent.destroy()end)end;function addTab(A,C,D,E)guis.frames[A][C]={C,D,E}addButton(C,function(p,B)openTab(p,B.parent.parent.parent.name,B.parent.parent.parent.tab,B.name)end)end;function addButton(F,G)guis.buttons[F]={F,G}end;function drawButton(A,F,H,D)A.add{name=F,type="button",caption=H,tooltip=D}end;function openTab(p,I,J,C)local K=p.gui.center[I].tabBarScroll.tabBar;for f,a in pairs(guis.frames[I])do if a[1]==C then K[a[1]].style.font_color={r=255,g=255,b=255,a=255}clearElement(J)a[3](p,J)else K[a[1]].style.font_color={r=100,g=100,b=100,a=255}end end end;function drawFrame(p,I,C)if p.gui.center[I]then p.gui.center[I].destroy()end;local A=p.gui.center.add{name=I,type='frame',caption=I,direction='vertical'}local L=A.add{type="scroll-pane",name="tabBarScroll",vertical_scroll_policy="never",horizontal_scroll_policy="always"}local K=L.add{type='flow',direction='horizontal',name='tabBar'}local J=A.add{type="scroll-pane",name="tab",vertical_scroll_policy="auto",horizontal_scroll_policy="never"}for f,a in pairs(guis.frames[I])do drawButton(K,a[1],a[1],a[2])end;openTab(p,I,J,C)drawButton(K,'close','Close','Close this window')J.style.minimal_height=300;J.style.maximal_height=300;J.style.minimal_width=500;J.style.maximal_width=500;L.style.minimal_height=60;L.style.maximal_height=60;L.style.minimal_width=500;L.style.maximal_width=500 end;function toggleVisable(A)if A then if A.style.visible==nil then A.style.visible=false else A.style.visible=not A.style.visible end end end;function clearElement(M)if M~=nil then for N,B in pairs(M.children_names)do M[B].destroy()end end end;script.on_event(defines.events.on_player_created,function(o)local p=game.players[o.player_index]p.insert{name="iron-plate",count=8}p.insert{name="pistol",count=1}p.insert{name="firearm-magazine",count=10}p.insert{name="burner-mining-drill",count=1}p.insert{name="stone-furnace",count=1}p.force.chart(p.surface,{{p.position.x-200,p.position.y-200},{p.position.x+200,p.position.y+200}})end)script.on_event(defines.events.on_player_respawned,function(o)local p=game.players[o.player_index]drawPlayerList()p.insert{name="pistol",count=1}p.insert{name="firearm-magazine",count=10}end)script.on_event(defines.events.on_player_joined_game,function(o)loadVar()test=test+1;saveVar()game.print(test)local p=game.players[o.player_index]p.print({"","Welcome"})if p.gui.left.PlayerList~=nil then p.gui.left.PlayerList.destroy()end;if p.gui.center.README~=nil then p.gui.center.README.destroy()end;if p.gui.top.PlayerList~=nil then p.gui.top.PlayerList.destroy()end;drawPlayerList()drawToolbar()local O=encode(game.players,"players",{"name","admin","online_time","connected","index"})game.write_file("players.json",O,false,0)if not p.admin and ticktominutes(p.online_time)<1 then drawFrame(p,'Readme','Rules')end end)script.on_event(defines.events.on_player_left_game,function(o)local p=game.players[o.player_index]drawPlayerList()end)script.on_event(defines.events.on_gui_click,function(o)local p=game.players[o.player_index]for f,P in pairs(guis.buttons)do if P[1]==o.element.name then if P[2]then P[2](p,o.element)else game.print('Invaid Button'..P[1])end;break end end;test=test+1;saveVar()game.print(test)end)script.on_event(defines.events.on_gui_text_changed,function(o)local p=game.players[o.player_index]if o.element.parent.parent.filterTable then local A=o.element;local Q={}local R=false;if A.parent.parent.parent.name=='Admin'then R=true;Q[#Q+1]='online'end;if A.parent.parent.filterTable.status_input and not R then local S=A.parent.parent.filterTable.status_input.text;if S=='yes'or S=='online'or S=='true'or S=='y'then Q[#Q+1]='online'elseif S~=''then Q[#Q+1]='offline'end end;if A.parent.parent.filterTable.hours_input then local T=A.parent.parent.filterTable.hours_input.text;if tonumber(T)and tonumber(T)>0 then Q[#Q+1]=tonumber(T)end end;if A.parent.parent.filterTable.name_input then local U=A.parent.parent.filterTable.name_input.text;if U then Q[#Q+1]=U end end;if A.parent.parent.playerTable then A.parent.parent.playerTable.destroy()end;drawPlayerTable(p,A.parent.parent,R,Q)end end)script.on_event(defines.events.on_marked_for_deconstruction,function(o)local V=game.players[o.player_index]if not V.admin and ticktominutes(V.online_time)=timeForRegular then a4.gui.left.PlayerList.PlayerListScroll.add{type="label",name=p.name,style="caption_label_style",caption={"",ticktohour(p.online_time)," H - ",p.name}}a4.gui.left.PlayerList.PlayerListScroll[p.name].style.font_color={r=24,g=172,b=188}p.tag="[Regular]"elseif p.name=="explosivegaming"then for N=10,1,-1 do a4.gui.left.PlayerList.PlayerListScroll.add{type="label",name=p.name..N,style="caption_label_style",caption={"",ticktohour(p.online_time)," H - ",p.name,N}}a4.gui.left.PlayerList.PlayerListScroll[p.name..N].style.font_color={r=24,g=172,b=188}p.tag="[TEST]"end else a4.gui.left.PlayerList.PlayerListScroll.add{type="label",name=p.name,style="caption_label_style",caption={"",ticktohour(p.online_time)," H - ",p.name}}a4.gui.left.PlayerList.PlayerListScroll[p.name].style.font_color={r=255,g=159,b=27}p.tag="[Guest]"end end end end end;addButton('goto',function(p,A)local a5=game.players[A.parent.name]p.teleport(game.surfaces[a5.surface.name].find_non_colliding_position("player",a5.position,32,1))end)addButton('bring',function(p,A)local a5=game.players[A.parent.name]a5.teleport(game.surfaces[p.surface.name].find_non_colliding_position("player",p.position,32,1))end)addButton('jail',function(p,A)local a5=game.players[A.parent.name]if a5.character then if a5.character.active then a5.character.active=false;a5.tag='[Jail]'drawPlayerList()else a5.character.active=true;a5.tag='[Guest]'drawPlayerList()end end end)addButton('kill',function(p,A)local a5=game.players[A.parent.name]if a5.character then a5.character.die()end end)function drawPlayerTable(p,A,R,Q)A.add{name='playerTable',type="table",colspan=5}A.playerTable.style.minimal_width=500;A.playerTable.style.maximal_width=500;A.playerTable.style.horizontal_spacing=10;A.playerTable.add{name="id",type="label",caption="Id "}A.playerTable.add{name="name",type="label",caption="Name "}if not R then A.playerTable.add{name="status",type="label",caption="Status "}end;A.playerTable.add{name="online_time",type="label",caption="Online Time "}A.playerTable.add{name="rank",type="label",caption="Rank "}if R then A.playerTable.add{name="commands",type="label",caption="Commands"}end;for N,a5 in pairs(game.players)do local a6=true;for f,a7 in pairs(Q)do if a7=='admin'then if a5.admin==false then a6=false;break end elseif a7=='online'then if a5.connected==false then a6=false;break end elseif a7=='offline'then if a5.connected==true then a6=false;break end elseif type(a7)=='number'then if a7>ticktominutes(a5.online_time)then a6=false;break end elseif type(a7)=='string'then if a5.name:lower():find(a7:lower())==nil then a6=false;break end end end;if a6==true and p.name~=a5.name then if A.playerTable[a5.name]==nil then A.playerTable.add{name=N.."id",type="label",caption=N}A.playerTable.add{name=a5.name..'_name',type="label",caption=a5.name}if not R then if a5.connected==true then A.playerTable.add{name=a5.name.."Status",type="label",caption="ONLINE"}else A.playerTable.add{name=a5.name.."Status",type="label",caption="OFFLINE"}end end;A.playerTable.add{name=a5.name.."Online_Time",type="label",caption=ticktohour(a5.online_time)..'H '..ticktominutes(a5.online_time)-60*ticktohour(a5.online_time)..'M'}A.playerTable.add{name=a5.name.."Rank",type="label",caption=a5.tag}if R then A.playerTable.add{name=a5.name,type="flow"}drawButton(A.playerTable[a5.name],'goto','Tp','Goto to the players location')drawButton(A.playerTable[a5.name],'bring','Br','Bring a player to your location')if a5.tag=='[Owner]'or a5.tag=='[Developer]'or a5.tag=='[Com Mngr]'then else drawButton(A.playerTable[a5.name],'jail','Ja','Jail/Unjail a player')drawButton(A.playerTable[a5.name],'kill','Ki','Kill this player')end end end end end end;addFrame('Readme')addTab('Readme','Rules','The rules of the server',function(p,A)local a8={"Hacking/cheating, exploiting and abusing bugs is not allowed.","Do not disrespect any player in the server (This includes staff).","Do not spam, this includes stuff such as chat spam, item spam, chest spam etc.","Do not laydown concrete with bots without permission.","Do not use active provider chests without permission.","Do not remove/move major parts of the factory without permission.","Do not walk in a random direction for no reason(to save map size).","Do not remove stuff just because you don't like it, tell people first.","Do not make train roundabouts.","Trains are Left Hand Drive (LHD) only.","Do not complain about lag, low fps and low ups or other things like that.","Do not ask for rank.","Use common sense and what an admin says goes."}for N,a9 in pairs(a8)do A.add{name=N,type="label",caption={"",N,". ",a9}}end end)addTab('Readme','Server Info','Info about the server',function(p,A)A.add{name=1,type="label",caption={"","Discord voice and chat server:"}}A.add{name=2,type='textfield',text='https://discord.gg/RPCxzgt'}.style.minimal_width=400;A.add{name=3,type="label",caption={"","Our forum:"}}A.add{name=4,type='textfield',text='https://explosivegaming.nl'}.style.minimal_width=400;A.add{name=5,type="label",caption={"","Steam:"}}A.add{name=6,type='textfield',text='http://steamcommunity.com/groups/tntexplosivegaming'}.style.minimal_width=400 end)addTab('Readme','How to chat','Just in case you dont know how to chat',function(p,A)local aa={"Chatting for new players can be difficult because it’s different than other games!","It’s very simple, the button you need to press is the “GRAVE/TILDE key”","it’s located under the “ESC key”. If you would like to change the key go to your","controls tab in options. The key you need to change is “Toggle Lua console”","it’s located in the second column 2nd from bottom."}for N,ab in pairs(aa)do A.add{name=N,type="label",caption={"",ab}}end end)addTab('Readme','Admins','List of all the people who can ban you :P',function(p,A)local ac={"This list contains all the people that are admin in this world. Do you want to become","an admin dont ask for it! an admin will see what you've made and the time you put","in the server."}for N,ab in pairs(ac)do A.add{name=N,type="label",caption={"",ab}}end;drawPlayerTable(p,A,false,{'admin'})end)addTab('Readme','Players','List of all the people who have been on the server',function(p,A)local ad={"These are the players who have supported us in the making of this factory. Without","you the player we wouldn't have been as far as we are now."}for N,ab in pairs(ad)do A.add{name=N,type="label",caption={"",ab}}end;A.add{name='filterTable',type='table',colspan=3}A.filterTable.add{name='name_label',type='label',caption='Name'}A.filterTable.add{name='status_label',type='label',caption='Online?'}A.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}A.filterTable.add{name='name_input',type='textfield'}A.filterTable.add{name='status_input',type='textfield'}A.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(p,A,false,{})end)addFrame('Admin')addButton('btn_toolbar_automessage',function()autoMessage()end)addButton('revive_dead_entitys',function(p,A)for ae,g in pairs(game.surfaces[1].find_entities_filtered({type="entity-ghost"}))do g.revive()end end)addButton('revive_dead_entitys_range',function(p,A)if tonumber(A.parent.range.text)then local af=tonumber(A.parent.range.text)for ae,g in pairs(game.surfaces[1].find_entities_filtered({area={{p.position.x-af,p.position.y-af},{p.position.x+af,p.position.y+af}},type="entity-ghost"}))do g.revive()end end end)addButton('remove_biters',function(p,A)for ae,g in pairs(game.surfaces[1].find_entities_filtered({force='enemy'}))do g.destroy()end end)addButton('tp_all',function(p,A)for N,a5 in pairs(game.connected_players)do local ag=game.surfaces[p.surface.name].find_non_colliding_position("player",p.position,32,1)if a5~=p then a5.teleport(ag)end end end)addButton('toggle_cheat',function(p,A)p.cheat_mode=not p.cheat_mode end)addButton('add_dev_items',function(p,A)p.insert{name="deconstruction-planner",count=1}p.insert{name="blueprint-book",count=1}p.insert{name="blueprint",count=20}end)addButton("btn_Modifier_apply",function(p,A)local ah={"manual_mining_speed_modifier","manual_crafting_speed_modifier","character_running_speed_modifier","worker_robots_speed_modifier","worker_robots_storage_bonus","character_build_distance_bonus","character_item_drop_distance_bonus","character_reach_distance_bonus","character_resource_reach_distance_bonus","character_item_pickup_distance_bonus","character_loot_pickup_distance_bonus"}for N,ai in pairs(ah)do local aj=tonumber(A.parent.parent.modifierTable[ai.."_input"].text:match("[%d]+[.%d+]"))if aj~=nil then if aj>=0 and aj<50 and aj~=p.force[ai]then p.force[ai]=aj;p.print(ai.." changed to number: "..tostring(aj))elseif aj==p.force[ai]then p.print(ai.." Did not change")else p.print(ai.." needs to be a higher number or it contains an letter")end end end end)addTab('Admin','Commands','Random useful commands',function(p,A)drawButton(A,'btn_toolbar_automessage','Auto Message','Send the auto message to all online players')drawButton(A,'add_dev_items','Get Blueprints','Get all the blueprints')drawButton(A,'revive_dead_entitys','Revive All Entitys','Brings all dead machines back to life')drawButton(A,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in a range')A.add{type='textfield',name='range',text='Range'}drawButton(A,'remove_biters','Kill Biters','Removes all biters in map')drawButton(A,'tp_all','TP All Here','Brings all players to you')drawButton(A,'toggle_cheat','Toggle Cheat Mode','Toggle your cheat mode')end)addTab('Admin','Modifiers','Edit in game modifiers',function(p,A)local ah={"manual_mining_speed_modifier","manual_crafting_speed_modifier","character_running_speed_modifier","worker_robots_speed_modifier","worker_robots_storage_bonus","character_build_distance_bonus","character_item_drop_distance_bonus","character_reach_distance_bonus","character_resource_reach_distance_bonus","character_item_pickup_distance_bonus","character_loot_pickup_distance_bonus"}A.add{type="flow",name="flowNavigation",direction="horizontal"}A.add{name="modifierTable",type="table",colspan=3}A.modifierTable.add{name="name",type="label",caption="name"}A.modifierTable.add{name="input",type="label",caption="input"}A.modifierTable.add{name="current",type="label",caption="current"}for N,ai in pairs(ah)do A.modifierTable.add{name=ai,type="label",caption=ai}A.modifierTable.add{name=ai.."_input",type="textfield",caption="inputTextField"}A.modifierTable.add{name=ai.."_current",type="label",caption=tostring(p.force[ai])}end;drawButton(A.flowNavigation,"btn_Modifier_apply","Apply","Apply the new values to the game")end)addTab('Admin','Player List','Send a message to all players',function(p,A)A.add{name='filterTable',type='table',colspan=2}A.filterTable.add{name='name_label',type='label',caption='Name'}A.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}A.filterTable.add{name='name_input',type='textfield'}A.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(p,A,true,{'online'})end) \ No newline at end of file +entityRemoved={}entityCache={}guis={frames={},buttons={}}defaults={itemRotated={},ranks={{name='Owner',shortHand='Owner',tag='[Owner]',power=0,colour={r=170,g=0,b=0}},{name='Community Manager',shortHand='CM',tag='[Com Mngr]',power=1,colour={r=150,g=68,b=161}},{name='Developer',shortHand='Dev',tag='[Dev]',power=1,colour={r=179,g=125,b=46}},{name='Admin',shortHand='Admin',tag='[Admin]',power=2,colour={r=170,g=41,b=170}},{name='Mod',shortHand='Mod',tag='[Mod]',power=3,colour={r=233,g=63,b=233}},{name='Donner',shortHand='P2W',tag='[P2W]',power=4,colour={r=233,g=63,b=233}},{name='Member',shortHand='Mem',tag='[Member]',power=5,colour={r=24,g=172,b=188}},{name='Regular',shortHand='Reg',tag='[Regukar]',power=5,colour={r=24,g=172,b=188}},{name='Guest',shortHand='',tag='[Guest]',power=6,colour={r=255,g=159,b=27}},{name='Jail',shortHand='Owner',tag='[Owner]',power=7,colour={r=170,g=0,b=0}}},autoRanks={badgamernl='Owner',arty714='Community Manager',Cooldude2606='Developer',eissturm='Admin',PropangasEddy='Admin'}}warningAllowed=nil;timeForRegular=180;CHUNK_SIZE=32;function loadVar(a)if a==nil then local b=nil;if game.players[1].gui.left.hidden then b=game.players[1].gui.left.hidden.caption else b=game.players[1].gui.left.add{type='frame',name='hidden',caption=table.tostring(defaults)}.caption;game.players[1].gui.left.hidden.style.visible=false end;gTable=loadstring('return '..b)()else gTable=a end;itemRotated=gTable.itemRotated;ranks=gTable.ranks;autoRanks=gTable.autoRanks end;function saveVar()gTable.itemRotated=itemRotated;gTable.ranks=ranks;gTable.autoRanks=autoRanks;game.players[1].gui.left.hidden.caption=table.tostring(gTable)end;local function c(d,e)if d.find_entities_filtered{area=e,type="decorative"}then for f,g in pairs(d.find_entities_filtered{area=e,type="decorative"})do if g.name~="red-bottleneck"and g.name~="yellow-bottleneck"and g.name~="green-bottleneck"then g.destroy()end end end end;local function h(d,i,j,k,l)c(d,{{i,j},{i+k,j+l}})end;local function m()local d=game.surfaces["nauvis"]for n in d.get_chunks()do h(d,n.x*CHUNK_SIZE,n.y*CHUNK_SIZE,CHUNK_SIZE-1,CHUNK_SIZE-1)end;callRank("Decoratives have been removed")end;script.on_event(defines.events.on_chunk_generated,function(o)c(o.surface,o.area)end)function getRank(p)if p then for f,q in pairs(ranks)do if p.tag==q.tag then return q end end;return stringToRank('Guest')end end;function stringToRank(string)if type(string)=='string'then for f,q in pairs(ranks)do if q.name==string then return q end end end end;function callRank(r,q)if q==nil then q=stringToRank('Mod')else q=stringToRank(q)end;for f,p in pairs(game.players)do rankPower=getRank(p).power;if rankPower<=q.power then p.print('['..q.shortHand..']: '..r)end end end;function autoRank(p)currentRank=getRank(p)if autoRanks[p.name]then if currentRank.power>stringToRank(autoRanks[p.name]).power then p.tag=stringToRank(autoRanks[p.name]).tag;if getRank(p).power<=3 and not p.admin then callRank(p.name..' needs to be promoted.')end end elseif ticktominutes(p.online_time)>=timeForRegular then p.tag=stringToRank('Regular').tag end end;function ticktohour(s)local t=tostring(math.floor(s/(216000*game.speed)))return t end;function ticktominutes(s)local u=math.floor(s/(3600*game.speed))return u end;function callRank(r)for f,p in pairs(game.connected_players)do if p.admin then p.print(r)end end end;function autoMessage()game.print('There are '..#game.connected_players..' players online')game.print('This map has been on for '..ticktohour(game.tick)..' Hours and '..ticktominutes(game.tick)-60*ticktohour(game.tick)..' Minutes')game.print('Please join us on:')game.print('Discord: https://discord.gg/RPCxzgt')game.print('Forum: explosivegaming.nl')game.print('Steam: http://steamcommunity.com/groups/tntexplosivegaming')game.print('To see these links again goto: Readme > Server Info')end;function table.val_to_str(v)if"string"==type(v)then v=string.gsub(v,"\n","\\n")if string.match(string.gsub(v,"[^'\"]",""),'^"+$')then return"'"..v.."'"end;return'"'..string.gsub(v,'"','\\"')..'"'else return"table"==type(v)and table.tostring(v)or tostring(v)end end;function table.key_to_str(w)if"string"==type(w)and string.match(w,"^[_%player][_%player%d]*$")then return w else return"["..table.val_to_str(w).."]"end end;function table.tostring(x)local y,z={},{}for w,v in ipairs(x)do table.insert(y,table.val_to_str(v))z[w]=true end;for w,v in pairs(x)do if not z[w]then table.insert(y,table.key_to_str(w).."="..table.val_to_str(v))end end;return"{"..table.concat(y,",").."}"end;function addFrame(A)guis.frames[A]={}addButton('close',function(p,B)B.parent.parent.parent.destroy()end)end;function addTab(A,C,D,E)guis.frames[A][C]={C,D,E}addButton(C,function(p,B)openTab(p,B.parent.parent.parent.name,B.parent.parent.parent.tab,B.name)end)end;function addButton(F,G)guis.buttons[F]={F,G}end;function drawButton(A,F,H,D)A.add{name=F,type="button",caption=H,tooltip=D}end;function openTab(p,I,J,C)local K=p.gui.center[I].tabBarScroll.tabBar;for f,a in pairs(guis.frames[I])do if a[1]==C then K[a[1]].style.font_color={r=255,g=255,b=255,player=255}clearElement(J)a[3](p,J)else K[a[1]].style.font_color={r=100,g=100,b=100,player=255}end end end;function drawFrame(p,I,C)if p.gui.center[I]then p.gui.center[I].destroy()end;local A=p.gui.center.add{name=I,type='frame',caption=I,direction='vertical'}local L=A.add{type="scroll-pane",name="tabBarScroll",vertical_scroll_policy="never",horizontal_scroll_policy="always"}local K=L.add{type='flow',direction='horizontal',name='tabBar'}local J=A.add{type="scroll-pane",name="tab",vertical_scroll_policy="auto",horizontal_scroll_policy="never"}for f,a in pairs(guis.frames[I])do drawButton(K,a[1],a[1],a[2])end;openTab(p,I,J,C)drawButton(K,'close','Close','Close this window')J.style.minimal_height=300;J.style.maximal_height=300;J.style.minimal_width=500;J.style.maximal_width=500;L.style.minimal_height=60;L.style.maximal_height=60;L.style.minimal_width=500;L.style.maximal_width=500 end;function toggleVisable(A)if A then if A.style.visible==nil then A.style.visible=false else A.style.visible=not A.style.visible end end end;function clearElement(M)if M~=nil then for N,B in pairs(M.children_names)do M[B].destroy()end end end;script.on_event(defines.events.on_player_created,function(o)local p=game.players[o.player_index]p.insert{name="iron-plate",count=8}p.insert{name="pistol",count=1}p.insert{name="firearm-magazine",count=10}p.insert{name="burner-mining-drill",count=1}p.insert{name="stone-furnace",count=1}p.force.chart(p.surface,{{p.position.x-200,p.position.y-200},{p.position.x+200,p.position.y+200}})end)script.on_event(defines.events.on_player_respawned,function(o)local p=game.players[o.player_index]drawPlayerList()p.insert{name="pistol",count=1}p.insert{name="firearm-magazine",count=10}end)script.on_event(defines.events.on_player_joined_game,function(o)loadVar()local p=game.players[o.player_index]autoRank(p)p.print({"","Welcome"})if p.gui.left.PlayerList~=nil then p.gui.left.PlayerList.destroy()end;if p.gui.center.README~=nil then p.gui.center.README.destroy()end;if p.gui.top.PlayerList~=nil then p.gui.top.PlayerList.destroy()end;drawPlayerList()drawToolbar(p)local O=encode(game.players,"players",{"name","admin","online_time","connected","index"})game.write_file("players.json",O,false,0)if not p.admin and ticktominutes(p.online_time)<1 then drawFrame(p,'Readme','Rules')end end)script.on_event(defines.events.on_player_left_game,function(o)local p=game.players[o.player_index]drawPlayerList()end)script.on_event(defines.events.on_gui_click,function(o)local p=game.players[o.player_index]for f,P in pairs(guis.buttons)do if P[1]==o.element.name then if P[2]then P[2](p,o.element)else game.print('Invaid Button'..P[1])end;break end end end)script.on_event(defines.events.on_gui_text_changed,function(o)local p=game.players[o.player_index]if o.element.parent.parent.filterTable then local A=o.element;local Q={}local R=false;if A.parent.parent.parent.name=='Admin'then R=true;Q[#Q+1]='online'end;if A.parent.parent.filterTable.status_input and not R then local S=A.parent.parent.filterTable.status_input.text;if S=='yes'or S=='online'or S=='true'or S=='y'then Q[#Q+1]='online'elseif S~=''then Q[#Q+1]='offline'end end;if A.parent.parent.filterTable.hours_input then local T=A.parent.parent.filterTable.hours_input.text;if tonumber(T)and tonumber(T)>0 then Q[#Q+1]=tonumber(T)end end;if A.parent.parent.filterTable.name_input then local U=A.parent.parent.filterTable.name_input.text;if U then Q[#Q+1]=U end end;if A.parent.parent.playerTable then A.parent.parent.playerTable.destroy()end;drawPlayerTable(p,A.parent.parent,R,Q)end end)script.on_event(defines.events.on_marked_for_deconstruction,function(o)local V=game.players[o.player_index]if not V.admin and ticktominutes(V.online_time)3 then Plist.add{type="label",name=p.name,style="caption_label_style",caption={"",ticktohour(p.online_time)," H - ",p.name,' - '..playerRank.shortHand}}Plist[p.name].style.font_color=playerRank.colour;p.tag=playerRank.tag end end end end;addButton('goto',function(p,A)local a4=game.players[A.parent.name]p.teleport(game.surfaces[a4.surface.name].find_non_colliding_position("player",a4.position,32,1))end)addButton('bring',function(p,A)local a4=game.players[A.parent.name]a4.teleport(game.surfaces[p.surface.name].find_non_colliding_position("player",p.position,32,1))end)addButton('jail',function(p,A)local a4=game.players[A.parent.name]if a4.character then if a4.character.active then a4.character.active=false;a4.tag='[Jail]'drawPlayerList()else a4.character.active=true;a4.tag='[Guest]'drawPlayerList()end end end)addButton('kill',function(p,A)local a4=game.players[A.parent.name]if a4.character then a4.character.die()end end)function drawPlayerTable(p,A,R,Q)A.add{name='playerTable',type="table",colspan=5}A.playerTable.style.minimal_width=500;A.playerTable.style.maximal_width=500;A.playerTable.style.horizontal_spacing=10;A.playerTable.add{name="id",type="label",caption="Id "}A.playerTable.add{name="name",type="label",caption="Name "}if not R then A.playerTable.add{name="status",type="label",caption="Status "}end;A.playerTable.add{name="online_time",type="label",caption="Online Time "}A.playerTable.add{name="rank",type="label",caption="Rank "}if R then A.playerTable.add{name="commands",type="label",caption="Commands"}end;for N,a4 in pairs(game.players)do local a5=true;for f,a6 in pairs(Q)do if a6=='admin'then if a4.admin==false then a5=false;break end elseif a6=='online'then if a4.connected==false then a5=false;break end elseif a6=='offline'then if a4.connected==true then a5=false;break end elseif type(a6)=='number'then if a6>ticktominutes(a4.online_time)then a5=false;break end elseif type(a6)=='string'then if a4.name:lower():find(a6:lower())==nil then a5=false;break end end end;if a5==true and p.name~=a4.name then if A.playerTable[a4.name]==nil then A.playerTable.add{name=N.."id",type="label",caption=N}A.playerTable.add{name=a4.name..'_name',type="label",caption=a4.name}if not R then if a4.connected==true then A.playerTable.add{name=a4.name.."Status",type="label",caption="ONLINE"}else A.playerTable.add{name=a4.name.."Status",type="label",caption="OFFLINE"}end end;A.playerTable.add{name=a4.name.."Online_Time",type="label",caption=ticktohour(a4.online_time)..'H '..ticktominutes(a4.online_time)-60*ticktohour(a4.online_time)..'M'}A.playerTable.add{name=a4.name.."Rank",type="label",caption=a4.tag}if R then A.playerTable.add{name=a4.name,type="flow"}drawButton(A.playerTable[a4.name],'goto','Tp','Goto to the players location')drawButton(A.playerTable[a4.name],'bring','Br','Bring player player to your location')if a4.tag=='[Owner]'or a4.tag=='[Developer]'or a4.tag=='[Com Mngr]'then else drawButton(A.playerTable[a4.name],'jail','Ja','Jail/Unjail player player')drawButton(A.playerTable[a4.name],'kill','Ki','Kill this player')end end end end end end;addFrame('Readme')addTab('Readme','Rules','The rules of the server',function(p,A)local a7={"Hacking/cheating, exploiting and abusing bugs is not allowed.","Do not disrespect any player in the server (This includes staff).","Do not spam, this includes stuff such as chat spam, item spam, chest spam etc.","Do not laydown concrete with bots without permission.","Do not use active provider chests without permission.","Do not remove/move major parts of the factory without permission.","Do not walk in player random direction for no reason(to save map size).","Do not remove stuff just because you don't like it, tell people first.","Do not make train roundabouts.","Trains are Left Hand Drive (LHD) only.","Do not complain about lag, low fps and low ups or other things like that.","Do not ask for rank.","Use common sense and what an admin says goes."}for N,a8 in pairs(a7)do A.add{name=N,type="label",caption={"",N,". ",a8}}end end)addTab('Readme','Server Info','Info about the server',function(p,A)A.add{name=1,type="label",caption={"","Discord voice and chat server:"}}A.add{name=2,type='textfield',text='https://discord.gg/RPCxzgt'}.style.minimal_width=400;A.add{name=3,type="label",caption={"","Our forum:"}}A.add{name=4,type='textfield',text='https://explosivegaming.nl'}.style.minimal_width=400;A.add{name=5,type="label",caption={"","Steam:"}}A.add{name=6,type='textfield',text='http://steamcommunity.com/groups/tntexplosivegaming'}.style.minimal_width=400 end)addTab('Readme','How to chat','Just in case you dont know how to chat',function(p,A)local a9={"Chatting for new players can be difficult because it’s different than other games!","It’s very simple, the button you need to press is the “GRAVE/TILDE key”","it’s located under the “ESC key”. If you would like to change the key go to your","controls tab in options. The key you need to change is “Toggle Lua console”","it’s located in the second column 2nd from bottom."}for N,aa in pairs(a9)do A.add{name=N,type="label",caption={"",aa}}end end)addTab('Readme','Admins','List of all the people who can ban you :P',function(p,A)local ab={"This list contains all the people that are admin in this world. Do you want to become","an admin dont ask for it! an admin will see what you've made and the time you put","in the server."}for N,aa in pairs(ab)do A.add{name=N,type="label",caption={"",aa}}end;drawPlayerTable(p,A,false,{'admin'})end)addTab('Readme','Players','List of all the people who have been on the server',function(p,A)local ac={"These are the players who have supported us in the making of this factory. Without","you the player we wouldn't have been as far as we are now."}for N,aa in pairs(ac)do A.add{name=N,type="label",caption={"",aa}}end;A.add{name='filterTable',type='table',colspan=3}A.filterTable.add{name='name_label',type='label',caption='Name'}A.filterTable.add{name='status_label',type='label',caption='Online?'}A.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}A.filterTable.add{name='name_input',type='textfield'}A.filterTable.add{name='status_input',type='textfield'}A.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(p,A,false,{})end)addFrame('Admin')addButton('btn_toolbar_automessage',function()autoMessage()end)addButton('revive_dead_entitys',function(p,A)for ad,g in pairs(game.surfaces[1].find_entities_filtered({type="entity-ghost"}))do g.revive()end end)addButton('revive_dead_entitys_range',function(p,A)if tonumber(A.parent.range.text)then local ae=tonumber(A.parent.range.text)for ad,g in pairs(game.surfaces[1].find_entities_filtered({area={{p.position.x-ae,p.position.y-ae},{p.position.x+ae,p.position.y+ae}},type="entity-ghost"}))do g.revive()end end end)addButton('remove_biters',function(p,A)for ad,g in pairs(game.surfaces[1].find_entities_filtered({force='enemy'}))do g.destroy()end end)addButton('tp_all',function(p,A)for N,a4 in pairs(game.connected_players)do local af=game.surfaces[p.surface.name].find_non_colliding_position("player",p.position,32,1)if a4~=p then a4.teleport(af)end end end)addButton('toggle_cheat',function(p,A)p.cheat_mode=not p.cheat_mode end)addButton('add_dev_items',function(p,A)p.insert{name="deconstruction-planner",count=1}p.insert{name="blueprint-book",count=1}p.insert{name="blueprint",count=20}end)addButton("btn_Modifier_apply",function(p,A)local ag={"manual_mining_speed_modifier","manual_crafting_speed_modifier","character_running_speed_modifier","worker_robots_speed_modifier","worker_robots_storage_bonus","character_build_distance_bonus","character_item_drop_distance_bonus","character_reach_distance_bonus","character_resource_reach_distance_bonus","character_item_pickup_distance_bonus","character_loot_pickup_distance_bonus"}for N,ah in pairs(ag)do local ai=tonumber(A.parent.parent.modifierTable[ah.."_input"].text:match("[%d]+[.%d+]"))if ai~=nil then if ai>=0 and ai<50 and ai~=p.force[ah]then p.force[ah]=ai;p.print(ah.." changed to number: "..tostring(ai))elseif ai==p.force[ah]then p.print(ah.." Did not change")else p.print(ah.." needs to be player higher number or it contains an letter")end end end end)addTab('Admin','Commands','Random useful commands',function(p,A)drawButton(A,'btn_toolbar_automessage','Auto Message','Send the auto message to all online players')drawButton(A,'add_dev_items','Get Blueprints','Get all the blueprints')drawButton(A,'revive_dead_entitys','Revive All Entitys','Brings all dead machines back to life')drawButton(A,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in player range')A.add{type='textfield',name='range',text='Range'}drawButton(A,'remove_biters','Kill Biters','Removes all biters in map')drawButton(A,'tp_all','TP All Here','Brings all players to you')drawButton(A,'toggle_cheat','Toggle Cheat Mode','Toggle your cheat mode')end)addTab('Admin','Modifiers','Edit in game modifiers',function(p,A)local ag={"manual_mining_speed_modifier","manual_crafting_speed_modifier","character_running_speed_modifier","worker_robots_speed_modifier","worker_robots_storage_bonus","character_build_distance_bonus","character_item_drop_distance_bonus","character_reach_distance_bonus","character_resource_reach_distance_bonus","character_item_pickup_distance_bonus","character_loot_pickup_distance_bonus"}A.add{type="flow",name="flowNavigation",direction="horizontal"}A.add{name="modifierTable",type="table",colspan=3}A.modifierTable.add{name="name",type="label",caption="name"}A.modifierTable.add{name="input",type="label",caption="input"}A.modifierTable.add{name="current",type="label",caption="current"}for N,ah in pairs(ag)do A.modifierTable.add{name=ah,type="label",caption=ah}A.modifierTable.add{name=ah.."_input",type="textfield",caption="inputTextField"}A.modifierTable.add{name=ah.."_current",type="label",caption=tostring(p.force[ah])}end;drawButton(A.flowNavigation,"btn_Modifier_apply","Apply","Apply the new values to the game")end)addTab('Admin','Player List','Send player message to all players',function(p,A)A.add{name='filterTable',type='table',colspan=2}A.filterTable.add{name='name_label',type='label',caption='Name'}A.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}A.filterTable.add{name='name_input',type='textfield'}A.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(p,A,true,{'online'})end) \ No newline at end of file diff --git a/source.lua b/source.lua index 18c1b9a1..1b77b853 100644 --- a/source.lua +++ b/source.lua @@ -5,7 +5,6 @@ guis = {frames={},buttons={}} --functions can not be included in the default list or be added by code defaults = { itemRotated = {}, - test = 0, ranks={ {name='Owner',shortHand='Owner',tag='[Owner]',power=0,colour={r=170,g=0,b=0}}, {name='Community Manager',shortHand='CM',tag='[Com Mngr]',power=1,colour={r=150,g=68,b=161}}, @@ -18,7 +17,7 @@ defaults = { {name='Guest',shortHand='',tag='[Guest]',power=6,colour={r=255,g=159,b=27}}, {name='Jail',shortHand='Owner',tag='[Owner]',power=7,colour={r=170,g=0,b=0}} }, - autoRank={ + autoRanks={ badgamernl='Owner', arty714='Community Manager', Cooldude2606='Developer', @@ -32,7 +31,6 @@ timeForRegular = 180 CHUNK_SIZE = 32 function loadVar(t) - game.print('load') if t == nil then local g = nil if game.players[1].gui.left.hidden then @@ -42,20 +40,16 @@ function loadVar(t) game.players[1].gui.left.hidden.style.visible = false end gTable = loadstring('return '..g)() - game.print(g) else gTable = t end itemRotated = gTable.itemRotated - test = gTable.test ranks= gTable.ranks - autoRank= gTable.autoRank + autoRanks= gTable.autoRanks end function saveVar() gTable.itemRotated = itemRotated - gTable.test = test gTable.ranks = ranks - gTable.autoRank = autoRank - game.print('save '..table.tostring(gTable)) + gTable.autoRanks = autoRanks game.players[1].gui.left.hidden.caption = table.tostring(gTable) end ---------------------------------------------------------------------------------------- @@ -94,6 +88,7 @@ function getRank(player) for _,rank in pairs(ranks) do if player.tag == rank.tag then return rank end end + return stringToRank('Guest') end end @@ -106,10 +101,24 @@ function stringToRank(string) end function callRank(msg, rank) - if rank == nil then rank = 3 else rank = rank.power end -- default mod or higher + if rank == nil then rank = stringToRank('Mod') else rank = stringToRank(rank) end -- default mod or higher for _, player in pairs(game.players) do rankPower = getRank(player).power - if rankPower <= rank then player.print(msg) end + if rankPower <= rank.power then player.print('['..rank.shortHand..']: '..msg) end + end +end + +function autoRank(player) + currentRank = getRank(player) + if autoRanks[player.name] then + if currentRank.power > stringToRank(autoRanks[player.name]).power then + player.tag=stringToRank(autoRanks[player.name]).tag + if getRank(player).power <= 3 and not player.admin then + callRank(player.name..' needs to be promoted.') + end + end + elseif ticktominutes(player.online_time) >= timeForRegular then + player.tag=stringToRank('Regular').tag end end ---------------------------------------------------------------------------------------- @@ -159,7 +168,7 @@ function table.val_to_str ( v ) end function table.key_to_str ( k ) - if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then + if "string" == type( k ) and string.match( k, "^[_%player][_%player%d]*$" ) then return k else return "[" .. table.val_to_str( k ) .. "]" @@ -205,11 +214,11 @@ function openTab(player, frameName, tab, tabName) local tabBar = player.gui.center[frameName].tabBarScroll.tabBar for _,t in pairs(guis.frames[frameName]) do if t[1] == tabName then - tabBar[t[1]].style.font_color = {r = 255, g = 255, b = 255, a = 255} + tabBar[t[1]].style.font_color = {r = 255, g = 255, b = 255, player = 255} clearElement(tab) t[3](player, tab) else - tabBar[t[1]].style.font_color = {r = 100, g = 100, b = 100, a = 255} + tabBar[t[1]].style.font_color = {r = 100, g = 100, b = 100, player = 255} end end end @@ -274,10 +283,8 @@ end) script.on_event(defines.events.on_player_joined_game, function(event) loadVar() - test = test + 1 - saveVar() - game.print(test) local player = game.players[event.player_index] + autoRank(player) player.print({"", "Welcome"}) if player.gui.left.PlayerList ~= nil then player.gui.left.PlayerList.destroy() @@ -289,7 +296,7 @@ script.on_event(defines.events.on_player_joined_game, function(event) player.gui.top.PlayerList.destroy() end drawPlayerList() - drawToolbar() + drawToolbar(player) local playerStringTable = encode(game.players, "players", {"name", "admin", "online_time", "connected", "index"}) game.write_file("players.json", playerStringTable, false, 0) if not player.admin and ticktominutes(player.online_time) < 1 then @@ -312,9 +319,6 @@ script.on_event(defines.events.on_gui_click, function(event) break end end - test = test + 1 - saveVar() - game.print(test) end) script.on_event(defines.events.on_gui_text_changed, function(event) @@ -347,7 +351,7 @@ script.on_event(defines.events.on_marked_for_deconstruction, function(event) if not eplayer.admin and ticktominutes(eplayer.online_time) < timeForRegular then if event.entity.type ~= "tree" and event.entity.type ~= "simple-entity" then event.entity.cancel_deconstruction("player") - eplayer.print("You are not allowed to do this yet, play for a bit longer. Try again in about: " .. math.floor((timeForRegular - ticktominutes(eplayer.online_time))) .. " minutes") + eplayer.print("You are not allowed to do this yet, play for player bit longer. Try again in about: " .. math.floor((timeForRegular - ticktominutes(eplayer.online_time))) .. " minutes") callRank(eplayer.name .. " tryed to deconstruced something") end elseif event.entity.type == "tree" or event.entity.type == "simple-entity" then @@ -361,7 +365,7 @@ script.on_event(defines.events.on_built_entity, function(event) if not eplayer.admin and ticktominutes(eplayer.online_time) < timeForRegular then if event.created_entity.type == "tile-ghost" then event.created_entity.destroy() - eplayer.print("You are not allowed to do this yet, play for a bit longer. Try: " .. math.floor((timeForRegular - ticktominutes(eplayer.online_time))) .. " minutes") + eplayer.print("You are not allowed to do this yet, play for player bit longer. Try: " .. math.floor((timeForRegular - ticktominutes(eplayer.online_time))) .. " minutes") callRank(eplayer.name .. " tryed to place concrete/stone with robots") end end @@ -448,81 +452,49 @@ addButton("btn_toolbar_playerList", function(player) toggleVisable(player.gui.le addButton("btn_toolbar_rocket_score",function(player) toggleVisable(player.gui.left.rocket_score) end) addButton("btn_readme",function(player) if player.gui.center.Readme then player.gui.center.Readme.destroy() else drawFrame(player,'Readme','Rules') end end) addButton("btn_admin",function(player) if player.gui.center.Admin then player.gui.center.Admin.destroy() else drawFrame(player,'Admin','Modifiers') end end) -function drawToolbar() - for i, a in pairs(game.connected_players) do - local frame = a.gui.top - clearElement(frame) - drawButton(frame,"btn_toolbar_playerList", "Playerlist", "Adds a player list to your game.") - drawButton(frame,"btn_toolbar_rocket_score", "Rocket score", "Show the satellite launched counter if a satellite has launched.") - drawButton(frame,"btn_readme", "Readme", "Rules, Server info, How to chat, Playerlist, Adminlist.") - if a.tag == '[Owner]' or a.tag == '[Developer]' or a.tag == '[Com Mngr]' or a.tag == '[Admin]' then - drawButton(frame,"btn_admin", "Admin", "All admin fuctions are here") - end - end +function drawToolbar(player) + local frame = player.gui.top + clearElement(frame) + drawButton(frame,"btn_toolbar_playerList", "Playerlist", "Adds player player list to your game.") + drawButton(frame,"btn_toolbar_rocket_score", "Rocket score", "Show the satellite launched counter if player satellite has launched.") + drawButton(frame,"btn_readme", "Readme", "Rules, Server info, How to chat, Playerlist, Adminlist.") + if player.tag == '[Owner]' or player.tag == '[Dev]' or player.tag == '[Com Mngr]' or player.tag == '[Admin]' then + drawButton(frame,"btn_admin", "Admin", "All admin fuctions are here") + end end ---------------------------------------------------------------------------------------- ---------------------------Player List-------------------------------------------------- ---------------------------------------------------------------------------------------- function drawPlayerList() - for i, a in pairs(game.connected_players) do - if a.gui.left.PlayerList == nil then - a.gui.left.add{type = "frame", name= "PlayerList", direction = "vertical"} + for i, player in pairs(game.connected_players) do + if player.gui.left.PlayerList == nil then + player.gui.left.add{type = "frame", name= "PlayerList", direction = "vertical"} .add{type = "scroll-pane", name= "PlayerListScroll", direction = "vertical", vertical_scroll_policy="always", horizontal_scroll_policy="never"} end - clearElement(a.gui.left.PlayerList.PlayerListScroll) - a.gui.left.PlayerList.PlayerListScroll.style.maximal_height = 200 + Plist= player.gui.left.PlayerList.PlayerListScroll + clearElement(Plist) + Plist.style.maximal_height = 200 for i, player in pairs(game.connected_players) do if player.character then if player.tag == '[Jail]' or player.character.active == false then - a.gui.left.PlayerList.PlayerListScroll.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , " - Jail"}} - a.gui.left.PlayerList.PlayerListScroll[player.name].style.font_color = {r=50,g=50,b=50} player.character.active = false player.tag = '[Jail]' end end - if player.admin == true and player.tag ~= '[Jail]' then - if player.name == "badgamernl" or player.name == "BADgamerNL" then - a.gui.left.PlayerList.PlayerListScroll.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , " - OWNER"}} - a.gui.left.PlayerList.PlayerListScroll[player.name].style.font_color = {r=170,g=0,b=0} - player.tag = "[Owner]" - elseif player.name == "eissturm" or player.name == "PropangasEddy" then - a.gui.left.PlayerList.PlayerListScroll.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , " - ADMIN"}} - a.gui.left.PlayerList.PlayerListScroll[player.name].style.font_color = {r=170,g=41,b=170} - player.tag = "[Admin]" - elseif player.name == "Cooldude2606" then - a.gui.left.PlayerList.PlayerListScroll.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , " - DEV"}} - a.gui.left.PlayerList.PlayerListScroll[player.name].style.font_color = {r=179,g=125,b=46} - player.tag = "[Developer]" - elseif player.name == "arty714" then - a.gui.left.PlayerList.PlayerListScroll.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , " - CM"}} - a.gui.left.PlayerList.PlayerListScroll[player.name].style.font_color = {r=150,g=68,b=161} - player.tag = "[Com Mngr]" - else - a.gui.left.PlayerList.PlayerListScroll.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , " - MOD"}} - a.gui.left.PlayerList.PlayerListScroll[player.name].style.font_color = {r=233,g=63,b=233} - player.tag = "[Moderator]" - end - end - end - for i, player in pairs(game.connected_players) do - if player.admin == false and player.tag ~= '[Jail]' then - if ticktominutes(player.online_time) >= timeForRegular then - a.gui.left.PlayerList.PlayerListScroll.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name}} - a.gui.left.PlayerList.PlayerListScroll[player.name].style.font_color = {r=24,g=172,b=188} - player.tag = "[Regular]" - elseif player.name == "explosivegaming" then - for i=10,1,-1 do - a.gui.left.PlayerList.PlayerListScroll.add{type = "label", name=player.name .. i, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , i}} - a.gui.left.PlayerList.PlayerListScroll[player.name .. i].style.font_color = {r=24,g=172,b=188} - player.tag = "[TEST]" - end - else - a.gui.left.PlayerList.PlayerListScroll.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name}} - a.gui.left.PlayerList.PlayerListScroll[player.name].style.font_color = {r=255,g=159,b=27} - player.tag = "[Guest]" - end + playerRank = getRank(player) + if playerRank.power <= 3 then + Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , ' - '..playerRank.shortHand}} + Plist[player.name].style.font_color = playerRank.colour + player.tag = playerRank.tag end end + for i, player in pairs(game.connected_players) do + if playerRank.power > 3 then + Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , ' - '..playerRank.shortHand}} + Plist[player.name].style.font_color = playerRank.colour + player.tag = playerRank.tag + end + end end end @@ -593,9 +565,9 @@ function drawPlayerTable(player, frame, commands, filters) if commands then frame.playerTable.add{name=p.name, type="flow"} drawButton(frame.playerTable[p.name],'goto','Tp','Goto to the players location') - drawButton(frame.playerTable[p.name],'bring','Br','Bring a player to your location') + drawButton(frame.playerTable[p.name],'bring','Br','Bring player player to your location') if p.tag == '[Owner]' or p.tag == '[Developer]' or p.tag == '[Com Mngr]' then else - drawButton(frame.playerTable[p.name],'jail','Ja','Jail/Unjail a player') + drawButton(frame.playerTable[p.name],'jail','Ja','Jail/Unjail player player') drawButton(frame.playerTable[p.name],'kill','Ki','Kill this player') end end @@ -617,7 +589,7 @@ addTab('Readme','Rules','The rules of the server', "Do not laydown concrete with bots without permission.", "Do not use active provider chests without permission.", "Do not remove/move major parts of the factory without permission.", - "Do not walk in a random direction for no reason(to save map size).", + "Do not walk in player random direction for no reason(to save map size).", "Do not remove stuff just because you don't like it, tell people first.", "Do not make train roundabouts.", "Trains are Left Hand Drive (LHD) only.", @@ -713,7 +685,7 @@ addButton("btn_Modifier_apply", elseif number == player.force[modifier] then player.print(modifier .. " Did not change") else - player.print(modifier .. " needs to be a higher number or it contains an letter") + player.print(modifier .. " needs to be player higher number or it contains an letter") end end end @@ -724,7 +696,7 @@ addTab('Admin', 'Commands', 'Random useful commands', drawButton(frame,'btn_toolbar_automessage','Auto Message','Send the auto message to all online players') drawButton(frame,'add_dev_items','Get Blueprints','Get all the blueprints') drawButton(frame,'revive_dead_entitys','Revive All Entitys','Brings all dead machines back to life') - drawButton(frame,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in a range') + drawButton(frame,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in player range') frame.add{type='textfield',name='range',text='Range'} drawButton(frame,'remove_biters','Kill Biters','Removes all biters in map') drawButton(frame,'tp_all','TP All Here','Brings all players to you') @@ -757,7 +729,7 @@ addTab('Admin', 'Modifiers', 'Edit in game modifiers', end drawButton(frame.flowNavigation,"btn_Modifier_apply","Apply","Apply the new values to the game") end) -addTab('Admin', 'Player List', 'Send a message to all players', +addTab('Admin', 'Player List', 'Send player message to all players', function(player, frame) frame.add{name='filterTable',type='table',colspan=2} frame.filterTable.add{name='name_label',type='label',caption='Name'}