Jump to content

help radar area


Death

Recommended Posts

This code was for when the player enter the area the vehicle he can shoot missiles

and when he left the vehicle to be removed

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 ) 
    local keys1 = getBoundKeys("vehicle_fire") 
    if keys1 then 
        for keyName, state in pairs(keys1) do 
            bindKey(keyName, "down", cdoshoot) 
        end 
        bindKey("F", "down", cdoshoot) 
    end 
    if (not keys1) then 
        bindKey("F", "down", cdoshoot) 
        bindKey("lctrl", "down", cdoshoot) 
        bindKey("rctrl", "down", cdoshoot) 
    end 
    theVehicle = getPedOccupiedVehicle(thePlayer) 
    allowShoots() 
            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") 
        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 ) 
  
  
function allowShoots() 
    bindTrigger = 1 
end 
  
function cdoshoot(thePlayer) 
    if bindTrigger == 1 then 
        if not isPlayerDead(thePlayer) then 
            bindTrigger = 0 
            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(allowShoots, 3000, 1) 
        end 
    end 
end 
  
  

Link to comment

CLIENT SIDE

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 ) 
    local keys1 = getBoundKeys("vehicle_fire") 
    if keys1 then 
        for keyName, state in pairs(keys1) do 
            bindKey(keyName, "down", cdoshoot) 
        end 
        bindKey("F", "down", cdoshoot) 
    end 
    if (not keys1) then 
        bindKey("F", "down", cdoshoot) 
        bindKey("lctrl", "down", cdoshoot) 
        bindKey("rctrl", "down", cdoshoot) 
    end 
    theVehicle = getPedOccupiedVehicle(thePlayer) 
    allowShoots() 
            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 ( "onClientColShapeHit", hillArea, hill_Enter ) 
  
  
function hill_Exit ( thePlayer, matchingDimension ) 
        vehicles = getElementsByType("vehicle") 
        for i,v in ipairs(vehicles) do 
        destroyElement(v) 
        if (getElementType(thePlayer) == "vehicle") then 
                if isPlayerDead ( 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 ( "onClientColShapeLeave", hillArea, hill_Exit ) 
  
  
function allowShoots() 
    bindTrigger = 1 
end 
  
function cdoshoot(thePlayer) 
    if bindTrigger == 1 then 
        local theVehicle = getPedOccupiedVehicle(thePlayer) 
        if not isPlayerDead(thePlayer) and theVehicle then 
            bindTrigger = 0 
            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(allowShoots, 3000, 1) 
        end 
    end 
end 
  
  

Link to comment

not work error

[11:13:32] WARNING: Morte_area/client3.lua(Line 52) [Client] getVehicleRotation is deprecated and may not work in future versions. Please replace with getElementRotation.

[11:13:32] Some files in 'Morte_area' use deprecated functions.

[11:13:32] Use the 'upgrade' command to perform a basic upgrade of resources.

Link to comment
not work error

[11:13:32] WARNING: Morte_area/client3.lua(Line 52) [Client] getVehicleRotation is deprecated and may not work in future versions. Please replace with getElementRotation.

[11:13:32] Some files in 'Morte_area' use deprecated functions.

[11:13:32] Use the 'upgrade' command to perform a basic upgrade of resources.

The error is written in plain English. It literally takes one change in the script and you can't even do that by yourself.

getVehicleRotation -> getElementRotation

local hillArea = createColRectangle(-2171.0678710938, 678.17950439453, 100, 100) 
local hillRadar = createRadarArea(-2183.5678710938, 705.67950439453, 100, -100, 0, 255, 0, 175) 
  
function allowShoots() 
    bindTrigger = 1 
end 
  
addEventHandler("onClientColShapeHit", hillArea, 
    function(thePlayer, matchingDimension) 
        local keys1 = getBoundKeys("vehicle_fire") 
         
        if (keys1) then 
            for keyName, state in pairs(keys1) do 
                bindKey(keyName, "down", cdoshoot) 
            end 
            bindKey("F", "down", cdoshoot) 
        else 
            bindKey("F", "down", cdoshoot) 
            bindKey("lctrl", "down", cdoshoot) 
            bindKey("rctrl", "down", cdoshoot) 
        end 
         
        theVehicle = getPedOccupiedVehicle(thePlayer) 
        allowShoots() 
         
        if (getElementType(thePlayer) == "vehicle") then 
            outputChatBox(getPlayerName(thePlayer) .. " Entrou na Zona Fun Seu Carro Pode Atirar Agora!", thePlayer, 255, 255, 109, false) 
            setRadarAreaFlashing(hillRadar, true) 
        end 
    end 
) 
  
addEventHandler("onClientColShapeLeave", hillArea, 
    function(thePlayer, matchingDimension) 
        vehicles = getElementsByType("vehicle") 
        for i,v in ipairs(vehicles) do 
            destroyElement(v) 
            if (getElementType(thePlayer) == "vehicle") then 
                if (getElementHealth(thePlayer) > 0) then 
                    outputChatBox(getPlayerName(thePlayer) .. " Saiu da Zona Fun Seu Carro Não Pode Atirar Mais!", thePlayer, 255, 255, 109, false) 
                    setRadarAreaFlashing(hillRadar, false) 
                end 
            end 
        end 
    end 
) 
  
function cdoshoot(thePlayer) 
    if (bindTrigger == 1) then 
        local theVehicle = getPedOccupiedVehicle(thePlayer) 
        if ((getElementHealth(thePlayer) > 0) and (theVehicle) then 
            bindTrigger = 0 
            local x, y, z = getElementPosition(theVehicle) 
            local rX, rY, rZ = getElementRotation(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(allowShoots, 3000, 1) 
        end 
    end 
end 

Additionally, you should probably read these manuals:

Edited by Guest
Link to comment

warning: Morte_area\client.lua:51:Bad Argument @ 'getElementHealth'

warning: Morte_area\client.lua:27:Bad Argument @ getPlayerName[Expected player at argument 1,got vehicle]

Error: Morte_area\client.lua:40: attempt to concatenate a boolean value

warning: Morte_area\client.lua:23:Bad 'ped' pointer @ getPedOccupiedVehicle(1)

Link to comment

errors help plis

warning: Morte_area\client.lua:51:Bad Argument @ 'getElementHealth'

if ((getElementHealth(thePlayer) > 0) and (theVehicle)) then 

warning: Morte_area\client.lua:27:Bad Argument @ getPlayerName[Expected player at argument 1,got vehicle]

outputChatBox(getPlayerName(thePlayer) .. " Entrou na Zona Fun Seu Carro Pode Atirar Agora!", thePlayer, 255, 255, 109, false) 

Error: Morte_area\client.lua:40: attempt to concatenate a boolean value

             outputChatBox(getPlayerName(thePlayer) .. " Saiu da Zona Fun Seu Carro Não Pode Atirar Mais!", thePlayer, 255, 255, 109, false) 

warning: Morte_area\client.lua:23:Bad 'ped' pointer @ getPedOccupiedVehicle(1)

theVehicle = getPedOccupiedVehicle(thePlayer) 

Link to comment

Well I changed the script and was so

the only problem is that anyone who is outside of this area also firing missile

I want only those who are in the area firing missile = /

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 ) 
        unvehicles = 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 ) 
  
  
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("#FF0000Press #00FF95X #FF0000to show/hide instructions! \"{SMILIES_PATH}/icon_biggrin.gif\" alt=\"\" title=\"Very Happy\" />", 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

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 hill_Enter ( thePlayer, matchingDimension ) 
                if (getElementType(getLocalPlayer()) == "vehicle") then 
                outputChatBox( getPlayerName(getLocalPlayer ( )) .. " 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 ) 
        unvehicles = getElementsByType("vehicle") 
        for i,v in ipairs(vehicles) do 
        destroyElement(v) 
        if (getElementType(getLocalPlayer()) == "vehicle") then 
                if isPlayerDead ( 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 ) 
  
  
cLP = getLocalPlayer() 
screenWidth, screenHeight = guiGetScreenSize() 
  
  
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("#FF0000Press #00FF95X #FF0000to show/hide instructions! \"{SMILIES_PATH}/icon_biggrin.gif\" alt=\"\" title=\"Very Happy\" />", 255, 255, 255, true) 
end 
addEventHandler ( "onColShapeHit", hillArea, cbinds ) 
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
  • 5 months later...

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...