Graal Pastebin
New PastePasted on November 4, 2011.
View the raw file
// Staff Console v2 by Kavan // Retrieving information from the server function onActionServerSide(){ // Loading player list if(params[0] == "LoadPlayers"){ for(temp.pl : allplayers){ if(temp.pl.level != NULL){ temp.plyrs.add(temp.pl); } else { temp.rcs.add(temp.pl); } } triggerClient("gui",name,"GotPlayers",temp.plyrs,temp.rcs); } // Warping to a player if(params[0] == "Warpto"){ temp.pl = findPlayer(params[1]); player.setlevel2(temp.pl.level,temp.pl.x,temp.pl.y); } // Summoning a player if(params[0] == "Summon"){ temp.pl = findPlayer(params[1]); temp.pl.setLevel2(player.level,player.x,player.y); } // Loading levels list if(params[0] == "LoadLevels"){ temp.lvl.loadFolder(client.path_level,false); for(temp.map : temp.lvl){ if(temp.map.ends(".gmap") && temp.map.substring(0, temp.map.length()-5) in serveroptions.gmaps){ temp.maps.add(temp.map.substring(0, temp.map.length()-5)); temp.lvl.remove(temp.map); } } triggerClient("gui",name,"GotLevels",temp.lvl,temp.maps); } // Warping to a level if(params[0] == "WarptoLevel"){ player.setLevel2(params[1],30,30); } // Warping a player to a level if(params[0] == "WarpPlayerToLevel"){ temp.pl = findPlayer(params[2]); temp.pl.setLevel2(params[1],30,30); } // Updating a level if(params[0] == "UpdateLevel"){ sendToRC("/updatelevel "@params[1]); } // Deleteing a level if(params[0] == "DeleteLevel"){ deleteLevel(params[1]); } // Retrieving scripts (WNPCs, Classes) if(params[0] == "LoadScripts"){ temp.w.loadFolder(client.path_weapon, false); temp.c.loadFolder(client.path_class, false); triggerClient("gui",name,"GotScripts",temp.w,temp.c); } // Adding a weapon to yourself if(params[0] == "AddWeapon"){ player.addWeapon(params[1]); } // Removing a weapon from yourself if(params[0] == "RemoveWeapon"){ player.removeWeapon(params[1]); } // Adding a weapon to another player if(params[0] == "GivePlayerWeapon"){ findPlayer(params[1]).addWeapon(params[2]); } // Removing a weapon from another player if(params[0] == "TakePlayerWeapon"){ findPlayer(params[1]).addWeapon(params[2]); } // Updating server flags if(params[0] == "UpdateServerVars"){ temp.sflag = params[1].substring(params[1].pos(".")+1, (params[1].pos("=")-1) - (params[1].pos(".")+1)); temp.sval = params[1].substring(params[1].pos("=")+2); serverr.(@temp.sflag) = temp.sval; } if(params[0] == "PlaceTiles"){ PlaceTiles(params[1], params[2], params[3], params[4], params[5]); } } function PlaceTiles(tile_selection, x, y, w, h){ for(temp.tx = 0; temp.tx < (w/16); temp.tx ++){ for(temp.ty = 0; temp.ty < (h/16); temp.ty ++){ tiles[x+tx, y+ty] = tile_selection[temp.t]; temp.t ++; } updateboard2(x, y, x+w, y+h); savelevel(player.levelname); } } //#CLIENTSIDE // Activating the console (Key: `) function onKeyPressed(keyCode,keyName,scanCode){ if(keyName == "`"){ if(!Console_Window.visible){ openConsole(); } else { closeConsole(); } } } // Creation of the console interface function openConsole(){ new GuiWindowCtrl("Console_Window"){ style = $pref::video::defaultguistyle; profile = "GuiBlueWindowProfile"; width = 600; height = 350; x = (GraalControl.width - width) / 2; y = (GraalControl.height - height) / 2; text = "Staff Console v2"; canClose = canMinimize = canMaximize = canResize = canMove = isExternal = destroyOnHide = true; new GuiTabCtrl("Category_Tabs"){ profile = "GuiBlueTabProfile"; x = 5; y = 0; width = Console_Window.width - 152; height = 23; tabwidth = 70; clearRows(); addRow(0,"Players"); addRow(1,"Levels"); addRow(2,"Scripts"); addRow(3,"Server"); addRow(4,"Tiles"); addRow(5,"Settings"); setSelectedRow(0); } new GuiScrollCtrl("Border_Interface"){ profile = "GuiBlueScrollProfile"; x = Category_Tabs.x; y = Category_Tabs.y + Category_Tabs.height; width = Category_Tabs.width; height = Console_Window.height - 29; hScrollBar = "alwaysOff"; vScrollBar = "dynamic"; new GuiTextListCtrl("Interface_List"){ profile = "GuiBlueTextListProfile"; x = 0; y = 0; width = Border_Interface.width - 20; fitParentWidth = true; height = 0; sortMode = "name"; columns = {0,120,240}; clearRows(); } new GuiTreeViewCtrl("Interface_Tree"){ profile = "GuiBlueTreeViewProfile"; x = 0; y = 0; width = Border_Interface.width - 20; fitParentWidth = true; sortMode = "name"; clearNodes(); } new GuiShowImgCtrl("Loading_Clock"){ width = 32; height = 32; x = (Border_Interface.width / 2) - width + 5; y = (Border_Interface.height / 2) - height; image = "bcalarmclock.png"; } new GuiTextCtrl("Loading_Text"){ profile = "GuiBlueTextProfile"; x = Loading_Clock.x - 7; y = Loading_Clock.y + Loading_Clock.height; text = "Loading..."; } new GuiTextCtrl("LevelPath_Text"){ profile = "GuiBlueTextProfile"; x = 10; y = 10; text = "Level Path:"; } new GuiTextEditCtrl("Level_Path"){ profile = "GuiBlueTextEditProfile"; x = LevelPath_Text.x; y = LevelPath_Text.y + 20; width = Border_Interface.width - 40; height = 20; if(client.path_level == NULL){ text = ""; } else { text = client.path_level; } } new GuiTextCtrl("WeaponPath_Text"){ profile = "GuiBlueTextProfile"; x = Level_Path.x; y = Level_Path.y + Level_Path.height + 40; text = "Weapon NPC Path:"; } new GuiTextEditCtrl("Weapon_Path"){ profile = "GuiBlueTextEditProfile"; x = WeaponPath_Text.x; y = WeaponPath_Text.y + 20; width = Level_Path.width; height = Level_Path.height; if(client.path_weapon == NULL){ text = ""; } else { text = client.path_weapon; } } new GuiTextCtrl("ClassPath_Text"){ profile = "GuiBlueTextProfile"; x = Weapon_Path.x; y = Weapon_Path.y + Weapon_Path.height + 40; text = "Class NPC Path:"; } new GuiTextEditCtrl("Class_Path"){ profile = "GuiBlueTextEditProfile"; x = ClassPath_Text.x; y = ClassPath_Text.y + 20; width = Weapon_Path.width; height = Weapon_Path.height; if(client.path_class == NULL){ text = ""; } else { text = client.path_class; } } new GuiButtonCtrl("Confirm_Button"){ profile = "GuiBlueButtonProfile"; x = Class_Path.x; y = Class_Path.y + Class_Path.height + 40; width = Class_Path.width; height = Class_Path.height + 5; text = "Confirm paths"; } new GuiDrawingPanel("Tile_Editor"){ x = 0; y = 0; width = getImgWidth("pics1.png"); height = getImgHeight("pics1.png"); clearAll(); } } new GuiTextEditCtrl("Interface_InputBox"){ profile = "GuiBlueTextEditProfile"; width = Border_Interface.width; height = 20; x = Border_Interface.x; y = (Border_Interface.y + Border_Interface.height) - height; } new GuiTextCtrl("Op_Text"){ profile = "GuiBlueTextProfile"; x = Category_Tabs.x + Category_Tabs.width + 7; y = Category_Tabs.y + 2; text = "Operations:"; } new GuiScrollCtrl("Border_Operations"){ profile = "GuiBlueScrollProfile"; x = Op_Text.x - 2; y = Border_Interface.y; width = Console_Window.width - x - 5; height = Console_Window.height - 125; hScrollBar = "alwaysOff"; vScrollBar = "dynamic"; new GuiTextListCtrl("Operations_List"){ profile = "GuiBlueTextListProfile"; x = 0; y = 0; width = Border_Operations.width - 20; fitParentWidth = true; height = 0; clearRows(); } } new GuiScrollCtrl("Border_Stats"){ profile = "GuiBlueScrollProfile"; x = Border_Operations.x; y = Border_Operations.y + Border_Operations.height + 5; width = Border_Operations.width; height = 67; hScrollBar = vScrollBar = "alwaysOff"; new GuiMLTextCtrl("Stats_Text"){ profile = "GuiBlueMLTextProfile"; x = 0; y = 0; width = Border_Stats.width - 20; height = 0; } } new GuiButtonCtrl("Refresh_Button"){ profile = "GuiBlueButtonProfile"; x = Border_Stats.x; y = Border_Stats.y + Border_Stats.height + 5; width = Border_Stats.width; height = 20; text = "Refresh"; } } toggleLoadText("hide"); } // Selecting a category function Category_Tabs.onSelect(selectId,selectText,selectIndex){ updateList(selectText); } function updateList(txt){ toggleLoadText("show"); hideOptions(); if(this.second_option != NULL){ this.option_count ++; if(this.option_count >= 2){ this.second_option = NULL; this.option_count = 0; } } switch(txt){ case "Players": triggerServer("gui", name, "LoadPlayers"); break; case "Levels": triggerServer("gui", name, "LoadLevels"); break; case "Scripts": triggerServer("gui", name, "LoadScripts"); break; case "Server": LoadServerVars(); break; case "Tiles": LoadTileset(); break; case "Settings": LoadSettings(); break; } } // Selecting an operation when an interface text is selected function Operations_List.onDblClick(entryid,entrytext,entryindex){ if(Operations_List.selected.active == true){ play("item.wav"); temp.n = getPlayerAcc(Interface_List.getSelectedText()); switch(entrytext){ case "Warpto": triggerServer("gui",name,"Warpto",temp.n); onNotify("<b>Warped to:</b>" NL temp.n); break; case "Profile": findPlayer(temp.n).showProfile(); onNotify("<b>Profile:</b>" NL temp.n); break; case "Summon": triggerServer("gui",name,"Summon",temp.n); onNotify("<b>Summoned:</b>" NL temp.n); break; case "Warp player": this.second_option = getPlayerAcc(Interface_List.getSelectedText()); Category_Tabs.setSelectedRow(1); break; case "Set player weapons": this.second_option = getPlayerAcc(Interface_List.getSelectedText()); Category_Tabs.setSelectedRow(2); break; case "Warpto level": triggerServer("gui",name,"WarptoLevel",Interface_Tree.getSelectedNode().text); onNotify("<b>Warped to:</b>" NL Interface_Tree.getSelectedNode().text); break; case "Warp player to level": triggerServer("gui",name,"WarpPlayerToLevel",Interface_Tree.getSelectedNode().text,this.second_option); Operations_List.rows[1].active = false; onNotify("<b>Warped:</b>" NL this.second_option); this.second_option = NULL; this.option_count = 0; Operations_List.setSelectedRow(1); break; case "Update level": triggerServer("gui",name,"UpdateLevel",Interface_Tree.getSelectedNode().text); onNotify("<b>Updated level:</b>" NL Interface_Tree.getSelectedNode().text); break; case "Delete level": triggerServer("gui", name, "DeleteLevel", Interface_Tree.getSelectedNode().text); onNotify("<b>Deleted level:</b>" NL Interface_Tree.getSelectedNode().text); break; case "Add weapon": triggerServer("gui", name, "AddWeapon", Interface_Tree.getSelectedNode().getFullName("/").substring(12)); onNotify("<b>Weapon added:</b>" NL Interface_Tree.getSelectedNode().getFullName("/").substring(12)); break; case "Remove weapon": triggerServer("gui", name, "RemoveWeapon", Interface_Tree.getSelectedNode().getFullName("/").substring(12)); onNotify("<b>Weapon removed:</b>" NL Interface_Tree.getSelectedNode().getFullName("/").substring(12)); break; case "Give player weapon": triggerServer("gui", name, "GivePlayerWeapon", this.second_option, Interface_Tree.getSelectedNode().getFullName("/").substring(12)); Operations_List.rows[2].active = false; Operations_List.setSelectedRow(0); onNotify("<b>Added ("@this.second_option@"):</b>" NL Interface_Tree.getSelectedNode().getFullName("/").substring(12)); this.second_option = NULL; this.options_count = 0; break; case "Take player weapon": triggerServer("gui", name, "TakePlayerWeapon", this.second_option, Interface_Tree.getSelectedNode().getFullName("/").substring(12)); Operations_List.rows[3].active = false; Operations_List.setSelectedRow(0); onNotify("<b>Removed ("@this.second_option@"):</b>" NL Interface_Tree.getSelectedNode().getFullName("/").substring(12)); this.second_option = NULL; this.options_count = 0; break; case "Create server flag": with("Interface_InputBox"){ width = Border_Interface.width; x = Border_Interface.x; y = (Border_Interface.y + Border_Interface.height) - height; } Interface_InputBox.show(); Border_Interface.height -= Interface_InputBox.height; Operations_List.rows[0].active = false; Operations_List.rows[1].active = false; Operations_List.rows[2].active = true; Operations_List.rows[3].active = true; break; case "Edit server flag": with("Interface_InputBox"){ width = Border_Interface.width; x = Border_Interface.x; y = (Border_Interface.y + Border_Interface.height) - height; text = Interface_List.getSelectedText(); } Interface_InputBox.show(); Border_Interface.height -= Interface_InputBox.height; Operations_List.rows[0].active = false; Operations_List.rows[1].active = false; Operations_List.rows[2].active = true; Operations_List.rows[3].active = true; break; case "Update server flag": triggerServer("gui", name, "UpdateServerVars", Interface_InputBox.text); Border_Interface.height += Interface_InputBox.height; Interface_InputBox.hide(); Operations_List.rows[0].active = true; Operations_List.rows[1].active = true; Operations_List.rows[2].active = false; Operations_List.rows[3].active = false; onNotify("<b>Server:</b>" NL "Flag updated"); break; case "Cancel flag updation": Border_Interface.height += Interface_InputBox.height; Interface_InputBox.hide(); Operations_List.rows[0].active = true; Operations_List.rows[1].active = true; Operations_List.rows[2].active = false; Operations_List.rows[3].active = false; break; } } } // Selecting text in the interface text list function Interface_List.onSelect(entryid,entrytext,entryindex){ if(Category_Tabs.getSelectedText() == "Players"){ if(Interface_List.rows[Interface_List.findText(entrytext)].active == true){ if(entrytext.ends(".nw") || entrytext.ends(".gmap")){ for(temp.r = 0; temp.r < Operations_List.rowCount(); temp.r ++){ Operations_List.rows[temp.r].active = true; } } else { for(temp.r = 0; temp.r < Operations_List.rowCount(); temp.r ++){ Operations_List.rows[temp.r].active = false; } Operations_List.rows[1].active = true; } } else { for(temp.r = 0; temp.r < Operations_List.rowCount(); temp.r ++){ Operations_List.rows[temp.r].active = false; } } } else if(Category_Tabs.getSelectedText() == "Server"){ Operations_List.rows[0].active = true; Operations_List.rows[1].active = true; Operations_List.rows[2].active = false; Operations_List.rows[3].active = false; Interface_InputBox.hide(); Interface_InputBox.text = ""; } Operations_List.setSelectedRow(0); } // Selecting text in the interface tree list function Interface_Tree.onSelect(entryid,entrytext,entryindex){ if(Category_Tabs.getSelectedText() == "Levels"){ if(entrytext.ends(".nw")){ for(temp.r = 0; temp.r < Operations_List.rowCount(); temp.r ++){ Operations_List.rows[temp.r].active = true; } if(this.second_option == NULL){ Operations_List.rows[1].active = false; } } else { for(temp.r = 0; temp.r < Operations_List.rowCount(); temp.r ++){ Operations_List.rows[temp.r].active = false; } } } else if(Category_Tabs.getSelectedText() == "Scripts"){ if(Interface_Tree.getSelectedNode().image == 2){ if(Interface_Tree.getSelectedNode().getFullName("/").starts("Weapon NPCs")){ for(temp.r = 0; temp.r < Operations_List.rowCount(); temp.r ++){ Operations_List.rows[temp.r].active = true; } if(PlayerHasWeapon(player.account, Interface_Tree.getSelectedNode().getFullName("/").substring(12))){ Operations_List.rows[0].active = false; Operations_List.rows[1].active = true; } else { Operations_List.rows[0].active = true; Operations_List.rows[1].active = false; } if(this.second_option != NULL){ if(PlayerHasWeapon(findPlayer(this.second_option).account, Interface_Tree.getSelectedNode().getFullName("/").substring(12))){ Operations_List.rows[2].active = false; Operations_List.rows[3].active = true; } else { Operations_List.rows[2].active = true; Operations_List.rows[3].active = false; } } else { Operations_List.rows[2].active = false; Operations_List.rows[3].active = false; } } else { for(temp.r = 0; temp.r < Operations_List.rowCount(); temp.r ++){ Operations_List.rows[temp.r].active = false; } } } else { for(temp.r = 0; temp.r < Operations_List.rowCount(); temp.r ++){ Operations_List.rows[temp.r].active = false; } } } Operations_List.setSelectedRow(0); } // Finding if the player has the weapon function PlayerHasWeapon(temp.acc, temp.wep){ for(temp.weapons : findPlayer(temp.acc).weapons){ temp.plweps.add(temp.weapons); } if(temp.wep in temp.plweps){ return true; } else { return false; } } // Information from the server function onActionClientSide(){ // Sorting players into a list if(params[0] == "GotPlayers"){ toggleLoadText("hide"); showOptions(Category_Tabs.getSelectedText()); showInterface(Category_Tabs.getSelectedText()); Interface_List.setIconSize(20, 14); Interface_List.clipColumnText = true; temp.pl = 2; for(temp.pl : params[1]){ if(findPlayer(temp.pl).communityName != NULL){ temp.n = findPlayer(temp.pl).nick; } else { temp.n = "Not available (N/A)"; } temp.row = Interface_List.addRow(temp.pl,temp.n TAB temp.pl TAB findPlayer(temp.pl).levelname); temp.row.icon.drawImageStretched(5,0,20,16,findPlayer(temp.pl).head,0,62,40,35); } for(temp.pl : params[2]){ if(findPlayer(temp.pl).communityName != NULL){ temp.n = findPlayer(temp.pl).nick; } else { temp.n = "Not available (N/A)"; } temp.row = Interface_List.addRow(temp.pl,temp.n TAB temp.pl TAB "Remote Control (N/A)"); temp.row.icon.drawImageStretched(5,0,20,16,"head25.png",0,62,40,35); } Interface_List.sort(); Interface_List.insertRow(0,0,"Nickname:" TAB "Account:" TAB "Level:").active = false; Interface_List.insertRow(1,0,"").active = false; onNotify("<b>List updated:</b>" NL "Player list loaded"); } // Sorting level files into a tree view if(params[0] == "GotLevels"){ toggleLoadText("hide"); showOptions(Category_Tabs.getSelectedText()); showInterface(Category_Tabs.getSelectedText()); for(temp.map : params[2]){ with(Interface_Tree.addNodeByPath("Gmaps/"@temp.map,"/")){ image = selectedImage = 2; } } for(temp.lvl : params[1]){ temp.count = 0; for(temp.c = 0; temp.c < temp.lvl.positions("_").size(); temp.c ++){ temp.checkmap = temp.lvl.substring(0, temp.lvl.positions("_")[temp.c]); if(temp.checkmap in params[2]){ with(Interface_Tree.addNodeByPath("Gmaps/"@temp.checkmap@"/"@temp.lvl,"/")){ image = selectedImage = 2; } } else { temp.count ++; } } if(temp.count == temp.lvl.positions("_").size() && temp.lvl.ends(".nw")){ with(Interface_Tree.addNodeByPath("Levels/"@temp.lvl,"/")){ image = selectedImage = 2; } } } Interface_Tree.sort(); for(temp.n = 0; temp.n < Interface_Tree.nodes.size(); temp.n ++){ Interface_Tree.nodes[temp.n].expanded = false; } onNotify("<b>List updated:</b>"NL"Level files loaded"); } // Listing the weapons and classes if(params[0] == "GotScripts"){ toggleLoadText("hide"); showOptions(Category_Tabs.getSelectedText()); showInterface(Category_Tabs.getSelectedText()); for(temp.w : params[1]){ temp.w = removeEscapesFromFilename(temp.w.substring(6, temp.w.pos(".txt") - 6)); with(Interface_Tree.addNodeByPath("Weapon NPCs/"@temp.w,"/")){ image = selectedImage = 2; } } for(temp.c : params[2]){ temp.c = removeEscapesFromFilename(temp.c.substring(0, temp.c.pos(".txt"))); with(Interface_Tree.addNodeByPath("Class NPCs_"@temp.c,"_")){ image = selectedImage = 2; } } Interface_Tree.sort(); for(temp.n = 0; temp.n < Interface_Tree.nodes.size(); temp.n ++){ Interface_Tree.nodes[temp.n].expanded = false; } onNotify("<b>List updated:</b>"NL"Script files loaded"); } } // Loading server flags function LoadServerVars(){ toggleLoadText("hide"); showOptions(Category_Tabs.getSelectedText()); showInterface(Category_Tabs.getSelectedText()); Interface_List.setIconSize(0, 0); Interface_List.clipColumnText = false; for(temp.num : serverr.getDynamicVarNames()){ Interface_List.addRow(temp.num, "serverr."@temp.num SPC "=" SPC serverr.(@temp.num)); } onNotify("<b>List updated:</b>" NL "Server flags loaded"); } // Tile editing stuff function LoadTileset(){ toggleLoadText("hide"); Tile_Editor.drawImage(0, 0, getTileset()); Border_Interface.hScrollBar = "dynamic"; Tile_Editor.show(); } // Setting starting point for selecting tileset tiles function Tile_Editor.onMouseDown(keymodifer, mouse_x, mouse_y, clickcount){ // Thanks to Hoyt here for the tileset coordinate formula this.start_x = min(int((Border_Interface.scrollpos[0]+params[1])/16),getImgWidth("pics1.png")); this.start_y = min(int((Border_Interface.scrollpos[1]+params[2])/16)-1,getImgHeight("pics1.png")); clearSelectTiles(); } // Selecting tiles on tileset function Tile_Editor.onMouseDragged(keymodifer, mouse_x, mouse_y){ temp.tile_x = min(int((Border_Interface.scrollpos[0]+params[1])/16),getImgWidth("pics1.png")); temp.tile_y = min(int((Border_Interface.scrollpos[1]+params[2])/16)-1,getImgHeight("pics1.png")); if(((temp.tile_x*16) - (this.start_x*16)) >= 16 && ((temp.tile_y*16) - (this.start_y*16)) >= 16){ with("Tile_Editor"){ new GuiControl("Tile_Select"){ useOwnProfile = true; profile.border = 0; profile.opaque = true; profile.fillColor = {255, 255, 255, 100}; x = (thiso.start_x*16); y = (thiso.start_y*16); width = shared.roundto((temp.tile_x*16),16) - (thiso.start_x*16); height = shared.roundto((temp.tile_y*16),16) - (thiso.start_y*16); active = false; } } } } // Moving selection into tile array function Tile_Editor.onMouseUp(){ this.select_tiles_size = {Tile_Select.x, Tile_Select.y, Tile_Select.width, Tile_Select.height}; clearSelectTiles(); for(temp.tx = 0; temp.tx < Tile_Select.width; temp.tx += 16){ for(temp.ty = 0; temp.ty < Tile_Select.height; temp.ty += 16){ this.select_tiles.add(ImageToTile(Tile_Select.x + tx, Tile_Select.y + ty)); } } this.select_type = "tileset"; Tile_Select.destroy(); } // Showing tile selection on level function GraalControl.onMouseMove(){ if(Category_Tabs.getSelectedText() == "Tiles"){ moveImage(); } } // Moving selection image function moveImage(){ if(this.select_tiles.size() > 0 && Category_Tabs.getSelectedText() == "Tiles"){ if(int(mousex) in |0,64| && int(mousey) in |0,64|){ switch(this.select_type){ case "tileset": showImg(1000, getTileset(), int(mousex), int(mousey)); changeImgColors(1000, 1, 1, 1, 0.99); changeImgVis(1000, 0); changeImgPart(1000, this.select_tiles_size[0], this.select_tiles_size[1], this.select_tiles_size[2], this.select_tiles_size[3]); break; case "level": showPoly(2000, {int(mousex), int(mousey), int(mousex) + this.pw, int(mousey), int(mousex) + this.pw, int(mousey) + this.ph, int(mousex), int(mousey) + this.ph}); break; } } } } // Placing tiles on the level function GraalControl.onRightMouseDown(){ if(this.select_tiles.size() > 0 && Category_Tabs.getSelectedText() == "Tiles"){ if(int(mousex) in |0,64| && int(mousey) in |0,64|){ triggerServer("gui", name, "PlaceTiles", this.select_tiles, int(mousex), int(mousey), this.select_tiles_size[2], this.select_tiles_size[3]); } } } // Repetetive placing of tiles function GraalControl.onRightMouseDragged(){ if(this.select_tiles.size() > 0 && Category_Tabs.getSelectedText() == "Tiles"){ if(int(mousex) in |0,64| && int(mousey) in |0,64|){ triggerServer("gui", name, "PlaceTiles", this.select_tiles, int(mousex), int(mousey), this.select_tiles_size[2], this.select_tiles_size[3]); } moveImage(); } } // Converting tile position to tile hex function ImageToTile(tx,ty) { return this.tile=((int(tx/16)%16)+(int(tx/256)*512))+((int(ty/16)*16)%512); } // Setting starting points for selecting level tiles function GraalControl.onMouseDown(){ if(Category_Tabs.getSelectedText() == "Tiles"){ this.start_x = int(mousex); this.start_y = int(mousey); clearSelectTiles(); } } // Selecting level tiles function GraalControl.onMouseDragged(){ if(Category_Tabs.getSelectedText() == "Tiles"){ if((int(mousex) - this.start_x) >= 1 && (int(mousey) - this.start_y) >= 1){ showPoly(2000, {this.start_x, this.start_y, int(mousex), this.start_y, int(mousex), int(mousey), this.start_x, int(mousey)}); changeimgcolors(2000, 1, 1, 1, 0.5); } } } // Moving level tiles into tile array function GraalControl.onMouseUp(){ if(Category_Tabs.getSelectedText() == "Tiles"){ for(temp.tx = 0; temp.tx < (int(mousex)-this.start_x); temp.tx ++){ for(temp.ty = 0; temp.ty < (int(mousey)-this.start_y); temp.ty ++){ this.select_tiles.add(tiles[this.start_x + tx, this.start_y + ty]); } } this.pw = findImg(2000).polygon[2] - findImg(2000).polygon[0]; this.ph = findImg(2000).polygon[5] - findImg(2000).polygon[3]; this.select_tiles_size = {0, 0, this.pw*16, this.ph*16}; this.select_type = "level"; } } // Clearing a tile selection function clearSelectTiles(){ hideImgs(1000,2000); this.select_tiles.clear(); } // Settings actions function LoadSettings(){ toggleLoadText("hide"); showOptions(Category_Tabs.getSelectedText()); showInterface(Category_Tabs.getSelectedText()); LevelPath_Text.show(); Level_Path.show(); WeaponPath_Text.show(); Weapon_Path.show(); ClassPath_Text.show(); Class_Path.show(); Confirm_Button.show(); } function Level_Path.onAction(){ client.path_level = Level_Path.text; } function Weapon_Path.onAction(){ client.path_weapon = Weapon_Path.text; } function Class_Path.onAction(){ client.path_class = Class_Path.text; } function Confirm_Button.onAction(){ client.path_level = Level_Path.text; client.path_weapon = Weapon_Path.text; client.path_class = Class_Path.text; Category_Tabs.setSelectedRow(0); } // Showing available options function showInterface(opt){ switch(opt){ case "Players": Interface_List.show(); break; case "Levels": Interface_Tree.show(); break; case "Scripts": Interface_Tree.show(); break; case "Server": Interface_List.show(); break; } } // Hiding all options function hideOptions(){ Interface_List.hide(); Interface_List.clearRows(); Operations_List.clearRows(); Interface_Tree.hide(); Interface_Tree.clearNodes(); LevelPath_Text.hide(); Level_Path.hide(); WeaponPath_Text.hide(); Weapon_Path.hide(); ClassPath_Text.hide(); Class_Path.hide(); Confirm_Button.hide(); Interface_InputBox.hide(); Tile_Editor.hide(); Border_Interface.hScrollBar = "alwaysOff"; Tile_Select.hide(); hideImgs(1000, 2000); Border_Interface.height = Console_Window.height - 29; } // Showing interface according to tab text function showOptions(opt){ with("Operations_List"){ switch(opt){ case "Players": addRow(0,"Warpto"); addRow(1,"Profile"); addRow(2,"Summon"); addRow(3,"Warp player"); addRow(4,"Set player weapons"); break; case "Levels": addRow(0,"Warpto level"); addRow(1,"Warp player to level"); addRow(2,"Update level"); addRow(3,"Delete level"); break; case "Scripts": addRow(0,"Add weapon"); addRow(1,"Remove weapon"); addRow(2,"Give player weapon"); addRow(3,"Take player weapon"); break; case "Server": addRow(0,"Create server flag"); addRow(1,"Edit server flag"); addRow(2,"Update server flag"); addRow(3,"Cancel flag updation"); break; } for(temp.r = 0; temp.r < rowCount(); temp.r ++){ rows[temp.r].active = false; } if(Category_Tabs.getSelectedText() == "Server"){ Operations_List.rows[0].active = true; } } } // The loading symbol and text function toggleLoadText(status){ switch(status){ case "show": Loading_Clock.show(); Loading_Text.show(); break; case "hide": Loading_Clock.hide(); Loading_Text.hide(); break; } } // Escaping the filename to separate text function getPlayerAcc(txt){ temp.filename = escapeFileName(txt); temp.acc = filename.substring(filename.positions("%009")[0]+4, filename.positions("%009")[1] - filename.positions("%009")[0]-4); return temp.acc; } // Resizing adjustments function Console_Window.onResize(){ with("Category_Tabs"){ width = Console_Window.width - 152; } with("Border_Interface"){ width = Category_Tabs.width; height = Console_Window.height - 29; } with("Level_Path"){ width = Border_Interface.width - 40; } with("Weapon_Path"){ width = Border_Interface.width - 40; } with("Class_Path"){ width = Border_Interface.width - 40; } with("Loading_Clock"){ x = (Border_Interface.width / 2) - width + 5; y = (Border_Interface.height / 2) - height; } with("Confirm_Button"){ width = Border_Interface.width - 40; } with("Loading_Text"){ x = Loading_Clock.x - 7; y = Loading_Clock.y + Loading_Clock.height; } with("Op_Text"){ x = Category_Tabs.x + Category_Tabs.width + 7; } with("Border_Operations"){ x = Op_Text.x - 2; width = Console_Window.width - x - 5; height = Console_Window.height - 125; } with("Border_Stats"){ x = Border_Operations.x; y = Border_Operations.y + Border_Operations.height + 5; width = Border_Operations.width; } with("Refresh_Button"){ x = Border_Stats.x; y = Border_Stats.y + Border_Stats.height + 5; width = Border_Stats.width; } } // Searching for text function Search_Box.onAction(){ if(Category_Tabs.getSelectedRow() != 4 && Category_Tabs.getSelectedRow() != 5){ this.search_text = Search_Box.text; updateList(Category_Tabs.getSelectedText()); } else { Search_Box.text = ""; } } // Refreshing lists function Refresh_Button.onAction(){ if(Category_Tabs.getSelectedRow() != 4 && Category_Tabs.getSelectedRow() != 5){ updateList(Category_Tabs.getSelectedText()); } } // Displaying status text function onNotify(txt){ Stats_Text.text = txt; } // Closing the staff console function closeConsole(){ Console_Window.hide(); hideimgs(1000,2000); this.select_tiles.clear(); }