Jump to content

Problem with bind


Recommended Posts

  
  
  
function showplat ( command ) 
if getKeyState("p") then 
    if isPedInVehicle(localPlayer) then 
     
         local localPlayerOccupiedVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) 
         local plateText = getVehiclePlateText ( localPlayerOccupiedVehicle ) 
         local x, y, z = getElementPosition(localPlayerOccupiedVehicle) 
             
             
                local tx, ty = getScreenFromWorldPosition(x, y, z, 5000, false) 
                 
             
        dxDrawText(plateText, tx, ty, tx, ty+10, tocolor(255, 255, 255, 200), 1, "bankgothic", "center", "center") 
             
end 
end 
end 
  
  
bindKey ( "p", "down", showplat )  

I am testing something out, and I am trying to make it so when I hole P then the text will appear above the car, but when I press P, it appears and then disappears straight away.

Thanks!

Link to comment
isHandler = nil 
  
function showplat (  ) 
    if isPedInVehicle(localPlayer) and getKeyState ("p") == true then 
        if isHandler == true then return end 
        addEventHandler('onClientRender',root,Draw) 
        isHandler = true 
    end 
end 
bindKey ( "p", "down", showplat )  
  
function Draw (  ) 
          if not isPedInVehicle ( localPlayer ) then return end 
         local localPlayerOccupiedVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) 
         local plateText = getVehiclePlateText ( localPlayerOccupiedVehicle ) 
         local x, y, z = getElementPosition(localPlayerOccupiedVehicle)    
         local tx, ty = getScreenFromWorldPosition(x, y, z, 5000, false) 
        dxDrawText(tostring(plateText), tx, ty, tx, ty+10, tocolor(255, 255, 255, 200), 1, "bankgothic", "center", "center") 
end 

You have to use a render event to draw dx functions try this and tell me.

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