mox.workz Posted April 10, 2015 Share Posted April 10, 2015 Hey guyz! I need all your expertise again., I just happened to download a Batpod Bike., and Yeah! it's cool! and i want it to be more cooler., I wonder and wishing that there's a way that I could make it Fire/Shoots Bullets 'coz it has guns it in., Link to comment
Ryancit2 Posted April 10, 2015 Share Posted April 10, 2015 Batpod bike? Can you tell us some more details? And you can attach elements to vehicles by MTA's functions: attachElements And fire that element (weapon in this case) onClientKey event. Link to comment
mox.workz Posted April 10, 2015 Author Share Posted April 10, 2015 HELP!!!" local screenW,screenH = guiGetScreenSize() local weapon1 local weapon2 function attach ( ) local theVehicle = getPedOccupiedVehicle ( localPlayer ) if theVehicle then local x,y,z = getElementPosition ( theVehicle ) weapon1 = createWeapon("minigun", x, y, z + 1) weapon2 = createWeapon("minigun", x, y, z + 1) attachElements ( weapon1, theVehicle, 0, 0, 0 ) attachElements ( weapon2, theVehicle, 0, 1, 0 ) setWeaponClipAmmo(weapon1, 99999) setWeaponClipAmmo(weapon2, 99999) setWeaponState(weapon1, "firing") setWeaponState(weapon2, "firing") setWeaponProperty(weapon1, "fire_rotation", 0, -30, -1) setWeaponProperty(weapon2, "fire_rotation", 0, -30, -1) end end addCommandHandler ( "attach", attach ) I already attached it but the miniguns are attached and facing in the right., Link to comment
Ryancit2 Posted April 11, 2015 Share Posted April 11, 2015 Use setElementRotation on creating weapon1 and weapon2. Link to comment
Mr.unpredictable. Posted April 11, 2015 Share Posted April 11, 2015 Use setElementRotation on creating weapon1 and weapon2. or add the xyz rotoation to attach elements code itself. Just edit the line 10 and 11 with this attachElements ( weapon1, theVehicle, 0, 0, 0, 20, 30, 90 ) attachElements ( weapon2, theVehicle, 0, 1, 0, 20, 30, 90 ) Full code local screenW,screenH = guiGetScreenSize() local weapon1 local weapon2 function attach ( ) local theVehicle = getPedOccupiedVehicle ( localPlayer ) if theVehicle then local x,y,z = getElementPosition ( theVehicle ) weapon1 = createWeapon("minigun", x, y, z + 1) weapon2 = createWeapon("minigun", x, y, z + 1) attachElements ( weapon1, theVehicle, 0, 0, 0, 20, 30, 90 ) attachElements ( weapon2, theVehicle, 0, 1, 0, 20, 30, 90 ) setWeaponClipAmmo(weapon1, 99999) setWeaponClipAmmo(weapon2, 99999) setWeaponState(weapon1, "firing") setWeaponState(weapon2, "firing") setWeaponProperty(weapon1, "fire_rotation", 0, -30, -1) setWeaponProperty(weapon2, "fire_rotation", 0, -30, -1) end end addCommandHandler ( "attach", attach ) http://i.imgur.com/G8iF23N.jpg Link to comment
mox.workz Posted April 11, 2015 Author Share Posted April 11, 2015 (edited) Here: I found something it all worked well BUT.... the guns are just client sided, I mean I'm just the only one who can see it., here is my code: Server: local weapon_state = nil function createBatPod(thePlayer, command) local pX,pY,pZ = getElementPosition(thePlayer) local _,_,rot = getElementRotation (thePlayer) local Batpod = createVehicle (522, pX,pY,pZ) if (Batpod) then warpPedIntoVehicle (thePlayer, Batpod) triggerClientEvent(thePlayer, "onCreateUzi", getRootElement(),pX,pY,pZ) bindKey(thePlayer, "vehicle_fire", "both", fire_uzi) end end addCommandHandler ("batpod", createBatPod) function fire_uzi(thePlayer, key, keyState) if (keyState == "down") then weapon_state = "firing" triggerClientEvent(thePlayer, "uzi_state", getRootElement(),weapon_state) elseif (keyState == "up") then weapon_state = "ready" triggerClientEvent(thePlayer, "uzi_state", getRootElement(),weapon_state) end end Client: addEvent ("onCreateUzi",true) function createUzi (px,py,pz) uzi = createWeapon("uzi", px,py,pz) setWeaponClipAmmo(uzi, 99999) attachElementToElement(uzi,getPedOccupiedVehicle(localPlayer), 0, 1.2, 0, 0, 0, 90) end addEventHandler ("onCreateUzi", root, createUzi) addEvent ("uzi_state",true) function fire_uzi (state) local weapon_state = tostring(state) setWeaponState(uzi, weapon_state) end addEventHandler ("uzi_state", root, fire_uzi) this one is quite cool actually 'coz it automatically warp me to the summoned vehicle. the vehicle will appear to all player in the server because I guess it is declared in the Server Side but the gun which is the UZI will not. i dont know how to declare the weapon in the server side.., I'm the only who can see it. Pls help.. Edited April 11, 2015 by Guest Link to comment
Mr.unpredictable. Posted April 11, 2015 Share Posted April 11, 2015 I don't understand what are you trying to do. Link to comment
mox.workz Posted April 11, 2015 Author Share Posted April 11, 2015 I don't understand what are you trying to do. This is what I'm Trying to do: and this is what the script does: When I encode the command "batpod", it creates a vehicle and automatically warped me into it, then in triggers the event which is it creates weapon: Uzi and attached it to the Vehicle:Bat Pod(522).. My problem is I'm the only one who can see the Uzi. Link to comment
Ryancit2 Posted April 11, 2015 Share Posted April 11, 2015 Create weapon on serverside. Link to comment
mox.workz Posted April 11, 2015 Author Share Posted April 11, 2015 (edited) Create weapon on serverside. how? this is what i did., still no luck., local weapon_state = nil function createBatPod(thePlayer, command) local pX,pY,pZ = getElementPosition(thePlayer) local _,_,rot = getElementRotation (thePlayer) local Batpod = createVehicle (522, pX,pY,pZ) if (Batpod) then warpPedIntoVehicle (thePlayer, Batpod) triggerClientEvent(thePlayer, "onCreateUzi", getRootElement(),pX,pY,pZ) bindKey(thePlayer, "vehicle_fire", "both", fire_uzi) end local uzi = createWeapon("uzi", px,py,pz) end addCommandHandler ("batpod", createBatPod) function fire_uzi(thePlayer, key, keyState) if (keyState == "down") then weapon_state = "firing" triggerClientEvent(thePlayer, "uzi_state", getRootElement(),weapon_state) elseif (keyState == "up") then weapon_state = "ready" triggerClientEvent(thePlayer, "uzi_state", getRootElement(),weapon_state) end end Edited April 11, 2015 by Guest Link to comment
Mr.unpredictable. Posted April 11, 2015 Share Posted April 11, 2015 Just sayi8ng, If you are changing the weapon from minigun to uzi just because minigun is overpowered then you can reduce the power of minigun. Link to comment
mox.workz Posted April 11, 2015 Author Share Posted April 11, 2015 Just sayi8ng, If you are changing the weapon from minigun to uzi just because minigun is overpowered then you can reduce the power of minigun. nope., I can change the weapon to anything later., all I need to know now is how to make it appear to everyone., I don't know how to create weapon in server side which sync to client side., Link to comment
Ryancit2 Posted April 11, 2015 Share Posted April 11, 2015 addCommandHandler on serverside and trigger that for client by: triggerClientEvent(player, "createBatPod", player) Then try, i think that would work. Link to comment
mox.workz Posted April 12, 2015 Author Share Posted April 12, 2015 addCommandHandler on serverside and trigger that for client by: triggerClientEvent(player, "createBatPod", player) Then try, i think that would work. there's no wrong when creating the vehicle batpod., it appears in every users., the only problem is creating the weapon which doesn't appears to other player., only to the player who executes the command., Link to comment
Walid Posted April 12, 2015 Share Posted April 12, 2015 Create weapon on serverside. lol you can't use CreateWeapon() funtion server side. try to use this : triggerClientEvent(root, "onCreateUzi", root,pX,pY,pZ) Link to comment
mox.workz Posted April 12, 2015 Author Share Posted April 12, 2015 try to use this : triggerClientEvent(root, "onCreateUzi", root,pX,pY,pZ) Still not working sir. Link to comment
Mr.unpredictable. Posted April 12, 2015 Share Posted April 12, 2015 try to use this : triggerClientEvent(root, "onCreateUzi", root,pX,pY,pZ) Still not working sir. That should work, post your full code or the part of the code. Link to comment
mox.workz Posted April 12, 2015 Author Share Posted April 12, 2015 post full code here here: server: local weapon_state = nil function createBatPod(thePlayer, command) local pX,pY,pZ = getElementPosition(thePlayer) local _,_,rot = getElementRotation (thePlayer) local Batpod = createVehicle (522, pX,pY,pZ) if (Batpod) then warpPedIntoVehicle (thePlayer, Batpod) triggerClientEvent(root, "onCreateUzi", getRootElement(),pX,pY,pZ) bindKey(thePlayer, "vehicle_fire", "both", fire_uzi) end end addCommandHandler ("batpod", createBatPod) function fire_uzi(thePlayer, key, keyState) if (keyState == "down") then weapon_state = "firing" triggerClientEvent(thePlayer, "uzi_state", getRootElement(),weapon_state) elseif (keyState == "up") then weapon_state = "ready" triggerClientEvent(thePlayer, "uzi_state", getRootElement(),weapon_state) end end client: addEvent ("onCreateUzi",true) function createUzi (px,py,pz) uzi = createWeapon("uzi", px,py,pz) setWeaponClipAmmo(uzi, 99999) attachElementToElement(uzi,getPedOccupiedVehicle(localPlayer), 0, 1.2, 0, 0, 0, 90) end addEventHandler ("onCreateUzi", root, createUzi) addEvent ("uzi_state",true) function fire_uzi (state) local weapon_state = tostring(state) setWeaponState(uzi, weapon_state) end addEventHandler ("uzi_state", root, fire_uzi) still the same problem., all worked fine but the other players in the server can't be hit or even see the attached uzi in the vehicle., Link to comment
Walid Posted April 12, 2015 Share Posted April 12, 2015 ok try this : -- Client side addEvent ("onCreateUzi",true) function createUzi (vehicle,px,py,pz) uzi = createWeapon("uzi", px,py,pz) setWeaponClipAmmo(uzi, 99999) attachElementToElement(uzi,vehicle, 0, 1.2, 0, 0, 0, 90) end addEventHandler ("onCreateUzi", root, createUzi) function fire_uzi (state) local weapon_state = tostring(state) setWeaponState(uzi, weapon_state) end addEvent ("uzi_state",true) addEventHandler ("uzi_state", root, fire_uzi) -- Server side function createBatPod(thePlayer, command) local pX,pY,pZ = getElementPosition(thePlayer) local _,_,rot = getElementRotation (thePlayer) local Batpod = createVehicle (522, pX,pY,pZ) if (Batpod) then warpPedIntoVehicle (thePlayer, Batpod) triggerClientEvent(root, "onCreateUzi", root,Batpod,pX,pY,pZ) bindKey(thePlayer, "vehicle_fire", "both", fire_uzi) end end addCommandHandler ("batpod", createBatPod) function fire_uzi(thePlayer, key, keyState) if (keyState == "down") then weapon_state = "firing" triggerClientEvent(thePlayer, "uzi_state", getRootElement(),weapon_state) elseif (keyState == "up") then weapon_state = "ready" triggerClientEvent(thePlayer, "uzi_state", getRootElement(),weapon_state) end end Link to comment
mox.workz Posted April 12, 2015 Author Share Posted April 12, 2015 still same result., damn! this is so depressing., Link to comment
Ryancit2 Posted April 12, 2015 Share Posted April 12, 2015 Create weapon on serverside. lol you can't use CreateWeapon() funtion server side. try to use this : triggerClientEvent(root, "onCreateUzi", root,pX,pY,pZ) Excuse me, read my second reply, i also suggested creating weapon via serverside by triggerClientEvent addCommandHandler on serverside and trigger that for client by: triggerClientEvent(player, "createBatPod", player) Then try, i think that would work. 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