diff --git a/control.lua b/control.lua index 3b275520..ee643311 100644 --- a/control.lua +++ b/control.lua @@ -1 +1 @@ -entityRemoved={}entityCache={}guis={frames={},buttons={}}defaults={itemRotated={},test=0}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 end;function saveVar()gTable.itemRotated=itemRotated;gTable.test=test;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;callAdmin("Decoratives have been removed")end;script.on_event(defines.events.on_chunk_generated,function(o)c(o.surface,o.area)end)function ticktohour(p)local q=tostring(math.floor(p/(216000*game.speed)))return q end;function ticktominutes(p)local r=math.floor(p/(3600*game.speed))return r end;function callAdmin(s)for f,t in pairs(game.connected_players)do if t.admin then t.print(s)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(u)if"string"==type(u)then u=string.gsub(u,"\n","\\n")if string.match(string.gsub(u,"[^'\"]",""),'^"+$')then return"'"..u.."'"end;return'"'..string.gsub(u,'"','\\"')..'"'else return"table"==type(u)and table.tostring(u)or tostring(u)end end;function table.key_to_str(v)if"string"==type(v)and string.match(v,"^[_%a][_%a%d]*$")then return v else return"["..table.val_to_str(v).."]"end end;function table.tostring(w)local x,y={},{}for v,u in ipairs(w)do table.insert(x,table.val_to_str(u))y[v]=true end;for v,u in pairs(w)do if not y[v]then table.insert(x,table.key_to_str(v).."="..table.val_to_str(u))end end;return"{"..table.concat(x,",").."}"end;function addFrame(z)guis.frames[z]={}addButton('close',function(t,A)A.parent.parent.parent.destroy()end)end;function addTab(z,B,C,D)guis.frames[z][B]={B,C,D}addButton(B,function(t,A)openTab(t,A.parent.parent.parent.name,A.parent.parent.parent.tab,A.name)end)end;function addButton(E,F)guis.buttons[E]={E,F}end;function drawButton(z,E,G,C)z.add{name=E,type="button",caption=G,tooltip=C}end;function openTab(t,H,I,B)local J=t.gui.center[H].tabBarScroll.tabBar;for f,a in pairs(guis.frames[H])do if a[1]==B then J[a[1]].style.font_color={r=255,g=255,b=255,a=255}clearElement(I)a[3](t,I)else J[a[1]].style.font_color={r=100,g=100,b=100,a=255}end end end;function drawFrame(t,H,B)if t.gui.center[H]then t.gui.center[H].destroy()end;local z=t.gui.center.add{name=H,type='frame',caption=H,direction='vertical'}local K=z.add{type="scroll-pane",name="tabBarScroll",vertical_scroll_policy="never",horizontal_scroll_policy="always"}local J=K.add{type='flow',direction='horizontal',name='tabBar'}local I=z.add{type="scroll-pane",name="tab",vertical_scroll_policy="auto",horizontal_scroll_policy="never"}for f,a in pairs(guis.frames[H])do drawButton(J,a[1],a[1],a[2])end;openTab(t,H,I,B)drawButton(J,'close','Close','Close this window')I.style.minimal_height=300;I.style.maximal_height=300;I.style.minimal_width=500;I.style.maximal_width=500;K.style.minimal_height=60;K.style.maximal_height=60;K.style.minimal_width=500;K.style.maximal_width=500 end;function toggleVisable(z)if z then if z.style.visible==nil then z.style.visible=false else z.style.visible=not z.style.visible end end end;function clearElement(L)if L~=nil then for M,A in pairs(L.children_names)do L[A].destroy()end end end;script.on_event(defines.events.on_player_created,function(o)local t=game.players[o.player_index]t.insert{name="iron-plate",count=8}t.insert{name="pistol",count=1}t.insert{name="firearm-magazine",count=10}t.insert{name="burner-mining-drill",count=1}t.insert{name="stone-furnace",count=1}t.force.chart(t.surface,{{t.position.x-200,t.position.y-200},{t.position.x+200,t.position.y+200}})end)script.on_event(defines.events.on_player_respawned,function(o)local t=game.players[o.player_index]drawPlayerList()t.insert{name="pistol",count=1}t.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 t=game.players[o.player_index]t.print({"","Welcome"})if t.gui.left.PlayerList~=nil then t.gui.left.PlayerList.destroy()end;if t.gui.center.README~=nil then t.gui.center.README.destroy()end;if t.gui.top.PlayerList~=nil then t.gui.top.PlayerList.destroy()end;drawPlayerList()drawToolbar()local N=encode(game.players,"players",{"name","admin","online_time","connected","index"})game.write_file("players.json",N,false,0)if not t.admin and ticktominutes(t.online_time)<1 then drawFrame(t,'Readme','Rules')end end)script.on_event(defines.events.on_player_left_game,function(o)local t=game.players[o.player_index]drawPlayerList()end)script.on_event(defines.events.on_gui_click,function(o)local t=game.players[o.player_index]for f,O in pairs(guis.buttons)do if O[1]==o.element.name then if O[2]then O[2](t,o.element)else game.print('Invaid Button'..O[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 t=game.players[o.player_index]if o.element.parent.parent.filterTable then local z=o.element;local P={}local Q=false;if z.parent.parent.parent.name=='Admin'then Q=true;P[#P+1]='online'end;if z.parent.parent.filterTable.status_input and not Q then local R=z.parent.parent.filterTable.status_input.text;if R=='yes'or R=='online'or R=='true'or R=='y'then P[#P+1]='online'elseif R~=''then P[#P+1]='offline'end end;if z.parent.parent.filterTable.hours_input then local S=z.parent.parent.filterTable.hours_input.text;if tonumber(S)and tonumber(S)>0 then P[#P+1]=tonumber(S)end end;if z.parent.parent.filterTable.name_input then local T=z.parent.parent.filterTable.name_input.text;if T then P[#P+1]=T end end;if z.parent.parent.playerTable then z.parent.parent.playerTable.destroy()end;drawPlayerTable(t,z.parent.parent,Q,P)end end)script.on_event(defines.events.on_marked_for_deconstruction,function(o)local U=game.players[o.player_index]if not U.admin and ticktominutes(U.online_time)=timeForRegular then a3.gui.left.PlayerList.PlayerListScroll.add{type="label",name=t.name,style="caption_label_style",caption={"",ticktohour(t.online_time)," H - ",t.name}}a3.gui.left.PlayerList.PlayerListScroll[t.name].style.font_color={r=24,g=172,b=188}t.tag="[Regular]"elseif t.name=="explosivegaming"then for M=10,1,-1 do a3.gui.left.PlayerList.PlayerListScroll.add{type="label",name=t.name..M,style="caption_label_style",caption={"",ticktohour(t.online_time)," H - ",t.name,M}}a3.gui.left.PlayerList.PlayerListScroll[t.name..M].style.font_color={r=24,g=172,b=188}t.tag="[TEST]"end else a3.gui.left.PlayerList.PlayerListScroll.add{type="label",name=t.name,style="caption_label_style",caption={"",ticktohour(t.online_time)," H - ",t.name}}a3.gui.left.PlayerList.PlayerListScroll[t.name].style.font_color={r=255,g=159,b=27}t.tag="[Guest]"end end end end end;addButton('goto',function(t,z)local a4=game.players[z.parent.name]t.teleport(game.surfaces[a4.surface.name].find_non_colliding_position("player",a4.position,32,1))end)addButton('bring',function(t,z)local a4=game.players[z.parent.name]a4.teleport(game.surfaces[t.surface.name].find_non_colliding_position("player",t.position,32,1))end)addButton('jail',function(t,z)local a4=game.players[z.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(t,z)local a4=game.players[z.parent.name]if a4.character then a4.character.die()end end)function drawPlayerTable(t,z,Q,P)z.add{name='playerTable',type="table",colspan=5}z.playerTable.style.minimal_width=500;z.playerTable.style.maximal_width=500;z.playerTable.style.horizontal_spacing=10;z.playerTable.add{name="id",type="label",caption="Id "}z.playerTable.add{name="name",type="label",caption="Name "}if not Q then z.playerTable.add{name="status",type="label",caption="Status "}end;z.playerTable.add{name="online_time",type="label",caption="Online Time "}z.playerTable.add{name="rank",type="label",caption="Rank "}if Q then z.playerTable.add{name="commands",type="label",caption="Commands"}end;for M,a4 in pairs(game.players)do local a5=true;for f,a6 in pairs(P)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 t.name~=a4.name then if z.playerTable[a4.name]==nil then z.playerTable.add{name=M.."id",type="label",caption=M}z.playerTable.add{name=a4.name..'_name',type="label",caption=a4.name}if not Q then if a4.connected==true then z.playerTable.add{name=a4.name.."Status",type="label",caption="ONLINE"}else z.playerTable.add{name=a4.name.."Status",type="label",caption="OFFLINE"}end end;z.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'}z.playerTable.add{name=a4.name.."Rank",type="label",caption=a4.tag}if Q then z.playerTable.add{name=a4.name,type="flow"}drawButton(z.playerTable[a4.name],'goto','Tp','Goto to the players location')drawButton(z.playerTable[a4.name],'bring','Br','Bring a player to your location')if a4.tag=='[Owner]'or a4.tag=='[Developer]'or a4.tag=='[Com Mngr]'then else drawButton(z.playerTable[a4.name],'jail','Ja','Jail/Unjail a player')drawButton(z.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(t,z)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 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 M,a8 in pairs(a7)do z.add{name=M,type="label",caption={"",M,". ",a8}}end end)addTab('Readme','Server Info','Info about the server',function(t,z)z.add{name=1,type="label",caption={"","Discord voice and chat server:"}}z.add{name=2,type='textfield',text='https://discord.gg/RPCxzgt'}.style.minimal_width=400;z.add{name=3,type="label",caption={"","Our forum:"}}z.add{name=4,type='textfield',text='https://explosivegaming.nl'}.style.minimal_width=400;z.add{name=5,type="label",caption={"","Steam:"}}z.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(t,z)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 M,aa in pairs(a9)do z.add{name=M,type="label",caption={"",aa}}end end)addTab('Readme','Admins','List of all the people who can ban you :P',function(t,z)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 M,aa in pairs(ab)do z.add{name=M,type="label",caption={"",aa}}end;drawPlayerTable(t,z,false,{'admin'})end)addTab('Readme','Players','List of all the people who have been on the server',function(t,z)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 M,aa in pairs(ac)do z.add{name=M,type="label",caption={"",aa}}end;z.add{name='filterTable',type='table',colspan=3}z.filterTable.add{name='name_label',type='label',caption='Name'}z.filterTable.add{name='status_label',type='label',caption='Online?'}z.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}z.filterTable.add{name='name_input',type='textfield'}z.filterTable.add{name='status_input',type='textfield'}z.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(t,z,false,{})end)addFrame('Admin')addButton('btn_toolbar_automessage',function()autoMessage()end)addButton('revive_dead_entitys',function(t,z)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(t,z)if tonumber(z.parent.range.text)then local ae=tonumber(z.parent.range.text)for ad,g in pairs(game.surfaces[1].find_entities_filtered({area={{t.position.x-ae,t.position.y-ae},{t.position.x+ae,t.position.y+ae}},type="entity-ghost"}))do g.revive()end end end)addButton('remove_biters',function(t,z)for ad,g in pairs(game.surfaces[1].find_entities_filtered({force='enemy'}))do g.destroy()end end)addButton('tp_all',function(t,z)for M,a4 in pairs(game.connected_players)do local af=game.surfaces[t.surface.name].find_non_colliding_position("player",t.position,32,1)if a4~=t then a4.teleport(af)end end end)addButton('toggle_cheat',function(t,z)t.cheat_mode=not t.cheat_mode end)addButton('add_dev_items',function(t,z)t.insert{name="deconstruction-planner",count=1}t.insert{name="blueprint-book",count=1}t.insert{name="blueprint",count=20}end)addButton("btn_Modifier_apply",function(t,z)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 M,ah in pairs(ag)do local ai=tonumber(z.parent.parent.modifierTable[ah.."_input"].text:match("[%d]+[.%d+]"))if ai~=nil then if ai>=0 and ai<50 and ai~=t.force[ah]then t.force[ah]=ai;t.print(ah.." changed to number: "..tostring(ai))elseif ai==t.force[ah]then t.print(ah.." Did not change")else t.print(ah.." needs to be a higher number or it contains an letter")end end end end)addTab('Admin','Commands','Random useful commands',function(t,z)drawButton(z,'btn_toolbar_automessage','Auto Message','Send the auto message to all online players')drawButton(z,'add_dev_items','Get Blueprints','Get all the blueprints')drawButton(z,'revive_dead_entitys','Revive All Entitys','Brings all dead machines back to life')drawButton(z,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in a range')z.add{type='textfield',name='range',text='Range'}drawButton(z,'remove_biters','Kill Biters','Removes all biters in map')drawButton(z,'tp_all','TP All Here','Brings all players to you')drawButton(z,'toggle_cheat','Toggle Cheat Mode','Toggle your cheat mode')end)addTab('Admin','Modifiers','Edit in game modifiers',function(t,z)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"}z.add{type="flow",name="flowNavigation",direction="horizontal"}z.add{name="modifierTable",type="table",colspan=3}z.modifierTable.add{name="name",type="label",caption="name"}z.modifierTable.add{name="input",type="label",caption="input"}z.modifierTable.add{name="current",type="label",caption="current"}for M,ah in pairs(ag)do z.modifierTable.add{name=ah,type="label",caption=ah}z.modifierTable.add{name=ah.."_input",type="textfield",caption="inputTextField"}z.modifierTable.add{name=ah.."_current",type="label",caption=tostring(t.force[ah])}end;drawButton(z.flowNavigation,"btn_Modifier_apply","Apply","Apply the new values to the game")end)addTab('Admin','Player List','Send a message to all players',function(t,z)z.add{name='filterTable',type='table',colspan=2}z.filterTable.add{name='name_label',type='label',caption='Name'}z.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}z.filterTable.add{name='name_input',type='textfield'}z.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(t,z,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={Owner={'badgamernl'},['Community Manager']={'arty714'},Developer={'Cooldude2606'},Admin={'eissturm','PropangasEddy'},Mod={'Alanore','Aquaday','cafeslacker','CrashKonijn','Drahc_pro','Flip','freek18','Hobbitkicker','hud','Matthias','MeDDish','Mindxt20','MottledPetrel','Mr_Happy_212','Phoenix27833','Sand3r205','ScarbVis','Smou','steentje77','TopHatGaming123'},Donner={},Member={},Regular={},Guest={},Jail={}}}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)local s=getRank(p)local t=nil;for q,u in pairs(autoRanks)do local v=false;for f,w in pairs(u)do if p.name==w then t=stringToRank(q)v=true;break end end;if v then break end end;if t then if s.power>t.power then p.tag=t.tag end elseif ticktominutes(p.online_time)>=timeForRegular then p.tag=stringToRank('Regular').tag end;if getRank(p).power<=3 and not p.admin then callRank(p.name..' needs to be promoted.')end end;function ticktohour(x)local y=tostring(math.floor(x/(216000*game.speed)))return y end;function ticktominutes(x)local z=math.floor(x/(3600*game.speed))return z 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(A)if"string"==type(A)then A=string.gsub(A,"\n","\\n")if string.match(string.gsub(A,"[^'\"]",""),'^"+$')then return"'"..A.."'"end;return'"'..string.gsub(A,'"','\\"')..'"'else return"table"==type(A)and table.tostring(A)or tostring(A)end end;function table.key_to_str(B)if"string"==type(B)and string.match(B,"^[_%player][_%player%d]*$")then return B else return"["..table.val_to_str(B).."]"end end;function table.tostring(C)local D,E={},{}for B,A in ipairs(C)do table.insert(D,table.val_to_str(A))E[B]=true end;for B,A in pairs(C)do if not E[B]then table.insert(D,table.key_to_str(B).."="..table.val_to_str(A))end end;return"{"..table.concat(D,",").."}"end;function addFrame(F,q,G,H,I)guis.frames[F]={{require=q,caption=H,tooltip=I}}addButton('close',function(p,J)J.parent.parent.parent.destroy()end)addButton('btn_'..F,function(p,J)if p.gui.center[F]then p.gui.center[F].destroy()else drawFrame(p,F,G)end end)end;function addTab(F,K,L,M)guis.frames[F][K]={K,L,M}addButton(K,function(p,J)openTab(p,J.parent.parent.parent.name,J.parent.parent.parent.tab,J.name)end)end;function addButton(N,O)guis.buttons[N]={N,O}end;function drawButton(F,N,H,L)F.add{name=N,type="button",caption=H,tooltip=L}end;function openTab(p,P,Q,K)local R=p.gui.center[P].tabBarScroll.tabBar;for f,a in pairs(guis.frames[P])do if f~=1 then if a[1]==K then R[a[1]].style.font_color={r=255,g=255,b=255,player=255}clearElement(Q)a[3](p,Q)else R[a[1]].style.font_color={r=100,g=100,b=100,player=255}end end end end;function drawFrame(p,P,K)if getRank(p).power<=guis.frames[P][1].require then if p.gui.center[P]then p.gui.center[P].destroy()end;local F=p.gui.center.add{name=P,type='frame',caption=P,direction='vertical'}local S=F.add{type="scroll-pane",name="tabBarScroll",vertical_scroll_policy="never",horizontal_scroll_policy="always"}local R=S.add{type='flow',direction='horizontal',name='tabBar'}local Q=F.add{type="scroll-pane",name="tab",vertical_scroll_policy="auto",horizontal_scroll_policy="never"}for f,a in pairs(guis.frames[P])do if f~=1 then drawButton(R,a[1],a[1],a[2])end end;openTab(p,P,Q,K)drawButton(R,'close','Close','Close this window')Q.style.minimal_height=300;Q.style.maximal_height=300;Q.style.minimal_width=500;Q.style.maximal_width=500;S.style.minimal_height=60;S.style.maximal_height=60;S.style.minimal_width=500;S.style.maximal_width=500 end end;function toggleVisable(F)if F then if F.style.visible==nil then F.style.visible=false else F.style.visible=not F.style.visible end end end;function clearElement(T)if T~=nil then for U,J in pairs(T.children_names)do T[J].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 V=encode(game.players,"players",{"name","admin","online_time","connected","index"})game.write_file("players.json",V,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,W in pairs(guis.buttons)do if W[1]==o.element.name then if W[2]then W[2](p,o.element)else game.print('Invaid Button'..W[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 F=o.element;local X={}local Y=false;if F.parent.parent.parent.name=='Admin'then Y=true;X[#X+1]='online'end;if F.parent.parent.filterTable.status_input and not Y then local Z=F.parent.parent.filterTable.status_input.text;if Z=='yes'or Z=='online'or Z=='true'or Z=='y'then X[#X+1]='online'elseif Z~=''then X[#X+1]='offline'end end;if F.parent.parent.filterTable.hours_input then local _=F.parent.parent.filterTable.hours_input.text;if tonumber(_)and tonumber(_)>0 then X[#X+1]=tonumber(_)end end;if F.parent.parent.filterTable.name_input then local a0=F.parent.parent.filterTable.name_input.text;if a0 then X[#X+1]=a0 end end;if F.parent.parent.playerTable then F.parent.parent.playerTable.destroy()end;drawPlayerTable(p,F.parent.parent,Y,X)end end)script.on_event(defines.events.on_marked_for_deconstruction,function(o)local a1=game.players[o.player_index]if not a1.admin and ticktominutes(a1.online_time)3 then if playerRank.shortHand~=''then Plist.add{type="label",name=p.name,style="caption_label_style",caption={"",ticktohour(p.online_time)," H - ",p.name,' - '..playerRank.shortHand}}else Plist.add{type="label",name=p.name,style="caption_label_style",caption={"",ticktohour(p.online_time)," H - ",p.name}}end;Plist[p.name].style.font_color=playerRank.colour;p.tag=playerRank.tag end end end end;addButton('goto',function(p,F)local w=game.players[F.parent.name]p.teleport(game.surfaces[w.surface.name].find_non_colliding_position("player",w.position,32,1))end)addButton('bring',function(p,F)local w=game.players[F.parent.name]w.teleport(game.surfaces[p.surface.name].find_non_colliding_position("player",p.position,32,1))end)addButton('jail',function(p,F)local w=game.players[F.parent.name]if w.character then if w.character.active then w.character.active=false;w.tag='[Jail]'drawPlayerList()else w.character.active=true;w.tag='[Guest]'drawPlayerList()end end end)addButton('kill',function(p,F)local w=game.players[F.parent.name]if w.character then w.character.die()end end)function drawPlayerTable(p,F,Y,X)F.add{name='playerTable',type="table",colspan=5}F.playerTable.style.minimal_width=500;F.playerTable.style.maximal_width=500;F.playerTable.style.horizontal_spacing=10;F.playerTable.add{name="id",type="label",caption="Id "}F.playerTable.add{name="name",type="label",caption="Name "}if not Y then F.playerTable.add{name="status",type="label",caption="Status "}end;F.playerTable.add{name="online_time",type="label",caption="Online Time "}F.playerTable.add{name="rank",type="label",caption="Rank "}if Y then F.playerTable.add{name="commands",type="label",caption="Commands"}end;for U,w in pairs(game.players)do local ac=true;for f,ad in pairs(X)do if ad=='admin'then if w.admin==false then ac=false;break end elseif ad=='online'then if w.connected==false then ac=false;break end elseif ad=='offline'then if w.connected==true then ac=false;break end elseif type(ad)=='number'then if ad>ticktominutes(w.online_time)then ac=false;break end elseif type(ad)=='string'then if w.name:lower():find(ad:lower())==nil then ac=false;break end end end;if ac==true and p.name~=w.name then if F.playerTable[w.name]==nil then F.playerTable.add{name=U.."id",type="label",caption=U}F.playerTable.add{name=w.name..'_name',type="label",caption=w.name}if not Y then if w.connected==true then F.playerTable.add{name=w.name.."Status",type="label",caption="ONLINE"}else F.playerTable.add{name=w.name.."Status",type="label",caption="OFFLINE"}end end;F.playerTable.add{name=w.name.."Online_Time",type="label",caption=ticktohour(w.online_time)..'H '..ticktominutes(w.online_time)-60*ticktohour(w.online_time)..'M'}F.playerTable.add{name=w.name.."Rank",type="label",caption=w.tag}if Y then F.playerTable.add{name=w.name,type="flow"}drawButton(F.playerTable[w.name],'goto','Tp','Goto to the players location')drawButton(F.playerTable[w.name],'bring','Br','Bring player player to your location')if w.tag=='[Owner]'or w.tag=='[Developer]'or w.tag=='[Com Mngr]'then else drawButton(F.playerTable[w.name],'jail','Ja','Jail/Unjail player player')drawButton(F.playerTable[w.name],'kill','Ki','Kill this player')end end end end end end;addFrame('Readme',6,'Rules','Readme','Rules, Server info, How to chat, Playerlist, Adminlist.')addTab('Readme','Rules','The rules of the server',function(p,F)local ae={"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 U,af in pairs(ae)do F.add{name=U,type="label",caption={"",U,". ",af}}end end)addTab('Readme','Server Info','Info about the server',function(p,F)F.add{name=1,type="label",caption={"","Discord voice and chat server:"}}F.add{name=2,type='textfield',text='https://discord.gg/RPCxzgt'}.style.minimal_width=400;F.add{name=3,type="label",caption={"","Our forum:"}}F.add{name=4,type='textfield',text='https://explosivegaming.nl'}.style.minimal_width=400;F.add{name=5,type="label",caption={"","Steam:"}}F.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,F)local ag={"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 U,ah in pairs(ag)do F.add{name=U,type="label",caption={"",ah}}end end)addTab('Readme','Admins','List of all the people who can ban you :P',function(p,F)local ai={"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 U,ah in pairs(ai)do F.add{name=U,type="label",caption={"",ah}}end;drawPlayerTable(p,F,false,{'admin'})end)addTab('Readme','Players','List of all the people who have been on the server',function(p,F)local u={"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 U,ah in pairs(u)do F.add{name=U,type="label",caption={"",ah}}end;F.add{name='filterTable',type='table',colspan=3}F.filterTable.add{name='name_label',type='label',caption='Name'}F.filterTable.add{name='status_label',type='label',caption='Online?'}F.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}F.filterTable.add{name='name_input',type='textfield'}F.filterTable.add{name='status_input',type='textfield'}F.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(p,F,false,{})end)addFrame('Admin',2,'Modifiers','Admin',"All admin fuctions are here")addButton('btn_toolbar_automessage',function()autoMessage()end)addButton('revive_dead_entitys',function(p,F)for aj,g in pairs(game.surfaces[1].find_entities_filtered({type="entity-ghost"}))do g.revive()end end)addButton('revive_dead_entitys_range',function(p,F)if tonumber(F.parent.range.text)then local ak=tonumber(F.parent.range.text)for aj,g in pairs(game.surfaces[1].find_entities_filtered({area={{p.position.x-ak,p.position.y-ak},{p.position.x+ak,p.position.y+ak}},type="entity-ghost"}))do g.revive()end end end)addButton('remove_biters',function(p,F)for aj,g in pairs(game.surfaces[1].find_entities_filtered({force='enemy'}))do g.destroy()end end)addButton('tp_all',function(p,F)for U,w in pairs(game.connected_players)do local al=game.surfaces[p.surface.name].find_non_colliding_position("player",p.position,32,1)if w~=p then w.teleport(al)end end end)addButton('toggle_cheat',function(p,F)p.cheat_mode=not p.cheat_mode end)addButton('add_dev_items',function(p,F)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,F)local am={"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 U,an in pairs(am)do local ao=tonumber(F.parent.parent.modifierTable[an.."_input"].text:match("[%d]+[.%d+]"))if ao~=nil then if ao>=0 and ao<50 and ao~=p.force[an]then p.force[an]=ao;p.print(an.." changed to number: "..tostring(ao))elseif ao==p.force[an]then p.print(an.." Did not change")else p.print(an.." needs to be player higher number or it contains an letter")end end end end)addTab('Admin','Commands','Random useful commands',function(p,F)drawButton(F,'btn_toolbar_automessage','Auto Message','Send the auto message to all online players')drawButton(F,'add_dev_items','Get Blueprints','Get all the blueprints')drawButton(F,'revive_dead_entitys','Revive All Entitys','Brings all dead machines back to life')drawButton(F,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in player range')F.add{type='textfield',name='range',text='Range'}drawButton(F,'remove_biters','Kill Biters','Removes all biters in map')drawButton(F,'tp_all','TP All Here','Brings all players to you')drawButton(F,'toggle_cheat','Toggle Cheat Mode','Toggle your cheat mode')end)addTab('Admin','Modifiers','Edit in game modifiers',function(p,F)local am={"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"}F.add{type="flow",name="flowNavigation",direction="horizontal"}F.add{name="modifierTable",type="table",colspan=3}F.modifierTable.add{name="name",type="label",caption="name"}F.modifierTable.add{name="input",type="label",caption="input"}F.modifierTable.add{name="current",type="label",caption="current"}for U,an in pairs(am)do F.modifierTable.add{name=an,type="label",caption=an}F.modifierTable.add{name=an.."_input",type="textfield",caption="inputTextField"}F.modifierTable.add{name=an.."_current",type="label",caption=tostring(p.force[an])}end;drawButton(F.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,F)F.add{name='filterTable',type='table',colspan=2}F.filterTable.add{name='name_label',type='label',caption='Name'}F.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}F.filterTable.add{name='name_input',type='textfield'}F.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(p,F,true,{'online'})end) \ No newline at end of file diff --git a/source.lua b/source.lua index 7d6284af..50994c9c 100644 --- a/source.lua +++ b/source.lua @@ -5,7 +5,30 @@ 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}}, + {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={ + Owner={'badgamernl'}, + ['Community Manager']={'arty714'}, + Developer={'Cooldude2606'}, + Admin={'eissturm','PropangasEddy'}, + Mod={'Alanore','Aquaday','cafeslacker','CrashKonijn','Drahc_pro','Flip','freek18','Hobbitkicker','hud','Matthias','MeDDish','Mindxt20','MottledPetrel','Mr_Happy_212','Phoenix27833','Sand3r205','ScarbVis','Smou','steentje77','TopHatGaming123'}, + Donner={}, + Member={}, + Regular={}, + Guest={}, + Jail={} + } } warningAllowed = nil @@ -13,7 +36,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 @@ -23,16 +45,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 + autoRanks= gTable.autoRanks end function saveVar() gTable.itemRotated = itemRotated - gTable.test = test - game.print('save '..table.tostring(gTable)) + gTable.ranks = ranks + gTable.autoRanks = autoRanks game.players[1].gui.left.hidden.caption = table.tostring(gTable) end ---------------------------------------------------------------------------------------- @@ -57,15 +79,63 @@ local function clearDecorations() for chunk in surface.get_chunks() do removeDecorations(surface, chunk.x * CHUNK_SIZE, chunk.y * CHUNK_SIZE, CHUNK_SIZE - 1, CHUNK_SIZE - 1) end - callAdmin("Decoratives have been removed") + callRank("Decoratives have been removed") end script.on_event(defines.events.on_chunk_generated, function(event) removeDecorationsArea( event.surface, event.area ) end) - ---------------------------------------------------------------------------------------- ----------------------------Common use functions--------------------------------------- +---------------------------Rank functions----------------------------------------------- +---------------------------------------------------------------------------------------- +function getRank(player) + if player then + for _,rank in pairs(ranks) do + if player.tag == rank.tag then return rank end + end + return stringToRank('Guest') + end +end + +function stringToRank(string) + if type(string) == 'string' then + for _,rank in pairs(ranks) do + if rank.name == string then return rank end + end + end +end + +function callRank(msg, rank) + 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.power then player.print('['..rank.shortHand..']: '..msg) end + end +end + +function autoRank(player) + local currentRank = getRank(player) + local playerAutoRank = nil + for rank,players in pairs(autoRanks) do + local Break = false + for _,p in pairs(players) do + if player.name == p then playerAutoRank = stringToRank(rank) Break = true break end + end + if Break then break end + end + if playerAutoRank then + if currentRank.power > playerAutoRank.power then + player.tag=playerAutoRank.tag + end + elseif ticktominutes(player.online_time) >= timeForRegular then + player.tag=stringToRank('Regular').tag + end + if getRank(player).power <= 3 and not player.admin then + callRank(player.name..' needs to be promoted.') + end +end +---------------------------------------------------------------------------------------- +---------------------------Common use functions----------------------------------------- ---------------------------------------------------------------------------------------- function ticktohour (tick) local hour = tostring(math.floor(tick/(216000*game.speed))) @@ -77,7 +147,7 @@ function ticktominutes (tick) return minutes end -function callAdmin(msg) +function callRank(msg) for _, player in pairs(game.connected_players) do if player.admin then player.print(msg) @@ -111,7 +181,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 ) .. "]" @@ -135,9 +205,10 @@ end ---------------------------------------------------------------------------------------- ---------------------------Gui Functions------------------------------------------------ ---------------------------------------------------------------------------------------- -function addFrame(frame) - guis.frames[frame] = {} +function addFrame(frame,rank,open,caption,tooltip) + guis.frames[frame] = {{require=rank,caption=caption,tooltip=tooltip}} addButton('close', function(player,element) element.parent.parent.parent.destroy() end) + addButton('btn_'..frame, function(player,element) if player.gui.center[frame] then player.gui.center[frame].destroy() else drawFrame(player,frame,open) end end) end function addTab(frame, tabName, describtion, drawTab) @@ -156,35 +227,39 @@ end 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} - clearElement(tab) - t[3](player, tab) - else - tabBar[t[1]].style.font_color = {r = 100, g = 100, b = 100, a = 255} + if _ ~= 1 then + if t[1] == tabName then + 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, player = 255} + end end end end function drawFrame(player, frameName, tabName) - if player.gui.center[frameName] then player.gui.center[frameName].destroy() end - local frame = player.gui.center.add{name=frameName,type='frame',caption=frameName,direction='vertical'} - local tabBarScroll = frame.add{type = "scroll-pane", name= "tabBarScroll", vertical_scroll_policy="never", horizontal_scroll_policy="always"} - local tabBar = tabBarScroll.add{type='flow',direction='horizontal',name='tabBar'} - local tab = frame.add{type = "scroll-pane", name= "tab", vertical_scroll_policy="auto", horizontal_scroll_policy="never"} - for _,t in pairs(guis.frames[frameName]) do - drawButton(tabBar, t[1], t[1], t[2]) + if getRank(player).power <= guis.frames[frameName][1].require then + if player.gui.center[frameName] then player.gui.center[frameName].destroy() end + local frame = player.gui.center.add{name=frameName,type='frame',caption=frameName,direction='vertical'} + local tabBarScroll = frame.add{type = "scroll-pane", name= "tabBarScroll", vertical_scroll_policy="never", horizontal_scroll_policy="always"} + local tabBar = tabBarScroll.add{type='flow',direction='horizontal',name='tabBar'} + local tab = frame.add{type = "scroll-pane", name= "tab", vertical_scroll_policy="auto", horizontal_scroll_policy="never"} + for _,t in pairs(guis.frames[frameName]) do + if _ ~= 1 then drawButton(tabBar, t[1], t[1], t[2]) end + end + openTab(player, frameName, tab, tabName) + drawButton(tabBar, 'close', 'Close', 'Close this window') + tab.style.minimal_height = 300 + tab.style.maximal_height = 300 + tab.style.minimal_width = 500 + tab.style.maximal_width = 500 + tabBarScroll.style.minimal_height = 60 + tabBarScroll.style.maximal_height = 60 + tabBarScroll.style.minimal_width = 500 + tabBarScroll.style.maximal_width = 500 end - openTab(player, frameName, tab, tabName) - drawButton(tabBar, 'close', 'Close', 'Close this window') - tab.style.minimal_height = 300 - tab.style.maximal_height = 300 - tab.style.minimal_width = 500 - tab.style.maximal_width = 500 - tabBarScroll.style.minimal_height = 60 - tabBarScroll.style.maximal_height = 60 - tabBarScroll.style.minimal_width = 500 - tabBarScroll.style.maximal_width = 500 end function toggleVisable(frame) @@ -226,10 +301,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() @@ -241,7 +314,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 @@ -264,9 +337,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) @@ -299,8 +369,8 @@ 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") - callAdmin(eplayer.name .. " tryed to deconstruced something") + 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 event.entity.destroy() @@ -313,8 +383,8 @@ 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") - callAdmin(eplayer.name .. " tryed to place concrete/stone with robots") + 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 end) @@ -398,83 +468,51 @@ end ---------------------------------------------------------------------------------------- addButton("btn_toolbar_playerList", function(player) toggleVisable(player.gui.left.PlayerList) end) 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 +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.") + for _,f in pairs(guis.frames) do + if getRank(player).power <= f[1].require then drawButton(frame,"btn_".._, f[1].caption, f[1].tooltip) end 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 + if playerRank.shortHand ~= '' then Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , ' - '..playerRank.shortHand}} + else Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name}} end + Plist[player.name].style.font_color = playerRank.colour + player.tag = playerRank.tag end end + for i, player in pairs(game.connected_players) do + playerRank = getRank(player) + if playerRank.power > 3 then + if playerRank.shortHand ~= '' then Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , ' - '..playerRank.shortHand}} + else Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name}} end + Plist[player.name].style.font_color = playerRank.colour + player.tag = playerRank.tag + end + end end end @@ -545,9 +583,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 @@ -558,7 +596,7 @@ end ---------------------------------------------------------------------------------------- ---------------------------Read Me Gui-------------------------------------------------- ---------------------------------------------------------------------------------------- -addFrame('Readme') +addFrame('Readme',6, 'Rules','Readme', 'Rules, Server info, How to chat, Playerlist, Adminlist.') addTab('Readme','Rules','The rules of the server', function(player,frame) @@ -569,7 +607,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.", @@ -632,7 +670,7 @@ addTab('Readme','Players','List of all the people who have been on the server', ---------------------------------------------------------------------------------------- ---------------------------Modifier Gui------------------------------------------------- ---------------------------------------------------------------------------------------- -addFrame('Admin') +addFrame('Admin',2,'Modifiers','Admin',"All admin fuctions are here") addButton('btn_toolbar_automessage',function() autoMessage() end) addButton('revive_dead_entitys',function(player,frame) for key, entity in pairs(game.surfaces[1].find_entities_filtered({type = "entity-ghost"})) do entity.revive() end end) @@ -665,7 +703,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 @@ -676,7 +714,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') @@ -709,7 +747,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'}