Jump to content

Armor and object


#RooTs

Recommended Posts

Hello friends. I'm trying to make show the vest, "object" while I'm of armor ... and then I'm losing armor the object gets transparent.

I have no idea how to do, and what to use. what would be the best choice function? "createObject" or "bone attachments"

https://community.multitheftauto.com/index.php?p ... ls&id=2540

My thought was that

function getArmour() 
    local amour = getPlayerArmor(source) 
    if amour >= 100 then 
        x, y, z = getElementPosition(source) 
        Obj = createObject(ID, x, y, z, 0, 0, 0) -- set transparency in the object 
        attachElements(source. Obj) 
    end 
end 
setTimer(getArmour, 1500, source) 

sorry my english

Link to comment
Hello friends. I'm trying to make show the vest, "object" while I'm of armor ... and then I'm losing armor the object gets transparent.

I have no idea how to do, and what to use. what would be the best choice function? "createObject" or "bone attachments"

https://community.multitheftauto.com/index.php?p ... ls&id=2540

My thought was that

function getArmour() 
    local amour = getPlayerArmor(source) 
    if amour >= 100 then 
        x, y, z = getElementPosition(source) 
        Obj = createObject(ID, x, y, z, 0, 0, 0) -- to set transparency in the object 
        attachElements(source. Obj) 
    end 
end 
  
setTimer(getArmour, 1500, source) 

attachElement(source. Obj), and this point in this function? It would not be a comma?

and this ID? Where's the object ID?

Link to comment
setObjectScale

thanks. how to add transparency to the object?

example

Armor = getPlayerArmor ( player ) 
( 255*Armor ) 

Bribe[player] = createObject(1242,x,y-8,z); 
setObjectScale ( Bribe[player], 1.9 ) 
setElementCollisionsEnabled(Bribe[player],false) 
exports.bone_attach:attachElementToBone(Bribe[player],player,3,0,0,0,3,-5,0) 

Link to comment
I'm sorry I didn't try to mock you.. I was just giving you advice.

Any ways -

Note: Objects are fully transparent at 140.

So you wanna find a way to make it factor in the amount of armour while keeping that in mind.

how could I do this calculation? . I've tried several ways. but I did not succeed.

"140*Armor "

"140/Armor "

"140+Armor "

"255/100*Armor"

Link to comment

not work

                setObjectScale ( Bribe[player], 1.9 ) 
                local value = getPlayerArmor(player)*100/255*140/100 
                setElementAlpha ( Bribe[player], value ) 
                setElementCollisionsEnabled(Bribe[player],false) 

Link to comment

if you use the resource bone_attach:

elementVest = {} 
function getArmour() 
    local amour = getPlayerArmor(source) 
    if amour > 0 then 
        x,y,z = getElementPosition(source) 
        if not isElement(elementVest[source]) then 
            exports.bone_attach:detachElementFromBone(elementVest[source]) 
            destroyElement(elementVest[source]) 
            elementVest[source] = false 
        end 
        elementVest[source] = createObject(1598,x,y,z) 
        exports.bone_attach:attachElementToBone(elementVest[source],source,3,0,0.02,-0.53,-3,0,90,1) 
    else 
        if elementVest[source] and isElement(elementVest[source]) then 
            exports.bone_attach:detachElementFromBone(elementVest[source]) 
            destroyElement(elementVest[source]) 
            elementVest[source] = false 
        end 
    end 
end 
setTimer(getArmour,1500,source) 

instead of SetTimer could use:

addEventHandler("onPlayerDamage",getRootElement(),getArmour) 

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...