Swatrat Posted August 25, 2015 Share Posted August 25, 2015 (edited) Hello, I've got lots of shooter maps which have no shooting script. The thing is that they are so much it would take more than a day work to add the script to every map. I wrote something but for some reason it's not working, I am new into scripting and I need some help. Client: local shootingAllowed = true function playerSpawn() shootingAllowed = true end addEventHandler("onClientPlayerSpawn", getLocalPlayer(), playerSpawn) function doShoot() if isShooterMap then if shootingAllowed == true then if not isPlayerDead(getLocalPlayer()) then shootingAllowed = false local theVehicle = getPedOccupiedVehicle(getLocalPlayer()) local x,y,z = getElementPosition(theVehicle) local rX,rY,rZ = getVehicleRotation(theVehicle) local x = x+4*math.cos(math.rad(rZ+90)) local y = y+4*math.sin(math.rad(rZ+90)) createProjectile(theVehicle, 19, x, y, z, 1.0, nil) setTimer(allowShooting, 3000, 1) end end end function allowShooting() shootingAllowed = true end for keyName, state in pairs(getBoundKeys("fire")) do bindKey(keyName, "down", doShoot) end Server: function isMapShooter() return string.find(g_MapInfo.name,"Shooter") end Any help is appreciated! Edited August 25, 2015 by Guest Link to comment
KariiiM Posted August 25, 2015 Share Posted August 25, 2015 What's wrong with this code? Link to comment
Swatrat Posted August 25, 2015 Author Share Posted August 25, 2015 It doesn't give error but it simply doesn't work, when I start it and start a shooter map, you still can't shoot. Link to comment
ozulus Posted August 27, 2015 Share Posted August 27, 2015 Try this. Client: local shootingAllowed = true function playerSpawn() shootingAllowed = true end addEventHandler("onClientPlayerSpawn", getLocalPlayer(), playerSpawn) function doShoot() if shootingAllowed == true then if not isPlayerDead(getLocalPlayer()) then shootingAllowed = false local theVehicle = getPedOccupiedVehicle(getLocalPlayer()) local x,y,z = getElementPosition(theVehicle) local rX,rY,rZ = getVehicleRotation(theVehicle) local x = x+4*math.cos(math.rad(rZ+90)) local y = y+4*math.sin(math.rad(rZ+90)) createProjectile(theVehicle, 19, x, y, z, 1.0, nil) setTimer(allowShooting, 3000, 1) end end end function allowShooting() shootingAllowed = true end function onClientMapStarting_Handler (map) if string.find( map.name, "Shooter", 1, true ) then for keyName, state in pairs(getBoundKeys("vehicle_fire")) do bindKey(keyName, "down", doShoot) end end end addEventHandler("onClientMapStarting",root,onClientMapStarting_Handler) addEvent("onClientMapStarting",true) 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