MenorTH Posted November 22, 2020 Share Posted November 22, 2020 (edited) Ola! Bom, comecei a fazer scipts para o MTA a pouco tempo e hoje me deparei com um erro que não consegui solucionar nas linhas 43 e 44 do lado Server Bad argument @'setElementVisibleTo' [Expected element at argument 2, got nil] Gostaria de saber como eu poderia arrumar este erro e em oque eu errei se possível Client: local screenW, screenH = guiGetScreenSize() local x, y = (screenW/1366), (screenH/768) painel = false vehjob = {} function DX () dxDrawRectangle(screenW * 0.2804, screenH * 0.3372, screenW * 0.4392, screenH * 0.3581, tocolor(0, 0, 0, 150), false) dxDrawRectangle(screenW * 0.2987, screenH * 0.3698, screenW * 0.4026, screenH * 0.1302, tocolor(0, 0, 0, 200), false) dxDrawRectangle(screenW * 0.2987, screenH * 0.5326, screenW * 0.4026, screenH * 0.1302, tocolor(0, 0, 0, 200), false) dxDrawText("R$4000", screenW * 0.2987, screenH * 0.3698, screenW * 0.7013, screenH * 0.5000, tocolor(254, 254, 254, 200), 2.00, "default", "center", "center", false, false, false, false, false) dxDrawText("R$8000", screenW * 0.2987, screenH * 0.5326, screenW * 0.7013, screenH * 0.6628, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false) end addEvent ("Abrepainel", true) addEventHandler ( "Abrepainel", root, DX) function AbrirPainel () if painel == false then addEventHandler ( "onClientRender", root, DX ) painel = true showCursor ( true ) end end addEvent ("Abrepainell", true) addEventHandler ( "Abrepainell", root, AbrirPainel) function FecharPainel () if painel == true then removeEventHandler ( "onClientRender", root, DX ) painel = false showCursor ( false ) end end addEvent ("Fechapainel", true) addEventHandler ("Fechapainel", root, FecharPainel) bindKey("backspace", "down", FecharPainel) function Botao1 (_,state) if painel == true then if state == "down" then if isCursorOnElement (screenW * 0.2987, screenH * 0.3698, screenW * 0.4026, screenH * 0.1302) then triggerServerEvent("RotaUm", localPlayer) end end end end addEventHandler ("onClientClick", root, Botao1) function Botao2 (_,state) if painel == true then if state == "down" then if isCursorOnElement(screenW * 0.2987, screenH * 0.5326, screenW * 0.4026, screenH * 0.1302) then local x, y, z = getElementPosition(localPlayer) setClipboard(""..x..", "..y..", "..z.." -1") end end end end addEventHandler ("onClientClick", root, Botao2) function isCursorOnElement ( x, y, w, h ) local mx, my = getCursorPosition () local fullx, fully = guiGetScreenSize () cursorx, cursory = mx*fullx, my*fully if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then return true else return false end end Server: Salario1 = 4000 Salario2 = 8000 vehjob = {} MarkerEmprego = createMarker(276.63165283203, 1411.712890625, 10.434967041016 -1, "cylinder", 1.3, 255, 255, 255, 100) MarkerRota1Mid = createMarker(-53.211204528809, 18.511032104492, 3.1171875 -1, "cylinder", 3, 255, 255, 255, 100) MarkerRota1Fim = createMarker(281.80587768555, 1432.7344970703, 10.5859375 -1, "cylinder", 3, 255, 255, 255, 100) MarkerRota2Mid = createMarker(1107.3701171875, 1934.5258789063, 10.8203125 -1, "cylinder", 3, 255, 255, 255, 100) MarkerRota2Fim = createMarker(281.80587768555, 1432.7344970703, 10.5859375 -1, "cylinder", 3, 255, 255, 255, 100) setElementVisibleTo(MarkerRota1Mid, root, false) setElementVisibleTo(MarkerRota1Fim, root, false) setElementVisibleTo(MarkerRota2Mid, root, false) setElementVisibleTo(MarkerRota2Fim, root, false) blipEmprego= createBlipAttachedTo(MarkerEmprego, 42) blipMidRota1 = createBlipAttachedTo(MarkerRota1Mid, 19) blipFimRota1 = createBlipAttachedTo(MarkerRota1Fim, 19) blipMidRota2 = createBlipAttachedTo(MarkerRota2Mid, 19) blipFimRota2 = createBlipAttachedTo(MarkerRota2Fim, 19) setElementVisibleTo(blipMidRota1, root, false) setElementVisibleTo(blipFimRota1, root, false) setElementVisibleTo(blipMidRota2, root, false) setElementVisibleTo(blipFimRota2, root, false) function kk (thePlayer) triggerClientEvent(thePlayer, "Abrepainel", thePlayer) triggerClientEvent(thePlayer, "Abrepainell", thePlayer) end addEventHandler("onMarkerHit", MarkerEmprego, kk) function inicio(player) if vehjob[player] and isElement(vehjob[player]) then destroyElement(vehjob[player]) vehjob[player] = nil end vehjob[player] = createVehicle(455, 299.37649536133, 1410.4169921875, 9.5720157623291) warpPedIntoVehicle(player, vehjob[player]) end addEventHandler("onMarkerHit", MarkerEmprego, inicio) function IniRotaUm (localPlayer) setElementVisibleTo(blipMidRota1, localPlayer, true) setElementVisibleTo(MarkerRota1Mid, localPlayer, true) end addEvent ("RotaUm", true) addEventHandler ("RotaUm", root, IniRotaUm) function mid(player) setElementVisibleTo(blipMidRota1, player, false) setElementVisibleTo(MarkerRota1Mid, player, false) setElementVisibleTo(blipFimRota1, player, true) setElementVisibleTo(MarkerRota1Fim, player, true) end addEventHandler("onMarkerHit", MarkerRota1Mid, mid) function fim(player) if vehjob[player] and isElement(vehjob[player]) then destroyElement(vehjob[player]) givePlayerMoney(player, Salario1) setElementVisibleTo(blipFimRota1, player, false) setElementVisibleTo(MarkerRota1Fim, player, false) end end addEventHandler("onMarkerHit", MarkerRota1Fim, fim) function cancelarjob(player) destroyElement(vehjob[player]) setElementVisibleTo(blipMidRota1, player, false) setElementVisibleTo(MarkerRota1Mid, player, false) end addCommandHandler("cancelar", cancelarjob) Edited November 22, 2020 by MenorTH Melhorando Organização Link to comment
Jonas^ Posted November 22, 2020 Share Posted November 22, 2020 Não existe localPlayer do lado servidor. function IniRotaUm (thePlayer) setElementVisibleTo(blipMidRota1, thePlayer, true) setElementVisibleTo(MarkerRota1Mid, thePlayer, true) end addEvent ("RotaUm", true) addEventHandler ("RotaUm", root, IniRotaUm) 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now