Ayush Rathore Posted March 13, 2017 Share Posted March 13, 2017 (edited) Well i was making this code but its not working properly. Client Side local weapa local weapb function mini_front() local che = getPedOccupiedVehicle(getLocalPlayer()) x,y,z = getElementPosition(getLocalPlayer()) if che then weapa = createWeapon("minigun",x,y,z) weapb = createWeapon("minigun",x,y,z) setElementAlpha(weapa,0) attachElements(weapa,che,-1.18,1.9,-0.6, 0, 0, 90) setElementAlpha(weapb,0) attachElements(weapb,che,1.18,1.9,-0.6, 0, 0, 90) setWeaponClipAmmo(weapb, 99999) setWeaponClipAmmo(weapa, 99999) setWeaponState(weapa,"firing") setWeaponState(weapb,"firing") end end function mini_front_stop() if isElement(weapa) and isElement(weapb) then destroyElement(weapa) destroyElement(weapb) end end addEvent("mini_front",true) addEventHandler("mini_front",getLocalPlayer(),mini_front) addEvent("mini_front_stop",true) addEventHandler("mini_front_stop",getLocalPlayer(),mini_front_stop) Server Side function minigun_front(source) triggerClientEvent(root,"mini_front",source) end function minigun_front_stop(source) triggerClientEvent(root,"mini_front_stop",source) end function rocket_white(source) bindKey(source,'mouse1','down',minigun_front) bindKey(source,'mouse1','down',minigun_front_stop) end addEventHandler("onVehicleEnter", root, rocket_white) The code works fine but the only error is that only local player can see it and it also do not cause any damage (server/client both) Thanks for help in Advance. Edited March 13, 2017 by Ayush Rathore Link to comment
Moderators Citizen Posted March 13, 2017 Moderators Share Posted March 13, 2017 (edited) My first guess would be to use source instead of getLocalPlayer() at line 6 and 7 from the client side: local che = getPedOccupiedVehicle(source) x,y,z = getElementPosition(source) Also you probably want to bind the minigun_front_stop function for when you release the mouse1 key: bindKey(source,'mouse1','down',minigun_front) bindKey(source,'mouse1','up',minigun_front_stop) -- changed 'down' for 'up' You also forgot to take this note into consideration: You need to fix that for both miniguns: setWeaponProperty(weapa, "fire_rotation", 0, -30, 0) setWeaponProperty(weapb, "fire_rotation", 0, -30, 0) Edited March 13, 2017 by Citizen 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