#RooTs Posted April 13, 2016 Share Posted April 13, 2016 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
MrDante Posted April 13, 2016 Share Posted April 13, 2016 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
#RooTs Posted April 14, 2016 Author Share Posted April 14, 2016 (edited) I could do with "createObject". more the camera was zuada, get close to more of my ped could someone explain me how to do it with "bone attachments" Edited April 14, 2016 by Guest Link to comment
Captain Cody Posted April 14, 2016 Share Posted April 14, 2016 -- Never mind did not notice last post -- use setElementCollisionsEnabled to make the camera ignore the vest. Link to comment
#RooTs Posted April 14, 2016 Author Share Posted April 14, 2016 how I could increase the size of the object? Bribe[player] = createObject(1242,x-2,y,z); setElementCollisionsEnabled(Bribe[player],false) attachElements (Bribe[player],player,-0.0,0.0,0.3) ; Link to comment
#RooTs Posted April 14, 2016 Author Share Posted April 14, 2016 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
Captain Cody Posted April 14, 2016 Share Posted April 14, 2016 setElementAlpha https://wiki.multitheftauto.com/wiki/Main_Page /\ Try searching there if you don't know the functions Link to comment
#RooTs Posted April 14, 2016 Author Share Posted April 14, 2016 /\ Try searching there if you don't know the functions you're funny? I am a while without programming. and so I end up forgetting something. bad that is no reason to mock the other boy right Link to comment
#RooTs Posted April 14, 2016 Author Share Posted April 14, 2016 not work. and not error in debug. how to make it go decreasing the transparency? local Armor = getPlayerArmor ( player ); setElementAlpha ( Bribe[player], 255/100*Armor ) Link to comment
Captain Cody Posted April 14, 2016 Share Posted April 14, 2016 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. Link to comment
#RooTs Posted April 14, 2016 Author Share Posted April 14, 2016 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
Simple0x47 Posted April 14, 2016 Share Posted April 14, 2016 You wanna get the % of the armour? If yes then use this: (Armor * 100) / 255 And the alpha obtained from the percentage: ( (Armor * 100) / 255 ) * 140 / 100 Link to comment
#RooTs Posted April 14, 2016 Author Share Posted April 14, 2016 this ? setElementAlpha ( Bribe[player], ( (Armor * 100) / 255 ) * 140 / 100 ) Link to comment
Simple0x47 Posted April 14, 2016 Share Posted April 14, 2016 this ? setElementAlpha ( Bribe[player], ( (Armor * 100) / 255 ) * 140 / 100 ) local value = ( ( Armor * 100 ) / 255 ) * 140 / 100 setElementAlpha ( Bribe[player], value) And it has to work Link to comment
#RooTs Posted April 14, 2016 Author Share Posted April 14, 2016 no work setObjectScale ( Bribe[player], 1.9 ) local value = ( ( Armor * 100 ) / 255 ) * 140 / 100 setElementAlpha ( Bribe[player], value ) Link to comment
Simple0x47 Posted April 14, 2016 Share Posted April 14, 2016 Try without "(" ")" local value = Armor*100/255*140/100 I tested it and it returns the good value. Maybe the error is with the script. Link to comment
#RooTs Posted April 14, 2016 Author Share Posted April 14, 2016 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
#RooTs Posted April 15, 2016 Author Share Posted April 15, 2016 I left without transparency it. Link to comment
TioTiago Posted April 18, 2016 Share Posted April 18, 2016 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
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