Jump to content

[SOLVED] bindKey to a command


DRW

Recommended Posts

local chat_range = 30 
  
addCommandHandler ("local",function(source,_,...) 
  
    local nick=getPlayerName(source) 
    local msg = table.concat({...}, " ") 
  
 if getPlayerTeam(source) then 
        r,g,b = getTeamColor(getPlayerTeam(source)) 
    else 
        r,g,b = getPlayerNametagColor(source) 
    end 
    if isPedInVehicle(source)then 
        for _,v in ipairs(getVehicleOccupants(getPedOccupiedVehicle(source)))do 
            outputChatBox("(Car Chat) "..nick..": "..msg,v,r,g,b,true) 
        end 
    else 
        local px,py,pz=getElementPosition(source) 
        for _,v in ipairs(getElementsByType("player")) do 
            if isPlayerInRangeOfPoint(v,px,py,pz,chat_range)then 
                outputChatBox("(Local) ".. nick ..": "..msg,v,r,g,b,true) 
            end 
        end 
    end 
end) 
  
function talk2 () 
bindKey (source,"u","down", "chatbox local") 
end --Here is the bindKey 
addEventHandler ("onPlayerLogin", getRootElement(), talk2) 

I'm adding a bind to a command so people can open that chatbox, the chatbox works perfectly if I /bind u chatbox local, but the script does nothing. What can I do?

Edited by Guest
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...