Jump to content

Problem Bindkey


iFoReX

Recommended Posts

I want if the Player Press M put the showCursor true/false

here the code

  
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Progress = {} 
GUIEditor_Image = {} 
  
GUICar = guiCreateWindow(0.6553,0.6224,0.3477,0.3802,"GUI Sistema de Autos",true) 
guiWindowSetMovable(GUICar,false) 
guiWindowSetSizable(GUICar,false) 
GUIEditor_Label[1] = guiCreateLabel(18,161,130,39,"Velocidad",false,GUICar) 
GUIEditor_Progress[1] = guiCreateProgressBar(19,194,328,50,false,GUICar) 
GUIEditor_Label[2] = guiCreateLabel(158,251,52,14,"0 Kms/H",false,GUICar) 
guiSetFont(GUIEditor_Label[2],"default-bold-small") 
GUIEditor_Button[1] = guiCreateButton(9,35,106,40,"Bloquear",false,GUICar) 
GUIEditor_Label[3] = guiCreateLabel(12,82,102,32,"Vencina/Petroleo",false,GUICar) 
GUIEditor_Progress[2] = guiCreateProgressBar(14,102,333,54,false,GUICar) 
  
showCursor(false) 
guiSetVisible(GUICar,false) 
  
addEventHandler("onClientVehicleEnter", getRootElement(), 
    function(thePlayer, seat) 
        if thePlayer == getLocalPlayer() then 
         guiSetVisible(GUICar,true) 
         end 
    end 
) 
  
bindKey("M","down", 
        function () 
        if isPedInVehicle( localPlayer ) then 
            showCursor(true) 
            else 
            showCursor(false) 
            end 
        end 
    ) 

Link to comment
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Progress = {} 
GUIEditor_Image = {} 
  
GUICar = guiCreateWindow(0.6553,0.6224,0.3477,0.3802,"GUI Sistema de Autos",true) 
guiWindowSetMovable(GUICar,false) 
guiWindowSetSizable(GUICar,false) 
GUIEditor_Label[1] = guiCreateLabel(18,161,130,39,"Velocidad",false,GUICar) 
GUIEditor_Progress[1] = guiCreateProgressBar(19,194,328,50,false,GUICar) 
GUIEditor_Label[2] = guiCreateLabel(158,251,52,14,"0 Kms/H",false,GUICar) 
guiSetFont(GUIEditor_Label[2],"default-bold-small") 
GUIEditor_Button[1] = guiCreateButton(9,35,106,40,"Bloquear",false,GUICar) 
GUIEditor_Label[3] = guiCreateLabel(12,82,102,32,"Vencina/Petroleo",false,GUICar) 
GUIEditor_Progress[2] = guiCreateProgressBar(14,102,333,54,false,GUICar) 
  
showCursor ( false ) 
guiSetVisible ( GUICar, false ) 
  
addEventHandler ( "onClientVehicleEnter", getRootElement(), 
    function ( thePlayer, seat ) 
        if ( thePlayer == localPlayer ) then 
            guiSetVisible ( GUICar, true ) 
         end 
    end 
) 
  
bindKey ( "M", "down", 
    function ( ) 
        if isPedInVehicle ( localPlayer ) then 
            showCursor ( not isCursorShowing ( ) ) 
        end 
    end 
) 

Try with that.

Link to comment

Doesnt work :/ I dont undestand how work it function u.u please help me

GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Progress = {} 
GUIEditor_Image = {} 
  
GUICar = guiCreateWindow(0.6553,0.6224,0.3477,0.3802,"GUI Sistema de Autos",true) 
guiWindowSetMovable(GUICar,false) 
guiWindowSetSizable(GUICar,false) 
GUIEditor_Label[1] = guiCreateLabel(18,161,130,39,"Velocidad",false,GUICar) 
GUIEditor_Progress[1] = guiCreateProgressBar(19,194,328,50,false,GUICar) 
GUIEditor_Label[2] = guiCreateLabel(158,251,52,14,"0 Kms/H",false,GUICar) 
guiSetFont(GUIEditor_Label[2],"default-bold-small") 
GUIEditor_Button[1] = guiCreateButton(9,35,106,40,"Bloquear",false,GUICar) 
GUIEditor_Label[3] = guiCreateLabel(12,82,102,32,"Vencina/Petroleo",false,GUICar) 
GUIEditor_Progress[2] = guiCreateProgressBar(14,102,333,54,false,GUICar) 
  
showCursor ( false ) 
guiSetVisible ( GUICar, false ) 
  
addEventHandler ( "onClientVehicleEnter", getRootElement(), 
    function ( thePlayer, seat ) 
        if ( thePlayer == localPlayer ) then 
            guiSetVisible ( GUICar, true ) 
         end 
    end 
) 
  
bindKey ( "M", "down", 
    function ( ) 
        if isPedInVehicle ( localPlayer ) then 
            showCursor ( not isCursorShowing ( ) ) 
        end 
    end 
) 
  
addEventHandler("onClientVehicleExit", getRootElement(), 
    function(thePlayer, seat) 
        if thePlayer == getLocalPlayer() then 
            guiSetVisible(GUICar,false) 
            showCursor(false) 
        end 
    end 
) 
  
function getElementSpeed(thePlayer) 
        local x,y,z = getElementVelocity(thePlayer) 
            guiProgressBarSetProgress( GUIEditor_Progress[1], x,y,z ) 
end 

Link to comment

That doesn't make any sense.

First you gotta copy the function source code which is:

function getElementSpeed(element,unit) 
    if (unit == nil) then unit = 0 end 
    if (isElement(element)) then 
        local x,y,z = getElementVelocity(element) 
        if (unit=="mph" or unit==1 or unit =='1') then 
            return (x^2 + y^2 + z^2) ^ 0.5 * 100 
        else 
            return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 
        end 
    else 
        outputDebugString("Not an element. Can't get speed") 
        return false 
    end 
end 

Then you gotta implement it on your script.

Link to comment

You ignored what Castillo said.

Use getElementSpeed, it returns one value that is the elementSpeed.

  
  
function getElementSpeed(thePlayer) 
        local car = getPedOccupiedVehicle(thePlayer,"kph") 
        local km = getElementSpeed(car) 
           -- U can't use progress bar. Use a label instead, with clientRender. 
end 
  
  

Link to comment
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Progress = {} 
GUIEditor_Image = {} 
  
GUICar = guiCreateWindow(0.6553,0.6224,0.3477,0.3802,"GUI Sistema de Autos",true) 
guiWindowSetMovable(GUICar,false) 
guiWindowSetSizable(GUICar,false) 
GUIEditor_Label[1] = guiCreateLabel(18,161,130,39,"Velocidad",false,GUICar) 
GUIEditor_Progress[1] = guiCreateProgressBar(19,194,328,50,false,GUICar) 
GUIEditor_Label[2] = guiCreateLabel(158,251,52,14,"0 Kms/H",false,GUICar) 
guiSetFont(GUIEditor_Label[2],"default-bold-small") 
GUIEditor_Button[1] = guiCreateButton(9,35,106,40,"Bloquear",false,GUICar) 
GUIEditor_Label[3] = guiCreateLabel(12,82,102,32,"Vencina/Petroleo",false,GUICar) 
GUIEditor_Progress[2] = guiCreateProgressBar(14,102,333,54,false,GUICar) 
  
showCursor ( false ) 
guiSetVisible ( GUICar, false ) 
  
addEventHandler ( "onClientVehicleEnter", getRootElement(), 
    function ( thePlayer, seat ) 
        if ( thePlayer == localPlayer ) then 
            guiSetVisible ( GUICar, true ) 
         end 
    end 
) 
  
bindKey ( "M", "down", 
    function ( ) 
        if isPedInVehicle ( localPlayer ) then 
            showCursor ( not isCursorShowing ( ) ) 
        end 
    end 
) 
  
addEventHandler("onClientVehicleExit", getRootElement(), 
    function(thePlayer, seat) 
        if thePlayer == getLocalPlayer() then 
            guiSetVisible(GUICar,false) 
            showCursor(false) 
        end 
    end 
) 
  
function getElementSpeed(thePlayer) 
        local car = getPedOccupiedVehicle(thePlayer,"kph") 
        local km = getElementSpeed(car) 
        guiSetText( GUIEditor_Label[2], km ) 
end 

?

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