Jump to content

Problem Bindkey


iFoReX

Recommended Posts

Posted

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 
    ) 

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

Posted

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 

Posted

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.

Posted

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 
  
  

Posted
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 

?

Posted

You're still posting random codes, seriously, you gotta start thinking on what you're doing. If you don't think, then I'm afraid you won't learn anything.

Posted
Why you put that "kph" @ getPedOccupiedVehicle o.O? maybe you wanted to use it @ getElementSpeed?

Just a really stupid mistake

My intention was to put it into getElementSpeed. Sorry :(

Posted
Solid I dont undestand anything of it function :c

That's because you don't even read about the function, you expect us to give you everything fixed, that is not a way to learn.

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