Sign in to follow this  
Lucas Henrique

getElementModel (Ajuda)

Recommended Posts

Galera esse é meu codigo de trabalho,  na function skins eu queria salvar a skin antes de pisar no marker pra pegar o trab  com o comando /salvarskin e quando sair do veiculo ou finalizar o trabalho, ele puxaria o modelo de skin anterior, o problema é que ele volta pro CJ sempre, alguem poderia me ajudar? 

Marker = createMarker (2193.9870605469, -1000.0881958008, 62.851928710938 -1, "cylinder", 2, 117 ,254 ,0, 255)
MarkerF = createMarker (2603.4150390625,-1918.1767578125,13.549844741821 -1, "cylinder", 2, 0 ,255 ,0, 255)

setElementVisibleTo ( MarkerF, root, false )

trab = createBlipAttachedTo ( Marker, 42 )
setElementVisibleTo ( Bfim, source, true )

Bfim = createBlipAttachedTo ( MarkerF, 19 )
setElementVisibleTo ( Bfim, root, false )

function skins (root)
local skinserv = getElementModel ( root, "skinp" )
outputChatBox ( "#ff00ffVocê salvou sua skin!",root,0,0,0,true )
end
addCommandHandler ( "salvarskin", skins )

veh = {}
function inicio (root)
if isElementWithinMarker(root, Marker) then
if veh[root] and isElement( veh[root] ) then destroyElement ( veh[root] )
veh[root] = nil
end
x,y,z = getElementPosition(root)
Trabalho = true
veh[root] = createVehicle(459,2192.45703125, -1007.572265625, 64.420482635498, 0, 0, 81.835632324219)
setPedSkin ( root, 280 )
setElementVisibleTo ( Bfim, root, true )
setElementVisibleTo ( MarkerF, root, true )
warpPedIntoVehicle ( root, veh[root] )
 outputChatBox ("#ff00ff-------------------------------------------------------------",root,0,0,0,true )
 outputChatBox ("#ffb200Você Pegou o Trabalho de Vendedor de Drogas,",root,0,0,0,true )
 outputChatBox ("#ffb200Leve as drogas, para os local indicado,",root,0,0,0,true )
 outputChatBox ("#ffb200A ser entregada, ganhara 8000R$",root,0,0,0,true )
 outputChatBox ("#ff00ff-------------------------------------------------------------",root,0,0,0,true )
end
end
addEventHandler( "onMarkerHit", Marker, inicio )

function fim (root)
if veh[root] and isElement(veh[root]) then
destroyElement (veh[root])
givePlayerMoney(root,8000)
setPedSkin ( root, "skinp", skinserv )
setElementVisibleTo ( Bfim, root, false )
setElementVisibleTo ( MarkerF, root, false )
outputChatBox ("#ff00ff-------------------------------------------------------------",root,0,0,0,true )
outputChatBox ("#ffb200Você Entregou todas as encomendas,",root,0,0,0,true)
outputChatBox ("#ffb200E Recebeu 8000R$ de Pagamento!",root,0,0,0,true)
outputChatBox ("#ff00ff-------------------------------------------------------------",root,0,0,0,true )
else
end
end
addEventHandler("onMarkerHit", MarkerF, fim)

function sair (root)
if (veh[root]) and isElement(veh[root]) then
setElementVisibleTo ( Bfim, root, false )
setElementVisibleTo ( MarkerF, root, false )
destroyElement (veh[root])
setPedSkin ( root, "skinp", skinserv )
outputChatBox ("#ffb200-------------------------------------------------------------",root,0,0,0,true )
outputChatBox ("#00ff00Voce perdeu seu trabalho, Pois saiu do carro!", root ,0,0,0,true)
outputChatBox ("#ffb200-------------------------------------------------------------",root,0,0,0,true )
else
end
end
addEventHandler ( "onVehicleExit", getRootElement(), sair )

 

Share this post


Link to post

Você definindo uma variável chamada "root", você está sobrescrevendo a variável de mesmo nome pre-definida pelo MTA que seria a raiz de todos elementos (LINK), impossibilitando seu uso caso necessite.

Marker = createMarker(2193.9870605469, -1000.0881958008, 62.851928710938 - 1, "cylinder", 2, 117, 254, 0, 255)
MarkerF = createMarker(2603.4150390625, -1918.1767578125, 13.549844741821 - 1, "cylinder", 2, 0, 255, 0, 255)

setElementVisibleTo(MarkerF, root, false)

trab = createBlipAttachedTo(Marker, 42)
setElementVisibleTo(Bfim, source, true)

Bfim = createBlipAttachedTo(MarkerF, 19)
setElementVisibleTo(Bfim, root, false)

veh = {}
skins = {}
function inicio(thePlayer)
    if isElementWithinMarker(thePlayer, Marker) then
        if veh[thePlayer] and isElement(veh[thePlayer]) then
            destroyElement(veh[thePlayer])
            veh[thePlayer] = nil
        end
        x, y, z = getElementPosition(thePlayer)
        Trabalho = true
        veh[thePlayer] = createVehicle(459, 2192.45703125, -1007.572265625, 64.420482635498, 0, 0, 81.835632324219)
        skins[thePlayer] = getElementModel(thePlayer)
        setPedSkin(thePlayer, 280)
        setElementVisibleTo(Bfim, thePlayer, true)
        setElementVisibleTo(MarkerF, thePlayer, true)
        warpPedIntoVehicle(thePlayer, veh[thePlayer])
        outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200Você Pegou o Trabalho de Vendedor de Drogas,", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200Leve as drogas, para os local indicado,", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200A ser entregada, ganhara 8000R$", thePlayer, 0, 0, 0, true)
        outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
    end
end
addEventHandler("onMarkerHit", Marker, inicio)

function fim(thePlayer)
    if veh[thePlayer] and isElement(veh[thePlayer]) then
        destroyElement(veh[thePlayer])
        givePlayerMoney(thePlayer, 8000)
        setPedSkin(thePlayer, "skinp", skins[thePlayer] or 0)
        setElementVisibleTo(Bfim, thePlayer, false)
        setElementVisibleTo(MarkerF, thePlayer, false)
        outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200Você Entregou todas as encomendas,", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200E Recebeu 8000R$ de Pagamento!", thePlayer, 0, 0, 0, true)
        outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
    else
    end
end
addEventHandler("onMarkerHit", MarkerF, fim)

function sair(thePlayer)
    if (veh[thePlayer]) and isElement(veh[thePlayer]) then
        setElementVisibleTo(Bfim, thePlayer, false)
        setElementVisibleTo(MarkerF, thePlayer, false)
        destroyElement(veh[thePlayer])
        setPedSkin(thePlayer, "skinp", skins[thePlayer] or 0)
        outputChatBox("#ffb200-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
        outputChatBox("#00ff00Voce perdeu seu trabalho, Pois saiu do carro!", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
    else
    end
end
addEventHandler("onVehicleExit", getRootElement(), sair)

addEventHandler("onPlayerQuit", root,
    function()
        if (veh[source]) and isElement(veh[source]) then
            destroyElement(veh[source])
            veh[source] = nil
        end
        if (skins[source]) then
            skins[source] = nil
        end
    end
)

 

Share this post


Link to post
18 minutes ago, [M]ister said:

Você definindo uma variável chamada "root", você está sobrescrevendo a variável de mesmo nome pre-definida pelo MTA que seria a raiz de todos elementos (LINK), impossibilitando seu uso caso necessite.


Marker = createMarker(2193.9870605469, -1000.0881958008, 62.851928710938 - 1, "cylinder", 2, 117, 254, 0, 255)
MarkerF = createMarker(2603.4150390625, -1918.1767578125, 13.549844741821 - 1, "cylinder", 2, 0, 255, 0, 255)

setElementVisibleTo(MarkerF, root, false)

trab = createBlipAttachedTo(Marker, 42)
setElementVisibleTo(Bfim, source, true)

Bfim = createBlipAttachedTo(MarkerF, 19)
setElementVisibleTo(Bfim, root, false)

veh = {}
skins = {}
function inicio(thePlayer)
    if isElementWithinMarker(thePlayer, Marker) then
        if veh[thePlayer] and isElement(veh[thePlayer]) then
            destroyElement(veh[thePlayer])
            veh[thePlayer] = nil
        end
        x, y, z = getElementPosition(thePlayer)
        Trabalho = true
        veh[thePlayer] = createVehicle(459, 2192.45703125, -1007.572265625, 64.420482635498, 0, 0, 81.835632324219)
        skins[thePlayer] = getElementModel(thePlayer)
        setPedSkin(thePlayer, 280)
        setElementVisibleTo(Bfim, thePlayer, true)
        setElementVisibleTo(MarkerF, thePlayer, true)
        warpPedIntoVehicle(thePlayer, veh[thePlayer])
        outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200Você Pegou o Trabalho de Vendedor de Drogas,", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200Leve as drogas, para os local indicado,", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200A ser entregada, ganhara 8000R$", thePlayer, 0, 0, 0, true)
        outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
    end
end
addEventHandler("onMarkerHit", Marker, inicio)

function fim(thePlayer)
    if veh[thePlayer] and isElement(veh[thePlayer]) then
        destroyElement(veh[thePlayer])
        givePlayerMoney(thePlayer, 8000)
        setPedSkin(thePlayer, "skinp", skins[thePlayer] or 0)
        setElementVisibleTo(Bfim, thePlayer, false)
        setElementVisibleTo(MarkerF, thePlayer, false)
        outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200Você Entregou todas as encomendas,", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200E Recebeu 8000R$ de Pagamento!", thePlayer, 0, 0, 0, true)
        outputChatBox("#ff00ff-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
    else
    end
end
addEventHandler("onMarkerHit", MarkerF, fim)

function sair(thePlayer)
    if (veh[thePlayer]) and isElement(veh[thePlayer]) then
        setElementVisibleTo(Bfim, thePlayer, false)
        setElementVisibleTo(MarkerF, thePlayer, false)
        destroyElement(veh[thePlayer])
        setPedSkin(thePlayer, "skinp", skins[thePlayer] or 0)
        outputChatBox("#ffb200-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
        outputChatBox("#00ff00Voce perdeu seu trabalho, Pois saiu do carro!", thePlayer, 0, 0, 0, true)
        outputChatBox("#ffb200-------------------------------------------------------------", thePlayer, 0, 0, 0, true)
    else
    end
end
addEventHandler("onVehicleExit", getRootElement(), sair)

addEventHandler("onPlayerQuit", root,
    function()
        if (veh[source]) and isElement(veh[source]) then
            destroyElement(veh[source])
            veh[source] = nil
        end
        if (skins[source]) then
            skins[source] = nil
        end
    end
)

 

Então, ele volta pro 0 ou seja o cj, não volta pro modelo anterior que puxamos na função inicio. Acabei arrumando isso tirando o "skinp" dentro do codigo SetPedSkin, vlw man pela ajuda :v

Edited by Lucas Henrique

Share this post


Link to post

Troca setPedSkin por setElementModel

  • Like 1

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.