Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 17/11/19 in all areas

  1. Hi guys i want show how to cover map (file with .map) to Lua script, but not finished yet, Its cover this elements: Object Vehicle Ped Marker Pickup Blip RemoveWorldObject 1) Use this code: addCommandHandler("covermap", function (thePlayer, _, map) if not (map) then return end local file = xmlLoadFile(map..".map") if (file) then local newMapFile = fileCreate(map..".Lua") if (newMapFile) then local mapTable = {} local mapText = "" local functionName = false for i,element in ipairs(xmlNodeGetChildren(file)) do local elementType = xmlNodeGetName(element) if not (mapTable[elementType]) then mapTable[elementType] = {} end table.insert(mapTable[elementType], xmlNodeGetAttributes(element)) end for type, dataList in pairs(mapTable) do mapText = mapText.."----- "..type..": # "..(#dataList).."\r\n" if (type == "object") then for _, data in ipairs(dataList) do mapText = mapText.."createObject".."("..(data.model or "nil")..", "..(data.posX or "nil")..", "..(data.posY or "nil")..", "..(data.posZ or "nil")..", "..(data.rotX or 0)..", "..(data.rotY or 0)..", "..(data.rotZ or 0)..")\r\n" end elseif (type == "vehicle") then for _, data in ipairs(dataList) do mapText = mapText.."createVehicle".."("..(data.model or "nil")..", "..(data.posX or "nil")..", "..(data.posY or "nil")..", "..(data.posZ or "nil")..", "..(data.rotX or 0)..", "..(data.rotY or 0)..", "..(data.rotZ or 0)..")\r\n" end elseif (type == "ped") then for _, data in ipairs(dataList) do mapText = mapText.."createPed".."("..(data.model or "nil")..", "..(data.posX or "nil")..", "..(data.posY or "nil")..", "..(data.posZ or "nil")..", "..(data.rotZ or 0)..")\r\n" end elseif (type == "marker") then local data.color = table.concat({getColorFromString(data.color or "#ff0000")}, ", ") for _, data in ipairs(dataList) do mapText = mapText.."createMarker".."("..(data.posX or "nil")..", "..(data.posY or "nil")..", "..(data.posZ or "nil")..", "..(data.type or "checkpoint")..", "..(data.size or "4")..", "..(data.color or "nil")..")\r\n" end elseif (type == "pickup") then for _, data in ipairs(dataList) do mapText = mapText.."createPickup".."("..(data.posX or "nil")..", "..(data.posY or "nil")..", "..(data.posZ or "nil")..", "..(data.type or "nil")..", "..(data.amount or "nil")..", "..(data.respawn or "30000")..")\r\n" end elseif (type == "blip") then local r, g, b, a = table.concat({getColorFromString(data.color or "#ff0000")}, ", ") for _, data in ipairs(dataList) do mapText = mapText.."createBlip".."("..(data.posX or "nil")..", "..(data.posY or "nil")..", "..(data.posZ or "nil")..", "..(data.icon or "0")..", 2, "..(r or "255")..", "..(g or "255")..", "..(b or "255")..", "..(a or "255")..", "..(data.ordering or "0")..")\r\n" end elseif (type == "removeWorldObject") then for _, data in ipairs(dataList) do mapText = mapText.."removeWorldObject".."("..(data.radius or "nil")..", "..(data.interior or "nil")..", "..(data.model or "nil")..", "..(data.lodModel or "nil")..", "..(data.posX or 0)..", "..(data.posY or 0)..", "..(data.posZ or 0)..")\r\n" end end end fileWrite(newMapFile, tostring(mapText)) fileFlush(newMapFile) fileClose(newMapFile) outputDebugString("Successfully "..map..".map covered to "..map..".Lua") else outputDebugString("Fail to create new map file") end xmlUnloadFile(file) else outputDebugString("Fail to load map file") end end) 2) For use removeWorldObject add this function function removeWorldObject(radius, interior, model, lodModel, posX, posY, posZ) table.insert(objectsRemoved, {radius, interior, model, lodModel, posX, posY, posZ}) removeWorldModel(model, radius, posX, posY, posZ, interior) removeWorldModel(lodModel, radius, posX, posY, posZ, interior) end 3) For restore all objects was removed when stop resource add this code: addEventHandler("onResourceStop", resourceRoot, function( ) for _, data in ipairs(objectsRemoved) do local radius, interior, model, lodModel, posX, posY, posZ = unpack(data) restoreWorldModel(model, radius, posX, posY, posZ, interior) restoreWorldModel(lodModel, radius, posX, posY, posZ, interior) end end) 4) Remember add this table: local objectsRemoved = {} 5) Use command 'covermap filename' example: /covermap base51 I have hope this TUT helpful and sorry for bad english
    1 point
  2. 1 point
  3. Example code: local scx, scy = guiGetScreenSize() local text = "hello world" showCursor(true) addEventHandler("onClientRender", root, function() if isCursorShowing() then -- can be removed local cx, cy = getCursorPosition() local boxW = dxGetTextWidth(text) + 2*20 -- add left and right paddings local boxH = dxGetFontHeight() + 2*10 -- add top and bottom paddings dxDrawRectangle(cx*scx, cy*scy, boxW, boxH) dxDrawText(text, cx*scx, cy*scy, boxW+cx*scx, boxH+cy*scy, tocolor(0, 0, 0, 255), 1, "default", "center", "center") end end) Result: Also don't forget about scale, font and color-coded properties which affect on dxGetTextWidth, dxGetFontHeight and drawing functions
    1 point
  4. Tente: itens [ tostring(weaponID) ] = nil Se não resolver, tente depurar o código... exiba os itens, verifica se tal index/valor existe na tabela antes de remover, etc.
    1 point
  5. A ideia é sempre obter o que já está salvo, efetuar as operações em cima do que obteve e então salvar todos novamente. -- Exemplo addCommandHandler("inventario", function(thePlayer, _, action, WeaponID, ammo) local houseName = playersInInterior[thePlayer] local itens = fromJSON(getHouseData(houseName, "houseWeapons")) if (action == "incluir") itens[WeaponID] = ammo else if (action == "remover") then itens[WeaponID] = nil end setHouseData(houseName, "houseWeapons", toJSON(itens)) end )
    1 point
  6. Modifique a handling dele. Ele causa dano absurdo ao colidir por causa da massa alta que ele tem. SetVehicleHandling
    1 point
×
×
  • Create New...