Jump to content

No4NaMe

Members
  • Posts

    31
  • Joined

  • Last visited

Recent Profile Visitors

1,179 profile views

No4NaMe's Achievements

Rat

Rat (9/54)

1

Reputation

  1. local count = 0 local DoorsTable = {} function onStart() if not fileExists("db/bases.db") then local h = fileCreate("db/bases.db") if h then fileClose(h) outputDebugString("[DayZ] Bases database not found, creating...") end db = dbConnect( "sqlite", "db/bases.db" ) outputDebugString("[DayZ] Inserting tables into database...") dbExec(db, "CREATE TABLE IF NOT EXISTS base_objects(id INT AUTO_INCREMENT, model INT, owner VARCHAR, x FLOAT, y FLOAT, z FLOAT, rx FLOAT, ry FLOAT, rz FLOAT, health FLOAT, encampment VARCHAR)") outputDebugString("[DayZ] Tables inserted.") else db = dbConnect( "sqlite", "db/bases.db" ) local qh = dbQuery( db, "SELECT * FROM base_objects" ) local result = dbPoll( qh, 10000 ) for i, ob in ipairs(result) do local tOb = createObject(ob['model'], ob['x'], ob['y'], ob['z'], ob['rx'], ob['ry'], ob['rz']) setTimer(function() if ob['health'] > 0 then triggerClientEvent("setTheObjectUnbreakable",root,tOb) end end,1000,1,tOb) setElementData(tOb, "bc.creator", ob['owner']) setElementData(tOb, "bc.ID", ob['id']) if ob['model'] == 1502 or ob['model'] == 1495 then setupDoor(tOb,ob['encampment']) end setElementData(tOb,"object.health",ob['health']) if getElementData(tOb,"object.health") <= 0 then if getElementData(tOb,"parent") then destroyElement(getElementData(tOb,"parent")) end destroyElement(tOb) end count = count + 1 end outputDebugString("[DayZ] Base objects loaded. TOTAL: "..tostring(count)) end end addEventHandler("onResourceStart", resourceRoot, onStart) function newObject(model,x,y,z,rx,ry,rz,health) if model and x and y and z and rx and ry and rz then local ob = createObject(model, x, y, z, rx, ry, rz) local acName = getAccountName(getPlayerAccount(client)) setElementData(ob, "bc.creator", acName) setElementData(ob,"object.health",health) triggerClientEvent("setTheObjectUnbreakable",root,ob) local encampment = getElementData(client,"Group") if model == 3093 or model == 3029 then setupDoor(ob,encampment) end if ob then local x,y,z = getElementPosition(ob) local rx,ry,rz = getElementRotation(ob) local model = getElementModel(ob) count = count+1 dbExec(db, "INSERT INTO base_objects VALUES (?,?,?,?,?,?,?,?,?,?,?)", count, model, acName, x, y, z, rx, ry, rz, health, tostring(encampment)) end end end addEvent("addon.basecreator:newObject", true) addEventHandler("addon.basecreator:newObject", root, newObject) function onObjectDamage(object,health,id) if object then dbExec(db,'UPDATE base_objects SET health=? WHERE id=?',health,id) end end addEvent("onObjectDamage",true) addEventHandler("onObjectDamage",root,onObjectDamage) function onObjectDestroy(object,id) if object then dbExec(db,"DELETE FROM base_objects WHERE id=?",id) if getElementData(object,"parent") then destroyElement(getElementData(object,"parent")) end destroyElement(object) count = count-1 end end addEvent("onObjectDestroy",true) addEventHandler("onObjectDestroy",root,onObjectDestroy) function setupDoor(object,encampment) local x,y,z = getElementPosition(object) local rx,ry,rz = getElementRotation(object) local col = createColSphere(x,y,z,2) setElementData(object,"parent",col) setElementData(col,"parent",object) DoorsTable[col] = {pos = {x = x,y = y,z = z}, rot= {x = rx,y = ry,z = rz}, col = col, camp = encampment, door = object} end function closeDoor(player,colshape) local data = DoorsTable[colshape] if data == nil then return end if getElementData(data["door"],"object.moved") == "moved" then if moveObject(data["door"],2000,data.pos.x,data.pos.y,data.pos.z,0,0,-90) then outputChatBox("Дверь успешно открыта") end setElementRotation(data["door"],data.rot.x,data.rot.y,data.rot.z - -90) -- checar isso -- ^ A rotação já é definida em moveObject, e menos com menos vai ser uma adição na rotZ setElementData(data["door"],"object.moved","notmoved") end end function toggleDoorOpen(player, key, keyState, colshape) if not isElementWithinColShape( player, colshape ) then return end; --[[ A bind só vai funcionar se tiver dentro do colshape, se quiser desativar só remover essa linha ]] local data = DoorsTable[colshape] if data == nil then return end local rx,ry,rz=getElementRotation(data["door"]) -- se não for usar isso pode remover local doorState = getElementData(data["door"], "object.moved") if doorState and doorState == "moved" and (getElementData(player,"Group") == data["camp"] or data.camp == "false" or not data["camp"]) then closeDoor( player, colshape ) outputChatBox("Дверь открыта") return end if doorState and doorState == "notmoved" and (getElementData(player,"Group") == data["camp"] or data.camp == "false" or not data["camp"]) then moveObject(data["door"],2000,data.pos.x,data.pos.y,data.pos.z,0,0,90) setElementData(data["door"],"object.moved","moved") outputChatBox("Дверь закрыта") end end function bind(hitPlayer, matchingDimension) if getElementType(hitPlayer) == "player" then if type(getElementData( DoorsTable[source]["door"], "object.moved" )) ~= "string" then setElementData( DoorsTable[source]["door"], "object.moved", "notmoved" ) end if isKeyBound( hitPlayer, "E", "down", toggleDoorOpen ) ~= true then bindKey(hitPlayer, "E", "down", toggleDoorOpen, source) end outputChatBox("Дверь может открыть участник группировки!") end end addEventHandler("onColShapeHit", resourceRoot, bind) how to do what the door could open members player of the group? now the open door to all players server
  2. everything is done correctly some code works, and the one that needs to stop after the specified time does not work
  3. Please help me, give me work code night sound and day
  4. and no work and weather sound my code work local weathersounds = { --":DayZ/sounds/ambience/thunder.mp3", ":DayZ/sounds/ambience/crow.mp3", } function WeatherSound() if PlayWeatherSound and isElement(PlayWeatherSound) then stopSound(PlayWeatherSound) end local weatherID = getWeather() if weatherID == 4 or weatherID == 7 or weatherID == 12 or weatherID == 15 then local PlayWeatherSound = playSound(weathersounds[math.random(1,#weathersounds)]) setSoundVolume(PlayWeatherSound,gameplayVariables["ambiencesoundvolume"]) end end addEventHandler ("onClientRender",resourceRoot,WeatherSound) setTimer(WeatherSound,70000,0)
  5. how to do that at a certain time the sound was turned off ?
  6. <meta> <!-- sounds folder --> <script src="sounds_c.lua" type="client" cache="false" /> <file type="client" src="day.mp3" /> <file type="client" src="night.mp3" /> </meta>
  7. and function playTimeSound() local hour, minutes = getTime() if hour == 06 and minutes == 0 then local timesound = playSound(":DayZ/sounds/ambience/day.mp3",true) elseif hur == 12 and minutes == 0 then local timesound = playSound(":DayZ/sounds/ambience/day.mp3",true) elseif hour == 15 and minutes == 0 then local timesound = playSound(":DayZ/sounds/ambience/day.mp3",true) elseif hour == 20 and minutes == 0 then local timesound = playSound(":DayZ/sounds/ambience/night.mp3",true) setSoundVolume(timesound,gameplayVariables["ambiencesoundvolume"]) end end addEventHandler("onClientRender", getRootElement(), playTimeSound ) no work
  8. function Nightmare() local hour,minutes = getTime() if hour == 06 and minutes == 0 then local sound = playSound("day.mp3") else if hour == 12 and minutes == 0 then local sound = playSound("day.mp3") else if hour == 15 and minutes == 0 then local sound = playSound("night.mp3") else if hour == 20 and minutes == 0 then local sound = playSound("night.mp3") --setSoundVolume(sound,50.0) end end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),Nightmare) setTimer(sound, 12000,0) end end end Tell me what's wrong with this script, at the specified time the music does not want to play!
  9. tell me how to make it so that in this script when choosing a language, he switched to the language in my fashion which is built in by the function ? Script lang: ----------------------------------------------------------------------------- -- =x=|DoN|=x= ( 7eJAzZy ) -- Date: 2014/2015 -- Skype: DON.81 -- Please don't remove my rights ----------------------------------------------------------------------------- local LanguageTableList = { {"Arabic"}, {"English"}, {"Spanish"}, {"Mandarin"}, {"Hindi"}, {"Portuguese"}, {"Bengali"}, {"Russian"}, {"Japanese"}, {"Punjabi"}, {"Germany"}, {"Javanese"}, {"Wu"}, {"Malay"}, {"Indonesian"}, {"Telugu"}, {"Vietnamese"}, {"Korean"}, {"French"}, {"Marathi"}, {"Tamil"}, {"Urdu"}, {"Turkish"}, {"Italian"}, {"Yue"}, {"Thai"}, {"Gujarati"}, {"Jin"}, {"Southern Min"}, {"Persian"}, {"Polish"}, {"Pashto"}, {"Kannada"}, {"Xiang"}, {"Malayalam"}, {"Sundanese"}, {"Hausa"}, {"Odia"}, {"Burmese"}, {"Hakka"}, {"Ukrainian"}, {"Bhojpuri"}, {"Tagalog"}, {"Yoruba"}, {"Maithili"}, {"Uzbek"}, {"Sindhi"}, {"Amharic"}, {"Fula"}, {"Romanian"}, {"Oromo"}, {"Igbo"}, {"Azerbaijani"}, {"Awadhi"}, {"Gan Chinese"}, {"Cebuano"}, {"Dutch"}, {"Kurdish"}, {"Serbo Croatian"}, {"Malagasy"}, {"Saraiki"}, {"Nepali"}, {"Sinhalese"}, {"Chittagonian"}, {"Zhuang"}, {"Khmer"}, {"Turkmen"}, {"Assamese"}, {"Madurese"}, {"Somali"}, {"Marwari"}, {"Magahi"}, {"Haryanvi"}, {"Hungarian"}, {"Chhattisgarhi"}, {"Greek"}, {"Chewa"}, {"Deccan"}, {"Akan"}, {"Kazakh"}, {"Northern Min"}, {"Sylheti"}, {"Zulu"}, {"Czech"}, {"Kinyarwanda"}, {"Dhundhari"}, {"Haitian Creole"}, {"Eastern Min"}, {"Ilocano"}, {"Quechua"}, {"Kirundi"}, {"Swedish"}, {"Hmong"}, {"Shona"}, {"Uyghur"}, {"Hiligaynon"}, {"Mossi"}, {"Xhosa"}, {"Belarusian"}, {"Balochi"}, {"Konkani"} } WindowLanguage = guiCreateWindow(0.36, 0.16, 0.31, 0.68, "Languages Script", true) guiSetVisible ( WindowLanguage, false ) GridlistLanguage = guiCreateGridList(0.04, 0.06, 0.92, 0.69, true, WindowLanguage) guiGridListAddColumn(GridlistLanguage, "Languages List", 0.9) for i,v in ipairs ( LanguageTableList ) do local Row = guiGridListAddRow( GridlistLanguage ) guiGridListSetItemText( GridlistLanguage, Row, 1, v[1], false, false ) end setNewLanguage = guiCreateButton(0.04, 0.77, 0.92, 0.09, "Set new Language", true, WindowLanguage) Close = guiCreateButton(0.04, 0.88, 0.92, 0.09, "Close", true, WindowLanguage) addEventHandler("onClientGUIClick",resourceRoot, function ( ) local row, col = guiGridListGetSelectedItem ( GridlistLanguage ) local Group = guiGridListGetItemText(GridlistLanguage,row,1 ) if source == setNewLanguage then if ( row and col and row ~= -1 and col ~= -1 ) then setElementData(localPlayer,"Language",Group,true) outputChatBox("Your new Language chat is "..getElementData(localPlayer,"Language").."",0,255,0) triggerServerEvent ( "setNewLanguageBindKey",resourceRoot ) else outputChatBox("Please choose a langauge",255,0,0) end elseif source == Close then guiSetVisible( WindowLanguage , not guiGetVisible(WindowLanguage)) showCursor(guiGetVisible(WindowLanguage)) end end ) function OpenWindow( ) guiSetVisible( WindowLanguage , not guiGetVisible(WindowLanguage)) showCursor(guiGetVisible(WindowLanguage)) end bindKey("F3","down",OpenWindow) addCommandHandler("language",OpenWindow) My function gamemode command chat language languageCode = getLocalization()["code"] function checkTheLanguage() if languageCode == "en_US" then languageCode = "en_US" elseif languageCode == "de" then languageCode = "de" elseif languageCode == "cs" then languageCode = "cs" elseif languageCode == "nl" then languageCode = "nl" elseif languageCode == "pt_BR" then languageCode = "pt_BR" elseif languageCode == "zh" then languageCode = "zh" elseif languageCode == "es" then languageCode = "es" elseif languageCode == "fr" then languageCode = "fr" elseif languageCode == "ro" then languageCode = "ro" elseif languageCode == "pl" then languageCode = "pl" else languageCode = "en_US" end end addEventHandler("onClientResourceStart",root,checkTheLanguage) local languageTable = { {"en","en_US"}, {"de","de"}, {"cs","cs"}, {"nl","nl"}, {"br","pt_BR"}, {"zh","zh"}, {"es","es"}, {"fr","fr"}, {"ro","ro"}, {"pl","pl"}, } function changeLanguageOnCommand(playerSource,language) if language then for i, lang in ipairs(languageTable) do if language == lang[1] then languageCode = lang[2] outputChatBox("New language: "..tostring(languageCode),0,255,0) end end else outputChatBox("Please specify a language. Possible values: en, de, cs, nl, br, zh, es, fr, ro, pl.",255,0,0) end end addCommandHandler("language",changeLanguageOnCommand) I want to transfer my language system to a graphical
  10. Нашел скрипт строительства сыроват, после установки двери она не привязывается к игроку или группе что в нём не так? --[[ Author: CiBeR Version: 0.1 Copyright: DayZ Gamemode. All rights reserved to Developers Info: MTA:DayZ Base Creation Addon Current Devs: Lawliet, CiBeR, Jboy, Remi, Renkon ]]-- local db local count = 0 local DoorsTable = {} function onStart() if not fileExists("db/bases.db") then local h = fileCreate("db/bases.db") if h then fileClose(h) outputDebugString("[DayZ] Bases database not found, creating...") end db = dbConnect( "sqlite", "db/bases.db" ) outputDebugString("[DayZ] Inserting tables into database...") dbExec(db, "CREATE TABLE IF NOT EXISTS base_objects(id INT AUTO_INCREMENT, model INT, owner VARCHAR, x FLOAT, y FLOAT, z FLOAT, rx FLOAT, ry FLOAT, rz FLOAT, health FLOAT, encampment VARCHAR)") outputDebugString("[DayZ] Tables inserted.") else db = dbConnect( "sqlite", "db/bases.db" ) local qh = dbQuery( db, "SELECT * FROM base_objects" ) local result = dbPoll( qh, 10000 ) for i, ob in ipairs(result) do local tOb = createObject(ob['model'], ob['x'], ob['y'], ob['z'], ob['rx'], ob['ry'], ob['rz']) setTimer(function() if ob['health'] > 0 then triggerClientEvent("setTheObjectUnbreakable",root,tOb) end end,1000,1,tOb) setElementData(tOb, "bc.creator", ob['owner']) setElementData(tOb, "bc.ID", ob['id']) if ob['model'] == 3093 or ob['model'] == 3029 then setupDoor(tOb,ob['encampment']) end setElementData(tOb,"object.health",ob['health']) if getElementData(tOb,"object.health") <= 0 then if getElementData(tOb,"parent") then destroyElement(getElementData(tOb,"parent")) end destroyElement(tOb) end count = count + 1 end outputDebugString("[DayZ] Base objects loaded. TOTAL: "..tostring(count)) end end addEventHandler("onResourceStart", resourceRoot, onStart) function newObject(model,x,y,z,rx,ry,rz,health) if model and x and y and z and rx and ry and rz then local ob = createObject(model, x, y, z, rx, ry, rz) local acName = getAccountName(getPlayerAccount(client)) setElementData(ob, "bc.creator", acName) setElementData(ob,"object.health",health) triggerClientEvent("setTheObjectUnbreakable",root,ob) local encampment = getElementData(client,"Group") if model == 3093 or model == 3029 then setupDoor(ob,encampment) end if ob then local x,y,z = getElementPosition(ob) local rx,ry,rz = getElementRotation(ob) local model = getElementModel(ob) count = count+1 dbExec(db, "INSERT INTO base_objects VALUES (?,?,?,?,?,?,?,?,?,?,?)", count, model, acName, x, y, z, rx, ry, rz, health, tostring(encampment)) end end end addEvent("addon.basecreator:newObject", true) addEventHandler("addon.basecreator:newObject", root, newObject) function onObjectDamage(object,health,id) if object then dbExec(db,'UPDATE base_objects SET health=? WHERE id=?',health,id) end end addEvent("onObjectDamage",true) addEventHandler("onObjectDamage",root,onObjectDamage) function onObjectDestroy(object,id) if object then dbExec(db,"DELETE FROM base_objects WHERE id=?",id) if getElementData(object,"parent") then destroyElement(getElementData(object,"parent")) end destroyElement(object) count = count-1 end end addEvent("onObjectDestroy",true) addEventHandler("onObjectDestroy",root,onObjectDestroy) function setupDoor(object,encampment) local x,y,z = getElementPosition(object) local rx,ry,rz = getElementRotation(object) local col = createColSphere(x,y,z,2) setElementData(object,"parent",col) setElementData(col,"parent",object) DoorsTable[col] = {pos = {x = x,y = y,z = z}, rot= {x = rx,y = ry,z = rz}, col = col, camp = encampment, door = object} end function closeDoor(player,colshape) local data = DoorsTable[colshape] if data == nil then return end if getElementData(data["door"],"object.moved") == "moved" then if moveObject(data["door"],2000,data.pos.x,data.pos.y,data.pos.z,0,0,-90) then outputChatBox("Дверь успешно открыта") end setElementRotation(data["door"],data.rot.x,data.rot.y,data.rot.z - -90) -- checar isso -- ^ A rotação já é definida em moveObject, e menos com menos vai ser uma adição na rotZ setElementData(data["door"],"object.moved","notmoved") end end function toggleDoorOpen(player, key, keyState, colshape) if not isElementWithinColShape( player, colshape ) then return end; --[[ A bind só vai funcionar se tiver dentro do colshape, se quiser desativar só remover essa linha ]] local data = DoorsTable[colshape] if data == nil then return end local rx,ry,rz=getElementRotation(data["door"]) -- se não for usar isso pode remover local doorState = getElementData(data["door"], "object.moved") if doorState and doorState == "moved" and (getElementData(player,"Group") == data["camp"] or data.camp == "false" or not data["camp"]) then closeDoor( player, colshape ) outputChatBox("Дверь открыта") return end if doorState and doorState == "notmoved" and (getElementData(player,"Group") == data["camp"] or data.camp == "false" or not data["camp"]) then moveObject(data["door"],2000,data.pos.x,data.pos.y,data.pos.z,0,0,90) setElementData(data["door"],"object.moved","moved") outputChatBox("Дверь закрыта") end end function bind(hitPlayer, matchingDimension) if getElementType(hitPlayer) == "player" then if type(getElementData( DoorsTable[source]["door"], "object.moved" )) ~= "string" then setElementData( DoorsTable[source]["door"], "object.moved", "notmoved" ) end if isKeyBound( hitPlayer, "E", "down", toggleDoorOpen ) ~= true then bindKey(hitPlayer, "E", "down", toggleDoorOpen, source) end outputChatBox("Дверь может открыть участник группировки!") end end addEventHandler("onColShapeHit", resourceRoot, bind)
  11. --[[ #-----------------------------------------------------------------------------# ----* MTA DayZ: graphics.lua *---- ----* Original Author: Marwin W., Germany, Lower Saxony, Otterndorf *---- ----* This gamemode is being developed by L, CiBeR96, 1B0Y *---- ----* Type: CLIENT *---- #-----------------------------------------------------------------------------# ]] graphicsPanel = { label = {}, radiobutton = {}, button = {}, window = {}, scrollbar = {}, combobox = {}, comboboxitem = {}, } graphicsPanel.window[1] = guiCreateWindow(0.14, 0.32, 0.69, 0.38, "Graphics Options", true) guiWindowSetSizable(graphicsPanel.window[1], false) graphicsPanel.label[1] = guiCreateLabel(0.02, 0.21, 0.20, 0.06, "Draw Distance:", true, graphicsPanel.window[1]) graphicsPanel.scrollbar[1] = guiCreateScrollBar(0.23, 0.21, 0.22, 0.06, true, true, graphicsPanel.window[1]) graphicsPanel.label[5] = guiCreateLabel(0.24, 0.14, 0.20, 0.06, tostring(getFarClipDistance()), true, graphicsPanel.window[1]) graphicsPanel.label[2] = guiCreateLabel(0.02, 0.35, 0.20, 0.06, "Texture Detail:", true, graphicsPanel.window[1]) graphicsPanel.combobox[1] = guiCreateComboBox(0.23, 0.35, 0.22, 0.24, "", true, graphicsPanel.window[1]) graphicsPanel.comboboxitem[1] = guiComboBoxAddItem(graphicsPanel.combobox[1], "High") graphicsPanel.comboboxitem[2] = guiComboBoxAddItem(graphicsPanel.combobox[1], "Low") graphicsPanel.label[3] = guiCreateLabel(0.02, 0.50, 0.20, 0.06, "Sky Detail:", true,graphicsPanel.window[1]) graphicsPanel.combobox[2] = guiCreateComboBox(0.23, 0.51, 0.22, 0.24, "", true, graphicsPanel.window[1]) graphicsPanel.comboboxitem[3] = guiComboBoxAddItem(graphicsPanel.combobox[2], "High") graphicsPanel.comboboxitem[4] = guiComboBoxAddItem(graphicsPanel.combobox[2], "Low") graphicsPanel.label[4] = guiCreateLabel(0.02, 0.66, 0.20, 0.06, "Water Detail:", true, graphicsPanel.window[1]) graphicsPanel.combobox[3] = guiCreateComboBox(0.23, 0.66, 0.22, 0.24, "", true, graphicsPanel.window[1]) graphicsPanel.comboboxitem[5] = guiComboBoxAddItem(graphicsPanel.combobox[3], "High") graphicsPanel.comboboxitem[6] = guiComboBoxAddItem(graphicsPanel.combobox[3], "Low") graphicsPanel.label[6] = guiCreateLabel(0.50, 0.35, 0.20, 0.06, "Bloom:", true, graphicsPanel.window[1]) graphicsPanel.combobox[4] = guiCreateComboBox(0.71, 0.35, 0.22, 0.24, "", true, graphicsPanel.window[1]) graphicsPanel.comboboxitem[7] = guiComboBoxAddItem(graphicsPanel.combobox[4], "Activate") graphicsPanel.comboboxitem[8] = guiComboBoxAddItem(graphicsPanel.combobox[4], "Deactivate") graphicsPanel.label[7] = guiCreateLabel(0.50, 0.51, 0.20, 0.06, "HDR:", true, graphicsPanel.window[1]) graphicsPanel.combobox[5] = guiCreateComboBox(0.71, 0.51, 0.22, 0.24, "", true, graphicsPanel.window[1]) graphicsPanel.comboboxitem[9] = guiComboBoxAddItem(graphicsPanel.combobox[5], "Activate") graphicsPanel.comboboxitem[10] = guiComboBoxAddItem(graphicsPanel.combobox[5], "Deactivate") graphicsPanel.label[8] = guiCreateLabel(0.02, 0.90, 0.07, 0.07, "Preset:", true, graphicsPanel.window[1]) graphicsPanel.label[9] = guiCreateLabel(0.13, 0.83, 0.07, 0.07, "High", true, graphicsPanel.window[1]) guiLabelSetHorizontalAlign(graphicsPanel.label[9], "center", false) guiLabelSetVerticalAlign(graphicsPanel.label[9], "center") graphicsPanel.label[10] = guiCreateLabel(0.28, 0.83, 0.07, 0.07, "Medium", true, graphicsPanel.window[1]) guiLabelSetHorizontalAlign(graphicsPanel.label[10], "center", false) guiLabelSetVerticalAlign(graphicsPanel.label[10], "center") graphicsPanel.label[11] = guiCreateLabel(0.43, 0.83, 0.07, 0.07, "Low", true, graphicsPanel.window[1]) guiLabelSetHorizontalAlign(graphicsPanel.label[11], "center", false) guiLabelSetVerticalAlign(graphicsPanel.label[11], "center") graphicsPanel.label[12] = guiCreateLabel(0.58, 0.83, 0.07, 0.07, "Custom", true, graphicsPanel.window[1]) guiLabelSetHorizontalAlign(graphicsPanel.label[12], "center", false) guiLabelSetVerticalAlign(graphicsPanel.label[12], "center") graphicsPanel.radiobutton[1] = guiCreateRadioButton(0.15, 0.90, 0.02, 0.06, "", true, graphicsPanel.window[1]) graphicsPanel.radiobutton[2] = guiCreateRadioButton(0.31, 0.90, 0.02, 0.06, "", true, graphicsPanel.window[1]) graphicsPanel.radiobutton[3] = guiCreateRadioButton(0.45, 0.90, 0.02, 0.06, "", true, graphicsPanel.window[1]) graphicsPanel.radiobutton[4] = guiCreateRadioButton(0.60, 0.90, 0.02, 0.06, "", true, graphicsPanel.window[1]) graphicsPanel.button[1] = guiCreateButton(0.76, 0.86, 0.10, 0.09, "Save", true, graphicsPanel.window[1]) graphicsPanel.button[2] = guiCreateButton(0.89, 0.86, 0.10, 0.09, "Cancel", true, graphicsPanel.window[1]) graphicsPanel.label[13] = guiCreateLabel(0.72, 0.08, 0.20, 0.06, "FPS: ", true, graphicsPanel.window[1]) guiSetVisible(graphicsPanel.window[1],false) local GraphicsPanelOpen = false function toggleGraphicsPanel() if getElementData(localPlayer,"logedin") then if not GraphicsPanelOpen then guiSetVisible(graphicsPanel.window[1],true) GraphicsPanelOpen = true showCursor(not isCursorShowing()) local oldGraphicsFile = xmlLoadFile("graphics.xml") local graphicsFile = xmlLoadFile("@graphics.xml") -- 0 = High/Activate, 1 = Low/Deactivate local drawDistance = 100 local textureDetail = 1 local skyDetail = 1 local waterDetail = 1 local bloomDetail = 1 local hdrDetail = 1 local savedPreset = 3 -- Low Preset if not graphicsFile and oldGraphicsFile then graphicsFile = xmlCreateFile("graphics.xml","settings") drawDistance = xmlNodeGetAttribute(oldGraphicsFile,"drawdistance") textureDetail = xmlNodeGetAttribute(oldGraphicsFile,"texture") skyDetail = xmlNodeGetAttribute(oldGraphicsFile,"sky") waterDetail = xmlNodeGetAttribute(oldGraphicsFile,"water") bloomDetail = xmlNodeGetAttribute(oldGraphicsFile,"bloom") hdrDetail = xmlNodeGetAttribute(oldGraphicsFile,"hdr") savedPreset = xmlNodeGetAttribute(oldGraphicsFile,"savedpreset") xmlNodeSetAttribute(graphicsFile,"drawdistance",drawDistance) xmlNodeSetAttribute(graphicsFile,"texture",textureDetail) xmlNodeSetAttribute(graphicsFile,"sky",skyDetail) xmlNodeSetAttribute(graphicsFile,"water",waterDetail) xmlNodeSetAttribute(graphicsFile,"bloom",bloomDetail) xmlNodeSetAttribute(graphicsFile,"hdr",hdrDetail) xmlNodeSetAttribute(graphicsFile,"savedpreset",savedPreset) xmlSaveFile(graphicsFile) end if oldGraphicsFile then xmlUnloadFile(oldGraphicsFile) end graphicsFile = xmlLoadFile("@graphics.xml") if graphicsFile then drawDistance = xmlNodeGetAttribute(graphicsFile,"drawdistance") textureDetail = xmlNodeGetAttribute(graphicsFile,"texture") skyDetail = xmlNodeGetAttribute(graphicsFile,"sky") waterDetail = xmlNodeGetAttribute(graphicsFile,"water") bloomDetail = xmlNodeGetAttribute(graphicsFile,"bloom") hdrDetail = xmlNodeGetAttribute(graphicsFile,"hdr") savedPreset = xmlNodeGetAttribute(graphicsFile,"savedpreset") else graphicsFile = xmlCreateFile("@graphics.xml","settings") xmlNodeSetAttribute(graphicsFile,"drawdistance",100) xmlNodeSetAttribute(graphicsFile,"texture",1) xmlNodeSetAttribute(graphicsFile,"sky",1) xmlNodeSetAttribute(graphicsFile,"water",1) xmlNodeSetAttribute(graphicsFile,"bloom",1) xmlNodeSetAttribute(graphicsFile,"hdr",1) xmlNodeSetAttribute(graphicsFile,"savedpreset",3) drawDistance = xmlNodeGetAttribute(graphicsFile,"drawdistance") textureDetail = xmlNodeGetAttribute(graphicsFile,"texture") skyDetail = xmlNodeGetAttribute(graphicsFile,"sky") waterDetail = xmlNodeGetAttribute(graphicsFile,"water") bloomDetail = xmlNodeGetAttribute(graphicsFile,"bloom") hdrDetail = xmlNodeGetAttribute(graphicsFile,"hdr") savedPreset = xmlNodeGetAttribute(graphicsFile,"savedpreset") end applySavedGraphicsToGui(drawDistance,textureDetail,skyDetail,waterDetail,bloomDetail,hdrDetail,savedPreset) xmlSaveFile(graphicsFile) else guiSetVisible(graphicsPanel.window[1],false) GraphicsPanelOpen = false showCursor(not isCursorShowing()) saveGraphicsToXML() end end end addCommandHandler("Show Graphics",toggleGraphicsPanel) bindKey("F3","down","Show Graphics") -- Preset Graphics Code function getSelectedPresetGraphicOption() if guiRadioButtonGetSelected(graphicsPanel.radiobutton[1]) then -- High setPresetGraphics(1) elseif guiRadioButtonGetSelected(graphicsPanel.radiobutton[2]) then -- Medium setPresetGraphics(2) elseif guiRadioButtonGetSelected(graphicsPanel.radiobutton[3]) then -- Low setPresetGraphics(3) elseif guiRadioButtonGetSelected(graphicsPanel.radiobutton[4]) then -- Custom -- revert to custom settings if they exist, if not, set everything to same as low end end addEventHandler("onClientGUIClick",graphicsPanel.radiobutton[1],getSelectedPresetGraphicOption,false) addEventHandler("onClientGUIClick",graphicsPanel.radiobutton[2],getSelectedPresetGraphicOption,false) addEventHandler("onClientGUIClick",graphicsPanel.radiobutton[3],getSelectedPresetGraphicOption,false) function setPresetGraphics(level) if level then -- 0 = High/Activate, 1 = Low/Deactivate local drawDistance = 100 local textureDetail = 1 local skyDetail = 1 local waterDetail = 1 local bloomDetail = 1 local hdrDetail = 1 local savedPreset = 3 -- Low Preset if level == 1 then drawDistance = 5000 textureDetail = 0 skyDetail = 0 waterDetail = 0 bloomDetail = 0 hdrDetail = 0 applySavedGraphicsToGui(drawDistance,textureDetail,skyDetail,waterDetail,bloomDetail,hdrDetail,level) elseif level == 2 then drawDistance = 2500 textureDetail = 0 skyDetail = 0 waterDetail = 0 bloomDetail = 1 hdrDetail = 1 applySavedGraphicsToGui(drawDistance,textureDetail,skyDetail,waterDetail,bloomDetail,hdrDetail,level) elseif level == 3 then drawDistance = 100 textureDetail = 1 skyDetail = 1 waterDetail = 1 bloomDetail = 1 hdrDetail = 1 applySavedGraphicsToGui(drawDistance,textureDetail,skyDetail,waterDetail,bloomDetail,hdrDetail,level) end saveGraphicsToXML() end end function saveGraphicsToXML() local graphicsFile = xmlLoadFile("@graphics.xml") local drawDistance = getFarClipDistance() local textureDetail = guiComboBoxGetSelected(graphicsPanel.combobox[1]) local skyDetail = guiComboBoxGetSelected(graphicsPanel.combobox[2]) local waterDetail = guiComboBoxGetSelected(graphicsPanel.combobox[3]) local bloomDetail = guiComboBoxGetSelected(graphicsPanel.combobox[4]) local hdrDetail = guiComboBoxGetSelected(graphicsPanel.combobox[5]) local savedPreset = 3 if guiRadioButtonGetSelected(graphicsPanel.radiobutton[1]) then savedPreset = 1 elseif guiRadioButtonGetSelected(graphicsPanel.radiobutton[2]) then savedPreset = 2 elseif guiRadioButtonGetSelected(graphicsPanel.radiobutton[3]) then savedPreset = 3 elseif guiRadioButtonGetSelected(graphicsPanel.radiobutton[4]) then savedPreset = 4 end if not graphicsFile then graphicsFile = xmlCreateFile("graphics.xml","settings") xmlNodeSetAttribute(graphicsFile,"drawdistance",drawDistance) xmlNodeSetAttribute(graphicsFile,"texture",textureDetail) xmlNodeSetAttribute(graphicsFile,"sky",skyDetail) xmlNodeSetAttribute(graphicsFile,"water",waterDetail) xmlNodeSetAttribute(graphicsFile,"bloom",bloomDetail) xmlNodeSetAttribute(graphicsFile,"hdr",hdrDetail) xmlNodeSetAttribute(graphicsFile,"savedpreset",savedPreset) else xmlNodeSetAttribute(graphicsFile,"drawdistance",drawDistance) xmlNodeSetAttribute(graphicsFile,"texture",textureDetail) xmlNodeSetAttribute(graphicsFile,"sky",skyDetail) xmlNodeSetAttribute(graphicsFile,"water",waterDetail) xmlNodeSetAttribute(graphicsFile,"bloom",bloomDetail) xmlNodeSetAttribute(graphicsFile,"hdr",hdrDetail) xmlNodeSetAttribute(graphicsFile,"savedpreset",savedPreset) end xmlSaveFile(graphicsFile) xmlUnloadFile(graphicsFile) end function applySavedGraphicsToGui(drawDistance,textureDetail,skyDetail,waterDetail,bloomDetail,hdrDetail,savedPreset) guiRadioButtonSetSelected(graphicsPanel.radiobutton[tonumber(savedPreset)],true) guiScrollBarSetScrollPosition(graphicsPanel.scrollbar[1],drawDistance/100) guiSetText(graphicsPanel.label[5],tostring(drawDistance)) guiComboBoxSetSelected(graphicsPanel.combobox[1],textureDetail) guiComboBoxSetSelected(graphicsPanel.combobox[2],skyDetail) guiComboBoxSetSelected(graphicsPanel.combobox[3],waterDetail) guiComboBoxSetSelected(graphicsPanel.combobox[4],bloomDetail) guiComboBoxSetSelected(graphicsPanel.combobox[5],hdrDetail) end function applyGraphics() local drawDistance = guiGetText(graphicsPanel.label[5]) local textureDetail = guiComboBoxGetSelected(graphicsPanel.combobox[1]) local skyDetail = guiComboBoxGetSelected(graphicsPanel.combobox[2]) local waterDetail = guiComboBoxGetSelected(graphicsPanel.combobox[3]) local bloomDetail = guiComboBoxGetSelected(graphicsPanel.combobox[4]) local hdrDetail = guiComboBoxGetSelected(graphicsPanel.combobox[5]) setFarClipDistance(tonumber(drawDistance)) if textureDetail == 0 then toggleTextureDetail(true) elseif textureDetail == 1 then toggleTextureDetail(false) end if skyDetail == 0 then toggleSkyDetail(true) elseif skyDetail == 1 then toggleSkyDetail(false) end if waterDetail == 0 then toggleWaterShader(true) elseif waterDetail == 1 then toggleWaterShader(false) end if bloomDetail == 0 then toggleBloom(true) elseif bloomDetail == 1 then toggleBloom(false) end if hdrDetail == 0 then toggleHDR(true) elseif hdrDetail == 1 then toggleHDR(false) end saveGraphicsToXML() end addEventHandler("onClientGUIClick",graphicsPanel.button[1],applyGraphics,false) function closeGraphicsPanelWithButton() guiSetVisible(graphicsPanel.window[1],false) end addEventHandler("onClientGUIClick",graphicsPanel.button[2],closeGraphicsPanelWithButton,false) addEventHandler("onClientRender",root, function() if GraphicsPanelOpen then local getDrawDistance = math.max(guiScrollBarGetScrollPosition(graphicsPanel.scrollbar[1])*50,100) guiSetText(graphicsPanel.label[5],tostring(getDrawDistance)) guiSetText(graphicsPanel.label[13],"FPS: "..math.floor(getCurrentFPS())) end end) -- Switch to custom preset if any of the other GUI elements is clicked addEventHandler("onClientGUIScroll",graphicsPanel.scrollbar[1],function() guiRadioButtonSetSelected(graphicsPanel.radiobutton[4],true) end,false) addEventHandler("onClientGUIClick",graphicsPanel.combobox[1],function() guiRadioButtonSetSelected(graphicsPanel.radiobutton[4],true) end,false) addEventHandler("onClientGUIClick",graphicsPanel.combobox[2],function() guiRadioButtonSetSelected(graphicsPanel.radiobutton[4],true) end,false) addEventHandler("onClientGUIClick",graphicsPanel.combobox[3],function() guiRadioButtonSetSelected(graphicsPanel.radiobutton[4],true) end,false) addEventHandler("onClientGUIClick",graphicsPanel.combobox[4],function() guiRadioButtonSetSelected(graphicsPanel.radiobutton[4],true) end,false) addEventHandler("onClientGUIClick",graphicsPanel.combobox[5],function() guiRadioButtonSetSelected(graphicsPanel.radiobutton[4],true) end,false) Problems no save settings xml file graphics. Massage debugscript enabled to create graphics.xml file
  12. How to display under the building object group name dxtextdraw please? i create dxtextdraw health dxDrawText("Health = "..tostring(getElementData(hitElement,"object.health")),sWidth-375,sHeight-47,sWidth-272,sHeight-12,tocolor(255,255,255,255),1.0) --[[ Author: CiBeR Version: 0.1 Copyright: DayZ Gamemode. All rights reserved to Developers Info: MTA:DayZ Base Creation Addon Current Devs: Lawliet, CiBeR, Jboy, Remi, Renkon ]]-- local sWidth,sHeight = guiGetScreenSize() baseCPanel = { edit = {}, button = {}, window = {}, label = {}, column = {}, gridlist = {}, tabpanel = {}, tab = {}, } objectTable = { -- Hatchet is a dummy item, in case you need less parts than expected -- DIY (Wood) or DIY (Metal) must always be the first item that is needed {"Wooden Base", 11292, 1000, "Wood", "DIY (Wood)","Log","Stone","Hatchet",1,1,2,0}, {"Wood Fence", 16637, 1000, "Wood", "DIY (Wood)", "Log","Stone","Hatchet",1,1,1,0}, {"Wooden Door", 3093, 1000, "Wood", "DIY (Wood)", "Log", "Stone","Hatchet",1,1,1,0}, {"Wood Structure", 1482, 1000, "Wood", "DIY (Wood)", "Log", "Plank", "Nails",1,1,3,5}, {"Metal Fence", 1412, 5000, "Metal", "DIY (Metal)","RSJ","Stone","Hatchet",1,1,2,0}, {"Metal Door", 3029, 5000, "Metal", "DIY (Metal)","RSJ","Nails","Hatchet",1,2,2,0}, {"Shack", 1457, 5000, "Metal", "DIY (Metal)","Metal Sheet (Rusted)","Plank","Hatchet",1,2,2,0} } function render() baseCPanel.window[1] = guiCreateWindow(0.00, 0.37, 0.57, 0.61, "", true) guiWindowSetSizable(baseCPanel.window[1], false) guiSetVisible(baseCPanel.window[1], false) baseCPanel.tabpanel[1] = guiCreateTabPanel(0.03, 0.07, 0.95, 0.90, true, baseCPanel.window[1]) baseCPanel.tab[1] = guiCreateTab("Wood", baseCPanel.tabpanel[1]) baseCPanel.gridlist[1] = guiCreateGridList(0.01, 0.03, 0.36, 0.94, true, baseCPanel.tab[1]) baseCPanel.column[1] = guiGridListAddColumn(baseCPanel.gridlist[1], "Item", 0.9) baseCPanel.label[1] = guiCreateLabel(0.39, 0.04, 0.25, 0.06, "Item:", true, baseCPanel.tab[1]) baseCPanel.label[2] = guiCreateLabel(0.39, 0.10, 0.25, 0.06, "Durability:", true, baseCPanel.tab[1]) baseCPanel.label[3] = guiCreateLabel(0.59, 0.04, 0.25, 0.06, "", true, baseCPanel.tab[1]) baseCPanel.label[4] = guiCreateLabel(0.59, 0.10, 0.25, 0.06, "", true, baseCPanel.tab[1]) baseCPanel.label[5] = guiCreateLabel(0.39, 0.16, 0.25, 0.06, "Requires:", true, baseCPanel.tab[1]) baseCPanel.label[6] = guiCreateLabel(0.39, 0.22, 0.25, 0.06, "", true, baseCPanel.tab[1]) baseCPanel.label[7] = guiCreateLabel(0.39, 0.28, 0.25, 0.06, "", true, baseCPanel.tab[1]) baseCPanel.label[8] = guiCreateLabel(0.39, 0.34, 0.25, 0.06, "", true, baseCPanel.tab[1]) baseCPanel.label[9] = guiCreateLabel(0.39, 0.40, 0.25, 0.06, "", true, baseCPanel.tab[1]) baseCPanel.label[10] = guiCreateLabel(0.39, 0.46, 0.25, 0.06, "", true, baseCPanel.tab[1]) baseCPanel.label[11] = guiCreateLabel(0.39, 0.52, 0.25, 0.06, "", true, baseCPanel.tab[1]) baseCPanel.label[12] = guiCreateLabel(0.39, 0.68, 0.25, 0.06, "", true, baseCPanel.tab[1]) baseCPanel.button[1] = guiCreateButton(0.86, 0.88, 0.12, 0.08, "Place", true, baseCPanel.tab[1]) baseCPanel.tab[2] = guiCreateTab("Metal", baseCPanel.tabpanel[1]) baseCPanel.gridlist[2] = guiCreateGridList(0.01, 0.03, 0.36, 0.94, true, baseCPanel.tab[2]) baseCPanel.column[2] = guiGridListAddColumn(baseCPanel.gridlist[2], "Item", 0.9) baseCPanel.label[13] = guiCreateLabel(0.39, 0.04, 0.25, 0.06, "Item:", true, baseCPanel.tab[2]) baseCPanel.label[14] = guiCreateLabel(0.39, 0.10, 0.25, 0.06, "Durability:", true, baseCPanel.tab[2]) baseCPanel.label[15] = guiCreateLabel(0.59, 0.04, 0.25, 0.06, "", true, baseCPanel.tab[2]) baseCPanel.label[16] = guiCreateLabel(0.59, 0.10, 0.25, 0.06, "", true, baseCPanel.tab[2]) baseCPanel.label[17] = guiCreateLabel(0.39, 0.16, 0.25, 0.06, "Requires:", true, baseCPanel.tab[2]) baseCPanel.label[18] = guiCreateLabel(0.39, 0.22, 0.25, 0.06, "", true, baseCPanel.tab[2]) baseCPanel.label[19] = guiCreateLabel(0.39, 0.29, 0.25, 0.06, "", true, baseCPanel.tab[2]) baseCPanel.label[20] = guiCreateLabel(0.39, 0.35, 0.25, 0.06, "", true, baseCPanel.tab[2]) baseCPanel.label[21] = guiCreateLabel(0.39, 0.41, 0.25, 0.06, "", true, baseCPanel.tab[2]) baseCPanel.label[22] = guiCreateLabel(0.39, 0.48, 0.25, 0.06, "", true, baseCPanel.tab[2]) baseCPanel.label[23] = guiCreateLabel(0.39, 0.54, 0.25, 0.06, "", true, baseCPanel.tab[2]) baseCPanel.label[25] = guiCreateLabel(0.39, 0.60, 0.25, 0.06, "", true, baseCPanel.tab[2]) baseCPanel.button[2] = guiCreateButton(0.86, 0.88, 0.12, 0.08, "Place", true, baseCPanel.tab[2]) baseCPanel.tab[3] = guiCreateTab("Help", baseCPanel.tabpanel[1]) local row = 0 local row2 = 0 local name = "" local name2 = "" for i, item in ipairs(objectTable) do if item[4] == "Wood" then name = item[1] row = guiGridListAddRow (baseCPanel.gridlist[1]) end if item[4] == "Metal" then name2 = item[1] row2 = guiGridListAddRow(baseCPanel.gridlist[2]) end guiGridListSetItemText ( baseCPanel.gridlist[1], row, baseCPanel.column[1], name, false, false ) guiGridListSetItemText ( baseCPanel.gridlist[2], row2, baseCPanel.column[2], name2, false, false ) end addEventHandler("onClientGUIClick", baseCPanel.gridlist[1], function() getRequiredItems(1) end, false) addEventHandler("onClientGUIClick", baseCPanel.gridlist[2], function() getRequiredItems(2) end, false) end render() active = false function togPanel() if active then return end if isPedInVehicle(localPlayer) then return end guiSetVisible(baseCPanel.window[1], not guiGetVisible ( baseCPanel.window[1] )) showCursor(not isCursorShowing()) end bindKey ("F6", "down", togPanel) tempOb = {} dep = 5 multip = 1 local health = 0 --[[ function updatePos() local ob = tempOb[localPlayer] if ob then local x, y = getCursorPosition() local cX, cY, cZ = getCameraMatrix() if getKeyState("lshift") then multip = 4 else multip = 1 end if getKeyState("arrow_u") then dep = dep + .1 * multip outputChatBox("Dep = "..tostring(dep)) elseif getKeyState("arrow_d") then dep = dep - .1 * multip end local nX, nY, nZ = getWorldFromScreenPosition(x*cX, y*cY, dep) local aX, aY, aZ = getElementPosition(ob) if (aX ~= nX) or (aY ~= nY) or (aZ ~= nZ) then setElementPosition(ob, nX, nY, nZ) end end end ]] function updatePos() local object = tempOb[localPlayer] if object then local screenX, screenY = guiGetScreenSize() local x,y = getCursorPosition() local x,y = x*screenX,y*screenY local sX,sY,sZ = getWorldFromScreenPosition(x,y,0) local sX2,sY2,sZ2 = getWorldFromScreenPosition(x,y,20) local hit,oX,oY,oZ = processLineOfSight(sX,sY,sZ,sX2,sY2,sZ2,true,false,false,true,false,true,false,false,object) if not hit then return end setElementPosition(object,oX,oY,oZ + getElementDistanceFromCentreOfMassToBaseOfModel(object)) end end local rotationAxis = "z" function setRotationOfObject(button,state) local object = tempOb[localPlayer] if button == "arrow_u" or button == "arrow_d" then if state then rotationAxis="y" else rotationAxis="z" end elseif button == "arrow_r" or button == "arrow_l" then if state then rotationAxis="x" else rotationAxis="z" end end if not state then return end if button == "mouse_wheel_up" or button == "pgup" then if rotationAxis == "z" then local x,y,z = getElementRotation(object) setElementRotation(object,x,y,z+5) elseif rotationAxis == "y" then local x,y,z = getElementRotation(object) setElementRotation(object,x,y+5,z) elseif rotationAxis == "x" then local x,y,z = getElementRotation(object) setElementRotation(object,x+5,y,z) end elseif button == "mouse_wheel_down" or button == "pgdn" then if rotationAxis == "z" then local x,y,z = getElementRotation(object) setElementRotation(object,x,y,z-5) elseif rotationAxis == "y" then local x,y,z = getElementRotation(object) setElementRotation(object,x,y-5,z) elseif rotationAxis == "x" then local x,y,z = getElementRotation(object) setElementRotation(object,x-5,y,z) end end end isGui = false addEventHandler( "onClientMouseEnter", root, function () isGui = true end) addEventHandler( "onClientMouseLeave", root, function () isGui = false end) function checkClick(bt, state) if bt == "left" and state == "down" and tempOb[localPlayer] and not isGui then local x, y, z = getElementPosition(tempOb[localPlayer]) local rx, ry, rz = getElementRotation(tempOb[localPlayer]) local model = getElementModel(tempOb[localPlayer]) removeEventHandler("onClientRender", root, updatePos) destroyElement(tempOb[localPlayer]) tempOb[localPlayer] = nil triggerServerEvent("addon.basecreator:newObject", localPlayer, model, x, y, z, rx, ry, rz, health ) active = false removeEventHandler("onClientClick", root, checkClick) removeEventHandler("onClientKey",root,setRotationOfObject) removeEventHandler("onClientClick", root, handleObDelete) takeItemsFromPlayer(model) end end local gridlistnumber = 0 function handleObSpawn(_, state, x, y) if state == "up" and not tempOb[localPlayer] then local theObjectName = guiGridListGetItemText ( baseCPanel.gridlist[gridlistnumber], guiGridListGetSelectedItem ( baseCPanel.gridlist[gridlistnumber] ), 1 ) if theObjectName then for i, item in ipairs(objectTable) do if item[1] == theObjectName then if getElementData(localPlayer,item[5]) and getElementData(localPlayer,item[5]) >= item[9] then if getElementData(localPlayer,item[6]) and getElementData(localPlayer,item[6]) >= item[10] then if getElementData(localPlayer,item[7]) and getElementData(localPlayer,item[7]) >= item[11] then if getElementData(localPlayer,item[8]) and getElementData(localPlayer,item[8]) >= item[12] then local id = item[2] local pX,pY,pZ = getElementPosition(localPlayer) tempOb[localPlayer] = createObject(id, pX+2, pY+2, pZ, 0, 0, 0) health = item[3] if tempOb[localPlayer] then addEventHandler("onClientRender", root, updatePos) addEventHandler("onClientClick", root, checkClick) addEventHandler("onClientKey",root,setRotationOfObject) addEventHandler("onClientClick", root, handleObDelete) active = true setElementCollisionsEnabled(tempOb[localPlayer], false) setElementAlpha(tempOb[localPlayer],150) end else outputChatBox("You need "..item[8].." to build this!",255,0,0) return end else outputChatBox("You need "..item[7].." to build this!",255,0,0) return end else outputChatBox("You need "..item[6].." to build this!",255,0,0) return end else outputChatBox("You need "..item[5].." to build this!",255,0,0) return end end end end end end function handleObDelete(button, state) if button == "right" then removeEventHandler("onClientRender", root, updatePos) if tempOb[localPlayer] then destroyElement(tempOb[localPlayer]) end removeEventHandler("onClientClick", root, checkClick) removeEventHandler("onClientKey",root, setRotationOfObject) tempOb[localPlayer] = nil active = false removeEventHandler("onClientClick", root, handleObDelete) end end function getRequiredItems(number) local clickedItem = guiGridListGetItemText(baseCPanel.gridlist[number], guiGridListGetSelectedItem (baseCPanel.gridlist[number]),1) for i, item in ipairs(objectTable) do if clickedItem == item[1] then if number == 1 then guiSetText(baseCPanel.label[3],tostring(item[1])) guiSetText(baseCPanel.label[4],tostring(item[3])) guiSetText(baseCPanel.label[6],tostring(item[5]).." x"..tostring(item[9])) guiSetText(baseCPanel.label[7],tostring(item[6]).." x"..tostring(item[10])) guiSetText(baseCPanel.label[8],tostring(item[7]).." x"..tostring(item[11])) guiSetText(baseCPanel.label[9],tostring(item[8]).." x"..tostring(item[12])) elseif number == 2 then guiSetText(baseCPanel.label[15],tostring(item[1])) guiSetText(baseCPanel.label[16],tostring(item[3])) guiSetText(baseCPanel.label[18],tostring(item[5]).." x"..tostring(item[9])) guiSetText(baseCPanel.label[19],tostring(item[6]).." x"..tostring(item[10])) guiSetText(baseCPanel.label[20],tostring(item[7]).." x"..tostring(item[11])) guiSetText(baseCPanel.label[21],tostring(item[8]).." x"..tostring(item[12])) end end end gridlistnumber = number end function setTheObjectUnbreakable(object) setObjectBreakable(object,false) end addEvent("setTheObjectUnbreakable",true) addEventHandler("setTheObjectUnbreakable",root,setTheObjectUnbreakable) function takeItemsFromPlayer(theModel) for i, item in ipairs(objectTable) do if theModel == item[2] then setElementData(localPlayer,item[6],getElementData(localPlayer,item[6])-item[10]) setElementData(localPlayer,item[7],getElementData(localPlayer,item[7])-item[11]) setElementData(localPlayer,item[8],getElementData(localPlayer,item[8])-item[12]) end end end function setObjectDamage(weapon,_,_,hitX,hitY,hitZ,hitElement) if weapon ~= 0 then if hitElement and getElementType(hitElement) == "object" then for i, object in ipairs(objectTable) do if getElementModel(hitElement) == object[2] then setElementData(hitElement,"object.health",getElementData(hitElement,"object.health")-1) triggerServerEvent("onObjectDamage",root,hitElement,getElementData(hitElement,"object.health"),getElementData(hitElement,"bc.ID")) --outputChatBox("Health = "..tostring(getElementData(hitElement,"object.health"))) dxDrawText("Health = "..tostring(getElementData(hitElement,"object.health")),sWidth-375,sHeight-47,sWidth-272,sHeight-12,tocolor(255,255,255,255),1.0) end end if getElementData(hitElement,"object.health") <= 0 then triggerServerEvent("onObjectDestroy",root,hitElement,getElementData(hitElement,"bc.ID")) end end end end addEventHandler("onClientPlayerWeaponFire",root,setObjectDamage) --[[Events]]-- addEventHandler ( "onClientGUIClick", baseCPanel.button[1], handleObSpawn, false ) addEventHandler ( "onClientGUIClick", baseCPanel.button[2], handleObSpawn, false ) --addEventHandler ( "onClientGUIClick", baseCPanel.button[2], handleObDelete, false )
×
×
  • Create New...