Death Posted March 1, 2014 Share Posted March 1, 2014 hello I'm creating an arena shooter and the script makes the car shoot the first time he enters the arena. Problem is when the player leaves the arena and back to her car does not shoot more = / please help me client local hillArea = createColRectangle ( -2171.0678710938, 678.17950439453, 100, 100 ) local hillRadar = createRadarArea ( -2183.5678710938, 705.67950439453, 100, -100, 0, 255, 0, 175 ) function hill_Enter ( thePlayer, matchingDimension ) if (getElementType(thePlayer) == "vehicle") then outputChatBox( getPlayerName(thePlayer) .. " Entrou na Zona Fun Seu Carro Pode Atirar Agora!", thePlayer, 255, 255, 109 ) setRadarAreaFlashing ( hillRadar, true ) end end addEventHandler ( "onColShapeHit", hillArea, hill_Enter ) function hill_Exit ( thePlayer, matchingDimension ) vehicles = getElementsByType("vehicle") bindTrigger = 0 end addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) cLP = getLocalPlayer() screenWidth, screenHeight = guiGetScreenSize() function cRStest() setTimer(resourcesCheck, 10000, 1) end addEventHandler("onClientResourceStart", getRootElement(), cRStest) function resourcesCheck() if check=="hillRadar" then return else setRadioChannel(0) setTimer(cbinds, 1000, 1) textToggle=0 check="hillRadar" end end function cRS() if check=="hillRadar" then return else setRadioChannel(0) setTimer(cbinds, 3333, 1) textToggle=0 check="hillRadar" end end addEventHandler("onColShapeHit", hillArea, cRS) function markers(player) if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) fixVehicle(vehicle) end end addEventHandler("onClientMarkerHit", getResourceRootElement(getThisResource()), markers) function cbinds() local keys1 = getBoundKeys("vehicle_fire") local keys2 = getBoundKeys("vehicle_secondary_fire") if keys1 then for keyName, state in pairs(keys1) do bindKey(keyName, "down", cdoshoot) end bindKey("F", "down", cdoshoot) cbindsText = "- Press F or the button you use to fire to shoot rockets!\n- You can shoot once every 3 seconds.\n- good luck and have fun!." end if keys2 then for keyName, state in pairs(keys2) do bindKey(keyName, "down", cdoshoot) end end if (not keys1) and (not keys2) then bindKey("F", "down", cdoshoot) bindKey("lctrl", "down", cdoshoot) bindKey("rctrl", "down", cdoshoot) cbindsText = "- Press F or CTRL to shoot rockets!\n- You can shoot once every 3 seconds." end theVehicle = getPedOccupiedVehicle(cLP) allowShoots() bindKey("X", "down", toggleText) outputChatBox("Seu carro atira", 255, 255, 255, true) end function toggleText() if textToggle==0 then addEventHandler("onClientRender", getRootElement(), bindsText) textToggle=1 elseif textToggle==1 then removeEventHandler("onClientRender", getRootElement(), bindsText) textToggle=0 end end function allowShoots() bindTrigger = 1 end function cdoshoot() if bindTrigger == 1 then if not isPlayerDead(cLP) then bindTrigger = 0 local x,y,z = getElementPosition(theVehicle) local rX,rY,rZ = getVehicleRotation(theVehicle) local x = x+8*math.cos(math.rad(rZ+100)) local y = y+8*math.sin(math.rad(rZ+100)) createProjectile(theVehicle, 19, x, y, z, 1.0, nil) local x,y,z = getElementPosition(theVehicle) local rX,rY,rZ = getVehicleRotation(theVehicle) local x = x+8*math.cos(math.rad(rZ+80)) local y = y+8*math.sin(math.rad(rZ+80)) createProjectile(theVehicle, 19, x, y, z, 1.0, nil) setTimer(allowShoots, 3000, 1) end end end function bindsText() dxDrawText(cbindsText, screenWidth/15, screenHeight/2.5, screenWidth, screenHeight, tocolor(0, 255, 110, 255), 2, "^ReLoco#") end server local hillArea = createColRectangle ( -2171.0678710938, 678.17950439453, 100, 100 ) local hillRadar = createRadarArea ( -2183.5678710938, 705.67950439453, 100, -100, 0, 255, 0, 175 ) function hill_Exit ( thePlayer, matchingDimension ) vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do destroyElement(v) if (getElementType(thePlayer) == "vehicle") then if isPedDead ( thePlayer ) ~= true then outputChatBox ( getPlayerName(thePlayer) .. " Saiu da Zona Fun Seu Carro Não Pode Atirar Mais!", thePlayer, 255, 255, 109 ) setRadarAreaFlashing ( hillRadar, false ) end end end end addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) Link to comment
Dealman Posted March 1, 2014 Share Posted March 1, 2014 Why are you using server-side events and functions in your client script? Link to comment
Death Posted March 1, 2014 Author Share Posted March 1, 2014 was the only way that worked Link to comment
Death Posted March 2, 2014 Author Share Posted March 2, 2014 I changed the code and still does not work help me local hillArea = createColRectangle ( -2171.0678710938, 678.17950439453, 100, 100 ) local hillRadar = createRadarArea ( -2183.5678710938, 705.67950439453, 100, -100, 0, 255, 0, 175 ) function entrou () setTimer(cbinds, 3333, 1) end addEventHandler ( "onColShapeHit", hillArea, entrou ) function hill_Exit ( thePlayer, matchingDimension ) end addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) cLP = getLocalPlayer() screenWidth, screenHeight = guiGetScreenSize() function cRStest() setTimer(resourcesCheck, 10000, 1) end addEventHandler("onClientResourceStart", getRootElement(), cRStest) function resourcesCheck() if check=="hillRadar" then return else setRadioChannel(0) setTimer(cbinds, 1000, 1) textToggle=0 check="hillRadar" end end function cRS() if check=="hillRadar" then return else setRadioChannel(0) setTimer(cbinds, 3333, 1) textToggle=0 check="hillRadar" end end addEventHandler("onColShapeHit", hillArea, cRS) function cbinds() local keys1 = getBoundKeys("vehicle_fire") local keys2 = getBoundKeys("vehicle_secondary_fire") if keys1 then for keyName, state in pairs(keys1) do bindKey(keyName, "down", cdoshoot) end bindKey("F", "down", cdoshoot) cbindsText = "- Press F or the button you use to fire to shoot rockets!\n- You can shoot once every 3 seconds.\n- good luck and have fun!." end if keys2 then for keyName, state in pairs(keys2) do bindKey(keyName, "down", cdoshoot) end end if (not keys1) and (not keys2) then bindKey("F", "down", cdoshoot) bindKey("lctrl", "down", cdoshoot) bindKey("rctrl", "down", cdoshoot) cbindsText = "- Press F or CTRL to shoot rockets!\n- You can shoot once every 3 seconds." end theVehicle = getPedOccupiedVehicle(cLP) allowShoots() bindKey("X", "down", toggleText) outputChatBox("Seu carro atira", 255, 255, 255, true) end function toggleText() if textToggle==0 then addEventHandler("onClientRender", getRootElement(), bindsText) textToggle=1 elseif textToggle==1 then removeEventHandler("onClientRender", getRootElement(), bindsText) textToggle=0 end end function allowShoots() bindTrigger = 1 end function cdoshoot() if bindTrigger == 1 then if not isPlayerDead(cLP) then bindTrigger = 0 local x,y,z = getElementPosition(theVehicle) local rX,rY,rZ = getVehicleRotation(theVehicle) local x = x+8*math.cos(math.rad(rZ+100)) local y = y+8*math.sin(math.rad(rZ+100)) createProjectile(theVehicle, 19, x, y, z, 1.0, nil) local x,y,z = getElementPosition(theVehicle) local rX,rY,rZ = getVehicleRotation(theVehicle) local x = x+8*math.cos(math.rad(rZ+80)) local y = y+8*math.sin(math.rad(rZ+80)) createProjectile(theVehicle, 19, x, y, z, 1.0, nil) setTimer(allowShoots, 3000, 1) end end end function bindsText() dxDrawText(cbindsText, screenWidth/15, screenHeight/2.5, screenWidth, screenHeight, tocolor(0, 255, 110, 255), 2, "^ReLoco#") end 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