Jump to content

MtaBrasilBr

Members
  • Posts

    4
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

MtaBrasilBr's Achievements

Vic

Vic (3/54)

0

Reputation

  1. spraying_c.lua dxDrawMaterialLine3D(x1,y1,z1,x2,y2,z2,tex,size,tocolor(255,255,255,128),x1+nx,y1+ny,z1+nz) Change To dxDrawMaterialLine3D(x1,y1,z1,x2,y2,z2,tex,size,tocolor(255,255,255,255),x1+nx,y1+ny,z1+nz) drawing_c.lua dxDrawImageSection(x,y,256,256,getTickCount()*0.004,0,256,256,"imgs/transparent.png",0,0,0,white,true) Change To dxDrawImageSection(x,y,256,256,getTickCount()*0.000,0,256,256,"imgs/transparent.png",0,0,0,white,true) drawing_c.lua dxDrawRectangle(x-4,y-4,264,264,green,true) Change To dxDrawRectangle(x-4,y-4,264,264,blue,true)
  2. I recently opened an MTASA server, I had this drawing mod on my old server and I would like to know how I can fix these errors that appear in the console. I had already asked aki earlier, but I ran out of pc and had no way to answer the topic. Here are the errors: [2022-05-19 18:31:10] Starting drawtag [2022-05-19 18:31:10] WARNING: drawtag_bc\drawtag_bc_s.lua:4: Bad argument @ 'addEventHandler' [Expected function at argument 3, got nil] [2022-05-19 18:31:10] WARNING: drawtag_bc\drawtag_bc_s.lua:5: Bad argument @ 'addEventHandler' [Expected function at argument 3, got nil] [2022-05-19 18:31:10] WARNING: drawtag_bc\drawtag_bc_s.lua:6: Bad argument @ 'addEventHandler' [Expected function at argument 3, got nil] [2022-05-19 18:31:10] WARNING: drawtag_bc\drawtag_bc_s.lua:7: Bad argument @ 'addEventHandler' [Expected function at argument 3, got nil] [2022-05-19 18:31:10] WARNING: drawtag_bc\drawtag_bc_s.lua:47: Bad argument @ 'getResourceState' [Expected resource-data at argument 1, got boolean] [2022-05-19 18:31:10] WARNING: drawtag_bc\save_tags.lua:33: call: failed to call 'drawtag:getAllTags' [string "?"] [2022-05-19 22:54:10] WARNING: drawtag_bc\save_tags.lua:34: bad argument #1 to 'ipairs' (table expected, got boolean) here is the mod script: drawtag_bc_s.lua function initDrawtagBC() if initialized then return end initialized = true addEventHandler("drawtag:onTagStartSpray",root,startDrawMsg) addEventHandler("drawtag:onTagFinishSpray",root,finishDrawMsg) addEventHandler("drawtag:onTagStartErase",root,startEraseMsg) addEventHandler("drawtag:onTagFinishErase",root,finishEraseMsg) addCommandHandler("drawtag",modeDraw) addCommandHandler("erasetag",modeErase) addCommandHandler("tagsize",changeSize) addEvent("drawtag_bc:copyTag",true) addEventHandler("drawtag_bc:copyTag",root,copyTag) loadTagsFromFile() local all_players = getElementsByType("player") for plnum,player in ipairs(all_players) do exports.drawtag:setPlayerTagSize(player,1.5) end addEventHandler("onPlayerJoin",root,setDefaultTagSize) end function uninitDrawtagBC() if not initialized then return end initialized = nil removeEventHandler("drawtag:onTagStartSpray",root,startDrawMsg) removeEventHandler("drawtag:onTagFinishSpray",root,finishDrawMsg) removeEventHandler("drawtag:onTagStartErase",root,startEraseMsg) removeEventHandler("drawtag:onTagFinishErase",root,finishEraseMsg) removeCommandHandler("drawtag",modeDraw) removeCommandHandler("erasetag",modeErase) removeCommandHandler("tagsize",changeSize) removeEventHandler("drawtag_bc:copyTag",root,copyTag) saveTagsToFile() removeEventHandler("onPlayerJoin",root,setDefaultTagSize) end function initOnStart(resource) if getResourceName(resource) == "drawtag" then initDrawtagBC() elseif source == resourceRoot and getResourceState(getResourceFromName("drawtag")) == "running" then initDrawtagBC() end end function uninitOnStop(resource) if getResourceName(resource) == "drawtag" then uninitDrawtagBC() elseif source == resourceRoot and getResourceState(getResourceFromName("drawtag")) == "running" then uninitDrawtagBC() end end addEventHandler("onResourceStart",root,initOnStart) addEventHandler("onResourceStop",root,uninitOnStop) function setDefaultTagSize() exports.drawtag:setPlayerTagSize(source,1.5) end function identifyPlayer(player) return player and getPlayerName(player) or "Unknown player" end function modeDraw(player) exports.drawtag:setPlayerSprayMode(player,"draw") end function modeErase(player) exports.drawtag:setPlayerSprayMode(player,"erase") end function changeSize(player,cmdname,size) size = tonumber(size) if not size or math.abs(size) > 1000 then return end if not exports.drawtag:setPlayerTagSize(player,size) then return end end function copyTag() local png = exports.drawtag:getTagTexture(source) exports.drawtag:setPlayerTagTexture(client,png) end here is the mod script: save_tags.lua function loadTagsFromFile() if tags_loaded then return end tags_loaded = true local tags_file = xmlLoadFile("saved_tags/tags.xml") if not tags_file then return end local png_file = fileOpen("saved_tags/tags_png.dat",true) if not png_file then xmlUnloadFile(tags_file) return end local tag_nodes = xmlNodeGetChildren(tags_file) for tagnum,tag_node in ipairs(tag_nodes) do local tagdata = xmlNodeGetAttributes(tag_node) fileSetPos(png_file,tagdata.png_off) exports.drawtag:createTagFromExistingData( nil, tagdata.x,tagdata.y,tagdata.z, tagdata.x1,tagdata.y1,tagdata.z1, tagdata.x2,tagdata.y2,tagdata.z2, tagdata.nx,tagdata.ny,tagdata.nz, tagdata.size, tagdata.vis,fileRead(png_file,tagdata.png_len) ) end fileClose(png_file) xmlUnloadFile(tags_file) end function saveTagsToFile() if not tags_loaded then return end tags_loaded = nil local tags_file = xmlCreateFile("saved_tags/tags.xml","tags") if not tags_file then return end local png_file = fileCreate("saved_tags/tags_png.dat") if not png_file then xmlUnloadFile(tags_file) return end local all_tags = exports.drawtag:getAllTags() for tagnum,tag in ipairs(all_tags) do local att,x,y,z,x1,y1,z1,x2,y2,z2,nx,ny,nz,size,vis,png = exports.drawtag:getTagData(tag) if not att then local tag_node = xmlCreateChild(tags_file,"tag") xmlNodeSetAttribute(tag_node,"x",x) xmlNodeSetAttribute(tag_node,"y",y) xmlNodeSetAttribute(tag_node,"z",z) xmlNodeSetAttribute(tag_node,"x1",x1) xmlNodeSetAttribute(tag_node,"y1",y1) xmlNodeSetAttribute(tag_node,"z1",z1) xmlNodeSetAttribute(tag_node,"x2",x2) xmlNodeSetAttribute(tag_node,"y2",y2) xmlNodeSetAttribute(tag_node,"z2",z2) xmlNodeSetAttribute(tag_node,"nx",nx) xmlNodeSetAttribute(tag_node,"ny",ny) xmlNodeSetAttribute(tag_node,"nz",nz) xmlNodeSetAttribute(tag_node,"size",size) xmlNodeSetAttribute(tag_node,"vis",vis) xmlNodeSetAttribute(tag_node,"png_off",fileGetPos(png_file)) xmlNodeSetAttribute(tag_node,"png_len",fileWrite(png_file,png)) destroyElement(tag) end end fileClose(png_file) xmlSaveFile(tags_file) xmlUnloadFile(tags_file) end
  3. wanted help with this mod : https://web.archive.org/web/20140831123107if_/http://crystalmv.net84.net/files/drawtag_1.1.zip it simply does not save the server drawings the following errors appear : can someone help me to make it work properly [2020-12-01 22:54:25] ERROR: drawtag_bc\save_tags.lua:33: call: failed to call 'drawtag:getAllTags' [string "?"] [2020-12-01 22:54:25] ERROR: drawtag_bc\save_tags.lua:34: bad argument #1 to 'ipairs' (table expected, got boolean) [2020-12-01 22:54:25] WARNING: drawtag_bc\drawtag_bc_s.lua:47: Bad argument @ 'getResourceState' [Expected resource-data at argument 1, got boolean] I contacted the creator without response.
  4. I want to edit this script from my friend's server, I want to leave the brush shape for the drawing trail to leave square ,and a graffiti panel. Script: function createDrawingWindow() local sw,sh = guiGetScreenSize() draw_window = guiCreateWindow((sw-512)*0.5,(sh-384)*0.5,512,384,"Grafite Ou Pixe Aki.",false) guiWindowSetSizable(draw_window,false) button_close = guiCreateButton(352,304,96,32,"Fechar",false,draw_window) button_done = guiCreateButton(304,344,64,24,"Salvar",false,draw_window) button_clear = guiCreateButton(432,344,64,24,"Apagar",false,draw_window) guiSetVisible(draw_window,false) setDefaultColors() brush_size = 4 drawdest = dxCreateRenderTarget(256,256,true) erasedest = dxCreateRenderTarget(256,256,false) if not drawdest or not erasedest then return end black = tocolor(0,0,0,255) white = tocolor(255,255,255,255) green = tocolor(0,128,0,255) midblue = tocolor(0,0,192,255) red = tocolor(0, 0, 255) lime = tocolor(0,255,0,255) blue = tocolor(0,0,255,255) transparent = tocolor(255,255,255,128) addEventHandler("onClientGUIClick",button_close,buttonCloseDrawingWindow,false) addEventHandler("onClientGUIClick",button_done,buttonDoneDrawing,false) addEventHandler("onClientGUIClick",button_clear,buttonClearImage,false) brush_preview_bg = white end function setDefaultColors() local r,g,b = {},{},{} colors = {r = r,g = g,b = b} r[0x01],g[0x01],b[0x01] = 0,0,0 r[0x02],g[0x02],b[0x02] = 255,255,255 r[0x03],g[0x03],b[0x03] = 255,0,0 r[0x04],g[0x04],b[0x04] = 255,255,0 r[0x05],g[0x05],b[0x05] = 0,255,0 r[0x06],g[0x06],b[0x06] = 0,255,255 r[0x07],g[0x07],b[0x07] = 0,0,255 r[0x08],g[0x08],b[0x08] = 255,0,255 r[0x09],g[0x09],b[0x09] = 128,128,128 r[0x0A],g[0x0A],b[0x0A] = 192,192,192 r[0x0B],g[0x0B],b[0x0B] = 128,0,0 r[0x0C],g[0x0C],b[0x0C] = 128,128,0 r[0x0D],g[0x0D],b[0x0D] = 0,128,0 r[0x0E],g[0x0E],b[0x0E] = 0,128,128 r[0x0F],g[0x0F],b[0x0F] = 0,0,128 r[0x10],g[0x10],b[0x10] = 128,0,128 active_color = 1 end function buttonCloseDrawingWindow(button,state) if button ~= "left" or state ~= "up" then return end showDrawingWindow(false) end function buttonClearImage(button,state) if button ~= "left" or state ~= "up" then return end addEventHandler("onClientRender",root,clearImage) end function clearImage() dxSetRenderTarget(drawdest,true) dxSetRenderTarget() removeEventHandler("onClientRender",root,clearImage) end function buttonDoneDrawing(button,state) if button ~= "left" or state ~= "up" then return end updateTagPNGData() end function updateTagPNGData() local current_tag = getElementData(localPlayer,"drawtag:tag") if not current_tag then return end local pixel_data = dxConvertPixels(dxGetTexturePixels(drawdest),"png") setElementData(current_tag,"pngdata",pixel_data) end function showDrawingWindow(show) if type(show) ~= "boolean" then return false end guiSetVisible(draw_window,show) showCursor(show) local toggleEventHandler = show and addEventHandler or removeEventHandler toggleEventHandler("onClientClick",root,clickedWindow) toggleEventHandler("onClientRender",root,renderDrawingWindow) return true end function isDrawingWindowVisible() return guiGetVisible(draw_window) end function renderDrawingWindow() local prevblend = dxGetBlendMode() local x,y = guiGetPosition(draw_window,false) drawToPicture(x+32,y+32) editBrush(x+320,y+48) renderPicture(x+32,y+32) renderColorList(x+68,y+312) renderBrushEditor(x+320,y+32) dxSetBlendMode(prevblend) local cx,cy = getCursorPosition() local sw,sh = guiGetScreenSize() cx,cy = cx*sw,cy*sh if drawing ~= false and cx >= x+32 and cy >= y+32 and cx < x+288 and cy < y+288 then local color = tocolor(colors.r[active_color],colors.g[active_color],colors.b[active_color],255) drawTrimmedCircle(cx,cy,brush_size,color,x+32,y+32,x+288,y+288) end end function drawToPicture(x,y) if not isCursorShowing() then return end dxSetBlendMode("modulate_add") local cx,cy = getCursorPosition() local sw,sh = guiGetScreenSize() cx,cy = cx*sw-x,cy*sh-y cx,cy = cx,cy if drawing then dxSetRenderTarget(drawdest) local color = tocolor(colors.r[active_color],colors.g[active_color],colors.b[active_color],255) dxDrawLine(px,py,cx,cy,color,brush_size*2) drawCircle(px,py,brush_size,color) drawCircle(cx,cy,brush_size,color) dxSetRenderTarget() end px,py = cx,cy end function editBrush(x,y) if not editingcolor and not editingsize or not isCursorShowing() then return end if not getKeyState("mouse1") and not getKeyState("mouse2") then stopEditingColor() return end local cx = getCursorPosition() local sw = guiGetScreenSize() cx = cx*sw-x if editingcolor then local new_color = cx*256/160 if editingsnap then new_color = math.floor((new_color+8)/16)*16 end new_color = math.min(math.max(new_color,0),255) editingcolor[active_color] = new_color elseif editingsize then local new_size = cx*32/160 if editingsnap then new_size = math.floor(new_size+0.5) end new_size = math.min(math.max(new_size,1),32) brush_size = new_size end end function drawCircle(x,y,r,color) for yoff = math.floor(-r)+0.5,r+0.5 do local xoff = math.sqrt(r*r-yoff*yoff) dxDrawRectangle(x-xoff,y+yoff,2*xoff,1,color) end end function drawTrimmedCircle(x,y,r,color,x1,y1,x2,y2) local dy1,dy2 = math.max(-r,y1-y),math.min(r,y2-y-1) for yoff = math.floor(dy1)+0.5,dy2+0.5 do local xoff = math.sqrt(r*r-yoff*yoff) local dx1,dx2 = math.max(x-xoff,x1),math.min(x+xoff,x2) dxDrawRectangle(dx1,y+yoff,dx2-dx1,1,color,true) end end function renderPicture(x,y) dxSetBlendMode("blend") dxDrawRectangle(x-4,y-4,264,264,red,true) dxDrawImageSection(x,y,256,256,getTickCount()*0.000,0,256,256,"imgs/transparent.png",0,0,0,white,true) dxSetBlendMode("add") dxDrawImage(x,y,256,256,drawdest,0,0,0,white,true) end function renderColorList(x,y) dxSetBlendMode("blend") dxDrawRectangle(x-8,y-8,200,56,white,true) for c = 1,16 do local cx = x+(c-1)%8*24 local cy = y+math.floor((c-1)/8)*24 dxDrawRectangle(cx-3,cy-3,22,22,(c == active_color) and midblue or black,true) dxDrawRectangle(cx,cy,16,16,tocolor(colors.r[c],colors.g[c],colors.b[c],255),true) end end function renderBrushEditor(x,y) local r = colors.r[active_color] local g = colors.g[active_color] local b = colors.b[active_color] dxDrawImage(x,y,160,24,"imgs/red.png",0,0,0,tocolor(255,g,b,255),true) dxDrawImage(x,y+48,160,24,"imgs/green.png",0,0,0,tocolor(r,255,b,255),true) dxDrawImage(x,y+96,160,24,"imgs/blue.png",0,0,0,tocolor(r,g,255,255),true) dxDrawImage(x,y+144,160,24,"imgs/size.png",0,0,0,white,true) local rx = x+r*160/256 local gx = x+g*160/256 local bx = x+b*160/256 local sx = x+brush_size*160/32 dxDrawRectangle(rx-3,y-3,6,30,white,true) dxDrawRectangle(rx-2,y-2,4,28,red,true) dxDrawRectangle(gx-3,y+48-3,6,30,white,true) dxDrawRectangle(gx-2,y+48-2,4,28,lime,true) dxDrawRectangle(bx-3,y+96-3,6,30,white,true) dxDrawRectangle(bx-2,y+96-2,4,28,blue,true) dxDrawRectangle(sx-3,y+144-3,6,30,white,true) dxDrawRectangle(sx-2,y+144-2,4,28,black,true) dxDrawRectangle(x+32,y+180,96,80,white,true) dxDrawRectangle(x+36,y+184,88,72,brush_preview_bg,true) drawTrimmedCircle(x+80,y+220,brush_size,tocolor(r,g,b,255),x+40,y+188,x+120,y+252) end function clickedWindow(button,state,x,y) if state == "down" then local wx,wy = guiGetPosition(draw_window,false) x,y = x-wx,y-wy if button == "left" then selectColor(x,y) startDrawing(x,y) end if button == "left" or button == "right" then startEditingBrush(button,x,y) end if button == "left" then changeBrushPreviewBackground(x,y) end else if button == "left" then stopDrawing() end end end function selectColor(x,y) x,y = x-68,y-312 if x < 0 or x >= 192 or y < 0 or y >= 48 then return end if x%24 >= 16 or y%24 >= 16 then return end active_color = math.floor(y/24)*8+math.floor(x/24)+1 end function startDrawing(x,y) x,y = x-32,y-32 if x < 0 or x >= 256 or y < 0 or y >= 256 then return end px,py = x,y drawing = true end function stopDrawing() drawing = nil end function startEditingBrush(btn,x,y) x,y = x-320,y-32 if x < 0 or x >= 160 or y < 0 or y >= 192 then return end if y%48 >= 24 then return end y = math.floor(y/48) if y == 0 then editingcolor = colors.r elseif y == 1 then editingcolor = colors.g elseif y == 2 then editingcolor = colors.b elseif y == 3 then editingsize = true end editingsnap = btn == "right" end function stopEditingColor() editingcolor = nil editingsize = nil editingsnap = nil end function changeBrushPreviewBackground(x,y) x,y = x-320-36,y-32-184 if x < 0 or x >= 88 or y < 0 or y >= 72 then return end brush_preview_bg = brush_preview_bg == white and black or white end --------------------------------------- function setEditorTexture(pngdata) local tex = dxCreateTexture(pngdata) local plaindata = dxGetTexturePixels(tex) destroyElement(tex) return dxSetTexturePixels(drawdest,plaindata) end
×
×
  • Create New...