Jump to content

Problema com plotagem


Recommended Posts

Tenho um script de plotagem que enquanto o player ta no servidor funciona normalmente, porem depois que ele reconecta no servidor perde a plotagem, tentei usar um laço for para setar a mesma plotagem para todos os veiculo (somente para teste) porem não obtive resultados, somente quando a plotagem já tinha sido colocada antes do reconnect

 


-- Lado Servidor

addEvent("AddShaderToAllPlayer", true)
addEventHandler("AddShaderToAllPlayer", root, function(vehicle, shader)
    triggerClientEvent(source, "AddShaderToAllPlayer", source, vehicle, shader)
end)

local markersPostos = {
    {city = "LS-1", x = 2750.817, y = -965.806, z = 59.815 -1, style = "cylinder", font = 1.5, r = 255, g = 165, b = 0, opaccity = 170}, -- ONDE O MARKER SERA CRIADO
}

function createBlipBuyVtr()
	for i,v in ipairs(markersPostos) do
		local m = createMarker(v.x, v.y, v.z, v.style, v.font, v.r, v.g, v.b, v.opaccity)
		addEventHandler("onMarkerHit", m, criarVeh)
	end
end
addEventHandler("onResourceStart", root, createBlipBuyVtr)

local vtrs = {
    ["pcerj"] = {aclGroup = "PC", skinName = "PCERJ"},
    ["bope"] = {aclGroup = "BOPE", skinName = "BOPE"},
    ["core"] = {aclGroup = "Staff", skinName = "CORE"},
    ["pmerj"] = {aclGroup = "PMERJ", skinName = "PMERJ"},
    -- ["teste"] = {aclGroup = "pcerj", skinName = "ft"}, -- EXEMPLO <
} -- TABELA COM AS INFORMACOES DO NOME DO GRUPO E NOME DA SKIN. PARA ADICIONAR, BASTA COPIAR E COLAR A ULTIMA LINHA E MUDAR OS NOMES QUE ESTAO DENTRO DAS ASPAS ("")

local veh = {}
function criarVeh(player)
    if getElementType(player) == "player" then
        if isPedInVehicle(player) == false then 
            if veh[player] == nil then
                local accName = getAccountName(getPlayerAccount(player))
                local x, y, z = getElementPosition(player)

                if (isObjectInACLGroup("user." .. accName, aclGetGroup(vtrs["bope"].aclGroup))) or (isObjectInACLGroup("user." .. accName, aclGetGroup(vtrs["core"].aclGroup))) or (isObjectInACLGroup("user." .. accName, aclGetGroup(vtrs["pmerj"].aclGroup))) or (isObjectInACLGroup("user." .. accName, aclGetGroup(vtrs["pcerj"].aclGroup))) then
                    veh[player] = createVehicle(598, x, y, z, 0, 0, 180) -- POSICAO ONDE O CARRO VAI SPAWNAR
                    warpPedIntoVehicle(player, veh[player]) -- VAI MOVER O PLAYER PARA DENTRO DO CARRO
                end
            end
        end 
    end
end

function verifyGroupAcl(player, cmd, skinName) -- FUNCAO QUE VERIFICA E SETA A SKIN CASO O PLAYER TENHA PERMISSAO
    local accName = getAccountName(getPlayerAccount(player)) -- PEGA O NOME DA CONTA DO PLAYER
    local vehicle = getPedOccupiedVehicle(player) -- PEGA O VEICULO QUE O PLAYER ESTA DENTRO
    actualSkin = skinName .. ".png" -- A VARIAVEL actualSkin TERA O VALOR DE NOME-SKIN.PNG

    if not(getElementData(vehicle, "Shader:Vehicle") == actualSkin) then -- VERIFICA SE A ULTIMA SKIN USADA EH DIFERENTE DA OPCAO SOLICITADA ATUAL
        if (isObjectInACLGroup("user." .. accName, aclGetGroup(vtrs["bope"].aclGroup)) and skinName == vtrs["bope"].skinName) then -- bope
            setElementData(vehicle, "Shader:Vehicle", vtrs["bope"].skinName .. ".png") -- ATUALIZA NO GETELEMENTDATA QUAL A SKIN QUE ESTA SENDO UTILIZADA PELO PLAYER
            triggerClientEvent(player, "onPlayerGetAclName", player, actualSkin) -- CHAMA O EVENTO QUE VAI TROCAR A SKIN, PASSANDO O NOME DA SKIN
        elseif (isObjectInACLGroup("user." .. accName, aclGetGroup(vtrs["core"].aclGroup)) and skinName == vtrs["core"].skinName) then -- core
            setElementData(vehicle, "Shader:Vehicle", vtrs["core"].skinName .. ".png") -- ATUALIZA NO GETELEMENTDATA QUAL A SKIN QUE ESTA SENDO UTILIZADA PELO PLAYER
            triggerClientEvent(player, "onPlayerGetAclName", player, actualSkin) -- CHAMA O EVENTO QUE VAI TROCAR A SKIN, PASSANDO O NOME DA SKIN
        elseif (isObjectInACLGroup("user." .. accName, aclGetGroup(vtrs["pmerj"].aclGroup)) and skinName == vtrs["pmerj"].skinName) then -- pcerj
            setElementData(vehicle, "Shader:Vehicle", vtrs["pmerj"].skinName .. ".png") -- ATUALIZA NO GETELEMENTDATA QUAL A SKIN QUE ESTA SENDO UTILIZADA PELO PLAYER
            triggerClientEvent(player, "onPlayerGetAclName", player, actualSkin) -- CHAMA O EVENTO QUE VAI TROCAR A SKIN, PASSANDO O NOME DA SKIN
         elseif (isObjectInACLGroup("user." .. accName, aclGetGroup(vtrs["pcerj"].aclGroup)) and skinName == vtrs["pcerj"].skinName) then -- EXEMPLO PARA CRIACAO DE OUTROS CARROS
             setElementData(vehicle, "Shader:Vehicle", vtrs["pcerj"].skinName .. ".png") 
             triggerClientEvent(player, "onPlayerGetAclName", player, actualSkin)
        else
            outputChatBox("Você não tem autorização para usar essa skin.", player, 255, 255, 255, true) -- CASO ELE NAO TENHA PERMISSAO PARA TROCAR A SKIN DA VTR
        end
    end
end
addCommandHandler("vtr", verifyGroupAcl) -- COMANDO PARA MUDAR A SKIN DA VTR /vtr [nome-skin]

addCommandHandler("coremoura",
    function (player)
        local vehicle = getPedOccupiedVehicle(player)
        setElementData(vehicle, "Shader:Vehicle", "CORE.png")
    end
)

addCommandHandler("pcmoura",
    function (player)
        local vehicle = getPedOccupiedVehicle(player)
        setElementData(vehicle, "Shader:Vehicle", "PCERJ.png")
    end
)



addCommandHandler("bopemoura",
    function (player)
        local vehicle = getPedOccupiedVehicle(player)
        setElementData(vehicle, "Shader:Vehicle", "BOPE.png")
    end
)



addCommandHandler("choquemoura",
    function (player)
        local vehicle = getPedOccupiedVehicle(player)
        setElementData(vehicle, "Shader:Vehicle", "chq.png")
    end
)



addCommandHandler("coemoura",
    function (player)
        local vehicle = getPedOccupiedVehicle(player)
        setElementData(vehicle, "Shader:Vehicle", "coe.png")
    end
)



addCommandHandler("ftmoura",
    function (player)
        local vehicle = getPedOccupiedVehicle(player)
        setElementData(vehicle, "Shader:Vehicle", "ft.png")
    end
)



addCommandHandler("pmerjmoura",
    function (player)
        local vehicle = getPedOccupiedVehicle(player)
        setElementData(vehicle, "Shader:Vehicle", "PMERJ.png")
    end
)



addCommandHandler("rotamoura",
    function (player)
        local vehicle = getPedOccupiedVehicle(player)
        setElementData(vehicle, "Shader:Vehicle", "rota.png")
    end
)



addCommandHandler("tormoura",
    function (player)
        local vehicle = getPedOccupiedVehicle(player)
        setElementData(vehicle, "Shader:Vehicle", "tor.png")
    end
)  



addCommandHandler("tor2moura",
    function (player)
        local vehicle = getPedOccupiedVehicle(player)
        setElementData(vehicle, "Shader:Vehicle", "tor2.png")
    end
)




addCommandHandler("getpmoura",
    function(player)
        local x, y, z = getElementPosition(player)
        outputChatBox(x .. ", " .. y .. ", " .. z)
    end
)

function carregarVehLogin(_)
    for i, veh in ipairs(getElementsByType("vehicle")) do
        setElementData(veh, "Shader:Vehicle", "BOPE.png") -- VAI ATUALIZAR O NOME DA SKIN DENTRO DO getElementData
    end
    outputDebugString ( "Iniciado o shader" )
end
addCommandHandler("vhs", carregarVehLogin) -- Comando para testar

--

-- Client

txd = engineLoadTXD ( "base.txd" )
engineImportTXD ( txd, 598 )
dff = engineLoadDFF ( "base.dff" )
engineReplaceModel ( dff, 598 )

addEvent("onPlayerGetAclName", true) -- CRIACAO DO EVENTO onPlayerGetACLName que e chamado no arquivo shader_s.lua
addEventHandler("onPlayerGetAclName", root, -- DECLARACAO DO EVENTO EM FORMA DE FUNCAO ANONIMA
    function (skinName) -- A FUNCAO VAI RECEBER O NOME DA SKIN
        theTechnique = dxCreateShader( "shader.fx" ) -- VAI CARREGAR O ARQUIVO COM O SHADER
        local vehicle = getPedOccupiedVehicle(localPlayer) -- VAI PEGAR O VEICULO QUE O PLAYER ESTIVER DENTRO
        setElementData(vehicle, "Shader:Vehicle", skinName) -- VAI ATUALIZAR O NOME DA SKIN DENTRO DO getElementData
    end
)


addEventHandler("onClientElementDataChange", root, function(key, old, new)
    if key == "Shader:Vehicle" then
        theTechnique = dxCreateShader( "shader.fx" )


        terrain = dxCreateTexture(new)
        dxSetShaderValue(theTechnique, "gTexture", terrain)
        engineApplyShaderToWorldTexture(theTechnique, "MisticStore", source)
        engineApplyShaderToWorldTexture(theTechnique, "?emap*", source)
    end
end)

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...