hipolitalakaj Posted January 16, 2019 Author Share Posted January 16, 2019 Thanks again! You're really helped me a lot. I did the animation thing. It's possible to change the onclientkey press to hold? because the current state I can't fire and aim with the weapon constant... Link to comment
Dimos7 Posted January 16, 2019 Share Posted January 16, 2019 7 minutes ago, hipolitalakaj said: Thanks again! You're really helped me a lot. I did the animation thing. It's possible to change the onclientkey press to hold? because the current state I can't fire and aim with the weapon constant... Post the code so we help you Link to comment
hipolitalakaj Posted January 16, 2019 Author Share Posted January 16, 2019 addEventHandler("onClientKey", root, function(button, press) if button =="mouse1" and press or button =="lalt" and press or button =="lctrl" and press or $ setPedAnimation(localPlayer, "rifle", "RIFLE_fire", -1, false, false, false, false) fireWeapon(weapon) setWeaponState(weapon, "firing") else setWeaponState(weapon, "ready") end if button =="mouse2" and press then if getControlState (localPlayer, "crouch") then setPedAnimation(localPlayer, "rifle", "RIFLE_crouchfire", -1, false, false, false, false) else setPedAnimation(localPlayer, "rifle", "RIFLE_fire", -1, false, false, false, false) setPedAimTarget(localPlayer, x, y, z) end end end) anyways, the getcontrolstate not working or bugging if it is crouch? because then ignore the animation but if I change to jump or walk it's working... Link to comment
Dimos7 Posted January 17, 2019 Share Posted January 17, 2019 (edited) addEventHandler("onClientKey", root, function(button, press) if button =="mouse1" and press or button =="lalt" and press or button =="lctrl" and press then setPedAnimation(localPlayer, "rifle", "rifle_fire", -1, false, false, false, false) fireWeapon(weapon) setWeaponState(weapon, "firing") else setWeaponState(weapon, "ready") end if button =="mouse2" and press then if button == "mouse2" and press and getControlState (localPlayer, "crouch") then setPedAnimation(localPlayer, "rifle", "rifle_crouchfire", -1, false, false, false, false) end setPedAnimation(localPlayer, "rifle", "rifle_fire", -1, false, false, false, false) end else setPedAnimation(localPlayer, false) end if button =="mouse2" and press and button =="mouse1" and press then fireWeapon(weapon) setWeaponState(weapon, "firing") setPedAnimation(localPlayer, "rifle", "rifle_fire", - 1,false, false, false, false) else setPedAnimation(localPlayer, false) setWeaponState(weapon, "ready") end if button == "mouse1" and press and button =="mouse2" and press and getControlState(localPlayer, "crouch") then fireWeapon(weapon) setWeaponState(weapon, "firing") setPedAnimation(localPlayer, "rifle", "rifle_crouchfire", - 1, false, false, false, false, false) else setPedAnimation(localPlayer, false) setWeaponState(weapon, "ready") end end end) Try this Edited January 17, 2019 by Dimos7 Link to comment
hipolitalakaj Posted January 17, 2019 Author Share Posted January 17, 2019 You're forgot to close function at line 15 but I didn't get it where... Loading script failed: aktest\client,lua:29: 'end' expected (to close 'function' at line 15) near 'else' function test() x,y,z = getElementPosition(localPlayer) weapon = createWeapon("ak-47", x, y, z) setWeaponAmmo(weapon, 1) setWeaponClipAmmo(weapon, 32) setWeaponState(weapon, "ready") setElementAlpha(weapon, 0) local newAK = createObject(2965, x, y, z) attachElements(weapon, newAK) exports['bone_attach']:attachElementToBone(newAK, localPlayer, 12, 0, 0, 0, 0, -90, 0) end addCommandHandler("aktest", test) addEventHandler("onClientKey", root, function(button, press) if button =="mouse1" and press or button =="lalt" and press or button =="lctrl" and press then setPedAnimation(localPlayer, "rifle", "rifle_fire", -1, false, false, false, false) fireWeapon(weapon) setWeaponState(weapon, "firing") else setWeaponState(weapon, "ready") end if button =="mouse2" and press then if button == "mouse2" and press and getControlState (localPlayer, "crouch") then setPedAnimation(localPlayer, "rifle", "rifle_crouchfire", -1, false, false, false, false) end setPedAnimation(localPlayer, "rifle", "rifle_fire", -1, false, false, false, false) end else setPedAnimation(localPlayer, false) end if button =="mouse2" and press and button =="mouse1" and press then fireWeapon(weapon) setWeaponState(weapon, "firing") setPedAnimation(localPlayer, "rifle", "rifle_fire", - 1,false, false, false, false) else setPedAnimation(localPlayer, false) setWeaponState(weapon, "ready") end if button == "mouse1" and press and button =="mouse2" and press and getControlState(localPlayer, "crouch") then fireWeapon(weapon) setWeaponState(weapon, "firing") setPedAnimation(localPlayer, "rifle", "rifle_crouchfire", - 1, false, false, false, false, false) else setPedAnimation(localPlayer, false) setWeaponState(weapon, "ready") end end end) addEventHandler("onClientWeaponFire" , root, function(hitElement, hitX, hitY, hitZ) setPedAimTarget(localPlayer, hitX, hitY, hitZ) end ) Link to comment
Dimos7 Posted January 17, 2019 Share Posted January 17, 2019 function test() x,y,z = getElementPosition(localPlayer) weapon = createWeapon("ak-47", x, y, z) setWeaponAmmo(weapon, 1) setWeaponClipAmmo(weapon, 32) setWeaponState(weapon, "ready") setElementAlpha(weapon, 0) local newAK = createObject(2965, x, y, z) attachElements(weapon, newAK) exports['bone_attach']:attachElementToBone(newAK, localPlayer, 12, 0, 0, 0, 0, -90, 0) end addCommandHandler("aktest", test) addEventHandler("onClientKey", root, function(button, press) if button =="mouse1" and press or button =="lalt" and press or button =="lctrl" and press then setPedAnimation(localPlayer, "rifle", "rifle_fire", -1, false, false, false, false) fireWeapon(weapon) setWeaponState(weapon, "firing") else setPedAnimation(localPlayer, false) setWeaponState(weapon, "ready") end if button =="mouse2" and press then if button == "mouse2" and press and getControlState (localPlayer, "crouch") then setPedAnimation(localPlayer, "rifle", "rifle_crouchfire", -1, false, false, false, false) else setPedAnimation(localPlayer, false) end setPedAnimation(localPlayer, "rifle", "rifle_fire", -1, false, false, false, false) else setPedAnimation(localPlayer, false) end if button =="mouse2" and press and button =="mouse1" and press then fireWeapon(weapon) setWeaponState(weapon, "firing") setPedAnimation(localPlayer, "rifle", "rifle_fire", - 1,false, false, false, false) else setPedAnimation(localPlayer, false) setWeaponState(weapon, "ready") end if button == "mouse1" and press and button =="mouse2" and press and getControlState(localPlayer, "crouch") then fireWeapon(weapon) setWeaponState(weapon, "firing") setPedAnimation(localPlayer, "rifle", "rifle_crouchfire", - 1, false, false, false, false, false) else setPedAnimation(localPlayer, false) setWeaponState(weapon, "ready") end end end) addEventHandler("onClientWeaponFire" , root, function(hitElement, hitX, hitY, hitZ) setPedAimTarget(localPlayer, hitX, hitY, hitZ) end ) Link to comment
hipolitalakaj Posted January 17, 2019 Author Share Posted January 17, 2019 Loading script failed: aktest/client.lua:51: ')' expected (to close '(' at line 15) near 'end' What? I don't see opened ( and the eventhandler closed already at the line 51 end) Link to comment
Zorgman Posted January 17, 2019 Share Posted January 17, 2019 Line 34: if button=="mouse2" and press and button =="mouse1" and press then This will never work, "button" cannot be both mouse2 and mouse1 at the same time. Link to comment
hipolitalakaj Posted January 17, 2019 Author Share Posted January 17, 2019 Ah, I see. And why I get this error: Loading script failed: aktest/client.lua:51: ')' expected (to close '(' at line 15) near 'end' if I doesn't have opened line and the 'addeventhandler' get closed at line 51 after end? Link to comment
AlexRazor Posted January 17, 2019 Share Posted January 17, 2019 You can make it a lot easier. Just make original weapon invisible(by editing txd) and then or attach object or attach weapon. Link to comment
hipolitalakaj Posted January 17, 2019 Author Share Posted January 17, 2019 9 minutes ago, Dimos7 said: yes What yes? I said I doesn't have opened line but the debugscript says that "Loading script failed: aktest/client.lua:51: ')' expected (to close '(' at line 15) near 'end'" 1 minute ago, AlexRazor said: You can make it a lot easier. Just make original weapon invisible(by editing txd) and then or attach object or attach weapon. But I want to keep the original AK-47 too. Link to comment
Zorgman Posted January 17, 2019 Share Posted January 17, 2019 (edited) You can add the original AK skin just like you add the custom new one. Edited January 17, 2019 by Zorgman 1 Link to comment
hipolitalakaj Posted January 17, 2019 Author Share Posted January 17, 2019 Yeah , but I can't do it for localplayer only in that way... because if someone uses eg.: camo ak-47 from their inventory then all other players who have ak-47 (id 30) seen camo ak I did research about custom weapons example before I posted this, but found nothing custom weapons with txd and dff.. just with shaders (with png files) which are ugly. Link to comment
Dimos7 Posted January 17, 2019 Share Posted January 17, 2019 (edited) function test() x,y,z = getElementPosition(localPlayer) weapon = createWeapon("ak-47", x, y, z) setWeaponAmmo(weapon, 1) setWeaponClipAmmo(weapon, 32) setWeaponState(weapon, "ready") setElementAlpha(weapon, 0) local newAK = createObject(2965, x, y, z) attachElements(weapon, newAK) exports['bone_attach']:attachElementToBone(newAK, localPlayer, 12, 0, 0, 0, 0, -90, 0) end addCommandHandler("aktest", test) addEventHandler("onClientKey", root, function(button, press) if button =="mouse1" and press or button =="lalt" and press or button =="lctrl" and press then setPedAnimation(localPlayer, "rifle", "rifle_fire", -1, false, true, false, false) fireWeapon(weapon) setWeaponState(weapon, "firing") else setPedAnimation(localPlayer, false) setWeaponState(weapon, "ready") end if button =="mouse2" and press then if button == "mouse2" and press and getControlState (localPlayer, "crouch") then setPedAnimation(localPlayer, "rifle", "rifle_crouchfire", -1, false, true, false, false) else setPedAnimation(localPlayer, false) end setPedAnimation(localPlayer, "rifle", "rifle_fire", -1, false, true, false, false) else setPedAnimation(localPlayer, false) end end ) addEventHandler("onClientWeaponFire" , root, function(hitElement, hitX, hitY, hitZ) setPedAimTarget(localPlayer, hitX, hitY, hitZ) end ) Edited January 17, 2019 by Dimos7 Link to comment
hipolitalakaj Posted January 17, 2019 Author Share Posted January 17, 2019 My character still "boxing" the air I think it's because the equiped weapon is meele (0) and I need to set the equipped weapon to ID 5 which is rifle, right? https://wiki.multitheftauto.com/wiki/SetPedWeaponSlot I trying to change the weaponslot to ID 5 , but it isn't working... the getpedweaponslot returns 0 in the chatbox after I run the command. setPedWeaponSlot(localPlayer, 5) And the "rifle_crouchfire" anim still not working if the state is crouch. Link to comment
Dimos7 Posted January 17, 2019 Share Posted January 17, 2019 For that work you need do giveWeapon function Link to comment
hipolitalakaj Posted January 17, 2019 Author Share Posted January 17, 2019 Oh, I see. Then which function can I do it? Because currently my character is boxing the air if I click mouse 1... Link to comment
AlexRazor Posted January 17, 2019 Share Posted January 17, 2019 4 hours ago, hipolitalakaj said: What yes? I said I doesn't have opened line but the debugscript says that "Loading script failed: aktest/client.lua:51: ')' expected (to close '(' at line 15) near 'end'" But I want to keep the original AK-47 too. You can add original ak as custom weapon. You replace objects with weapon skins and attach them to your hand. Link to comment
hipolitalakaj Posted January 17, 2019 Author Share Posted January 17, 2019 And how can I do it that replace the weapon only for the localplayer who using the eg.: camo ak? because if I make the original ak inivisble and replace with the custom then changes the skin for everyone not just for localplayer who using the custom ak. isn't it? (eh my english is s.cks but hope u understand what I mean) Link to comment
AlexRazor Posted January 17, 2019 Share Posted January 17, 2019 (edited) 6 minutes ago, hipolitalakaj said: And how can I do it that replace the weapon only for the localplayer who using the eg.: camo ak? because if I make the original ak inivisble and replace with the custom then changes the skin for everyone not just for localplayer who using the custom ak. isn't it? (eh my english is s.cks but hope u understand what I mean) You should replace original AK model with invisible model and replace any usable object model with model of camo AK. Then you give player weapon(with invisible model) and attach camo AK model to his hand while he uses AK. Edited January 17, 2019 by AlexRazor Link to comment
hipolitalakaj Posted January 17, 2019 Author Share Posted January 17, 2019 (edited) It's okay but if I give ak to the player (I need to provide the default AK id 30) and the weapon ID 30 model ID is 355.. so if I do the "engineImportTXD" , "engineReplaceModel" I need to provide the 355 Model ID for every custom skin.. or can I give example weapon ID 30 with any usable object ID (2965) instead of 355 model ID? Edited January 17, 2019 by hipolitalakaj Link to comment
AlexRazor Posted January 17, 2019 Share Posted January 17, 2019 (edited) 11 minutes ago, hipolitalakaj said: It's okay but if I give ak to the player (I need to provide the default AK id 30) and the weapon ID 30 model ID is 355.. so if I do the "engineImportTXD" , "engineReplaceModel" I need to provide the 355 Model ID every custom skin.. or can I give example weapon ID 30 with any usable object ID (2965) instead of 355 model ID? Didn't quite understand you. First you replace original 355 model with invisible model. Then you replace 2965(for example) model with AK model. Then you replace 2966(for example) model with AK CAMO model. When you want to give someone weapon you do giveWeapon(30) then createObject with model object ID of weapon of choice(2965 normal ak OR 2966 camo) and then attach thath object to player hand. Edited January 17, 2019 by AlexRazor Link to comment
hipolitalakaj Posted January 17, 2019 Author Share Posted January 17, 2019 Ah okay, I will try it. Thanks for your help. Link to comment
hipolitalakaj Posted January 17, 2019 Author Share Posted January 17, 2019 Now I'm stuck in the invisible model part... can't make it with txd workshop, I already tried to change the texture to white/black image and untick the alpha in properties but isn't be invisible... anyone have an insivible model please? 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