ItachiUchiha Posted February 17, 2016 Share Posted February 17, 2016 Hi! I'm a new fag on this, I barely could build this script to make that the car have weapons mounted (like Twisted Metal cars): local weapon = createWeapon("ak47", 0, 0, 1 ) local weapon2 = createWeapon("ak47", 0, 0, 1 ) setElementAlpha ( weapon, 0) setElementAlpha ( weapon2, 0) local weaponINV = createWeapon("ak47", 0, 0, 1 ) local weapon2INV = createWeapon("ak47", 0, 0, 1 ) function createAndFire() local theVehicle = getPedOccupiedVehicle ( localPlayer ) if theVehicle then local x,y,z = getElementPosition ( theVehicle ) local rX,rY,rZ = getElementRotation(theVehicle) attachElements ( weapon, theVehicle, 1, 2, 0, 0, 0, 90 ) attachElements ( weapon2, theVehicle, -1, 2, 0, 0, 0, 90 ) attachElements ( weaponINV, theVehicle, 1, 2, 0, 0, 0, 95 ) attachElements ( weapon2INV, theVehicle, -1, 2, 0, 0, 0, 95 ) fireWeapon(weapon) fireWeapon(weapon2) end end bindKey("mouse2", "down", createAndFire) addEventHandler("onClientResourceStart", resourceRoot, createAndFire) This works good. But now I wanted to know how to make it works with other players. I mean, I tested it with my friend and when I shoot him he don't get damage, and he can't see my weapons on the car too, and I either. Link to comment
bebo1king Posted February 17, 2016 Share Posted February 17, 2016 Because it Client Side Your should make it for Server side Link to comment
ItachiUchiha Posted February 17, 2016 Author Share Posted February 17, 2016 Because it Client SideYour should make it for Server side how can i make it? or what I have to change? and I have to change whole script? Link to comment
Yazir Posted February 17, 2016 Share Posted February 17, 2016 Copy that to server file and use some player trigger https://wiki.multitheftauto.com/wiki/Cl ... yer_events . You can also make clientside script to send a message that your character shoots, or even better, when he starts and stops shooting. Link to comment
Dimos7 Posted February 17, 2016 Share Posted February 17, 2016 addEventHandler("onPlayerLogin", root function() bindKey(source, "mouse2", "down", createAndFire) end ) addEventHandler("onResourceStart", resourceRoot, function() for _, v in ipairs(getElementsByType("player")) do bindKey(v, "mouse2", "down", createAndFire) end end ) local weapon = createWeapon("ak47", 0, 0, 1 ) local weapon2 = createWeapon("ak47", 0, 0, 1 ) setElementAlpha ( weapon, 0) setElementAlpha ( weapon2, 0) local weaponINV = createWeapon("ak47", 0, 0, 1 ) local weapon2INV = createWeapon("ak47", 0, 0, 1 ) function createAndFire(thePlayer) local theVehicle = getPedOccupiedVehicle (thePlayer ) if theVehicle then local x,y,z = getElementPosition ( theVehicle ) local rX,rY,rZ = getElementRotation(theVehicle) attachElements ( weapon, theVehicle, 1, 2, 0, 0, 0, 90 ) attachElements ( weapon2, theVehicle, -1, 2, 0, 0, 0, 90 ) attachElements ( weaponINV, theVehicle, 1, 2, 0, 0, 0, 95 ) attachElements ( weapon2INV, theVehicle, -1, 2, 0, 0, 0, 95 ) fireWeapon(weapon) fireWeapon(weapon2) end end addEventHandler("onResourceStart", resourceRoot, createAndFire) Link to comment
ItachiUchiha Posted February 17, 2016 Author Share Posted February 17, 2016 addEventHandler("onPlayerLogin", root function() bindKey(source, "mouse2", "down", createAndFire) end ) addEventHandler("onResourceStart", resourceRoot, function() for _, v in ipairs(getElementsByType("player")) do bindKey(v, "mouse2", "down", createAndFire) end end ) local weapon = createWeapon("ak47", 0, 0, 1 ) local weapon2 = createWeapon("ak47", 0, 0, 1 ) setElementAlpha ( weapon, 0) setElementAlpha ( weapon2, 0) local weaponINV = createWeapon("ak47", 0, 0, 1 ) local weapon2INV = createWeapon("ak47", 0, 0, 1 ) function createAndFire(thePlayer) local theVehicle = getPedOccupiedVehicle (thePlayer ) if theVehicle then local x,y,z = getElementPosition ( theVehicle ) local rX,rY,rZ = getElementRotation(theVehicle) attachElements ( weapon, theVehicle, 1, 2, 0, 0, 0, 90 ) attachElements ( weapon2, theVehicle, -1, 2, 0, 0, 0, 90 ) attachElements ( weaponINV, theVehicle, 1, 2, 0, 0, 0, 95 ) attachElements ( weapon2INV, theVehicle, -1, 2, 0, 0, 0, 95 ) fireWeapon(weapon) fireWeapon(weapon2) end end addEventHandler("onResourceStart", resourceRoot, createAndFire) Didn't work, using this i can't see the weapons and don't fire too Link to comment
Bonus Posted February 17, 2016 Share Posted February 17, 2016 You should really read the MTA Wiki: https://wiki.multitheftauto.com/wiki/CreateWeapon or atleast use the debugscript ... Link to comment
ItachiUchiha Posted February 17, 2016 Author Share Posted February 17, 2016 You should really read the MTA Wiki:https://wiki.multitheftauto.com/wiki/CreateWeapon or atleast use the debugscript ... Sure, I did it. The problem is that I don't know LUA, I build that script using common sense and google, I wasted a lot of time doing that and reading old posts from this forum in order to make it works. Then if you can say me where is my exact error and you can help me with this I will really appreciate it. 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