Jump to content

[HELP] Rescricting script to a map.


Swatrat

Recommended Posts

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 by Guest
Link to comment

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...