Jump to content

[HELP]Command Only In location


Black2

Recommended Posts

I don't know you can use

  
--colShape functions as  
createColCircle  
createColRectangle  
-- you can find those in wiki as well as their events  
-- or simply use  
function authorizeCmd (thePlayer , cmd )  
    if getElementType(thePlayer) ~= "player" then return end  
    local x, y, z = getElementPosition(thePlayer) 
    zone = getZoneName(x, y, z, true) -- will output LS , LV, SF 
    if (zone == "Las Venturas" ) and (cmd) then -- you can change Las Venturas to location you want  
     -- do something  
    end  
end  
  
-- Not tested though .  

Link to comment

Based on zone name:

local blacklistCommands = { 
    ["say"] = true 
} 
addEventHandler("onPlayerCommand", 
    function(command) 
        local x, y, z = getElementPosition(source) 
        if getZoneName(x, y, z, true) == "Los Santos" and blacklistCommands[command] then 
            cancelEvent() 
        end 
    end 
) 

Or ColShape:

local blacklistCommands = { 
    ["say"] = true 
} 
local col = createColCircle(...) 
addEventHandler("onPlayerCommand", 
    function(command) 
        if isElementWithinColShape(source, col) and blacklistCommands[command] then 
            cancelEvent() 
        end 
    end 
) 

Link to comment

I am assuming you want a command to work on specific location.

In that case, the following will do the job.

  
  
function restrictedCommand(thePlayer) 
    if getElementZoneName (thePlayer) == "YourZoneName" then 
    -- do your stuff 
    end 
end 
addCommandHandler("YourCommand", restrictedCommand) 
  

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