Jump to content

Click Car


ViRuZGamiing

Recommended Posts

Hello,

What's the function for clicking a car?

I searched for onVehicleClick but it doesn't exist.

At the moment I have a short part for the cursor to be visible.

bindKey ("b", "down",                            -- binds B key to toggle cursor state 
        function() 
                showCursor( not isCursorShowing() ) 
        end) 

Link to comment
function onVehicleClick ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
        if ( clickedElement ) and ( clickedElement == getElementType ( "vehicle" ) )then 
  
        end 
end 
addEventHandler ( "onClientClick", getRootElement(), onVehicleClick ) 

Link to comment

Sack I wrote a , this doesn't end the code.

@WASSIm. can you get the onVehicleClick code in my code and let it do

if getVehicleName == 523 or 598  or 596 or 597 or 599 then 

Then this code

bindKey ("m", "down",                                            -- binds M key to toggle cursor state 
        function() 
                showCursor( not isCursorShowing() ) 
        end) 
         
addEventHandler("onClientVehicleEnter", 
    function (thePlayer, 
    local playerTeam = getPlayerTeam ( source )     -- get the player's team 
    if ( playerTeam ) == Police then                          -- checks if it's Police 
    giveWeapon ( thePlayer, 23, 200 )                     -- If Team is Police then gives the player a gun 
    end 
end 

Link to comment

you want if click car id 523 or 598 or 596 or 597 or 599 and you in team police will give a weapon ?

function onVehicleClick ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
        if ( clickedElement ) and ( clickedElement == getElementType ( "vehicle" ) )then 
                if ( getElementModel == (523 or 598  or 596 or 597 or 599) ) then 
                        local playerTeam = getPlayerTeam ( source ) 
                        if ( playerTeam ) and ( getTeamName ( playerTeam ) == "Police" ) then 
                                giveWeapon ( thePlayer, 23, 200 ) 
                        end 
                end 
        end 
end 
addEventHandler ( "onClientClick", getRootElement(), onVehicleClick ) 

Link to comment
you want if click car id 523 or 598 or 596 or 597 or 599 and you in team police will give a weapon ?
function onVehicleClick ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
        if ( clickedElement ) and ( clickedElement == getElementType ( "vehicle" ) )then 
                if ( getElementModel == (523 or 598  or 596 or 597 or 599) ) then 
                        local playerTeam = getPlayerTeam ( source ) 
                        if ( playerTeam ) and ( getTeamName ( playerTeam ) == "Police" ) then 
                                giveWeapon ( thePlayer, 23, 200 ) 
                        end 
                end 
        end 
end 
addEventHandler ( "onClientClick", getRootElement(), onVehicleClick ) 

Indeed, thanks WASSIm. !

Link to comment
  
function onVehicleClick(clickedElement) 
        if clickedElement and clickedElement == getElementType("vehicle") then 
                if getElementModel(clickedElement) == 523 or 598  or 596 or 597 or 599 then 
                        local playerTeam = getPlayerTeam(source) 
                        if playerTeam and getTeamName(playerTeam) == "Police" then 
                                giveWeapon(source, 23, 200) 
                        end 
                end 
        end 
end 
addEventHandler("onClientClick",root,onVehicleClick) 
  
addEventHandler("onClientResourceStart",root,function() 
bindKey (source,"m","down",function() 
        showCursor(not isCursorShowing()) 
end 
) 
  

Link to comment
  • Moderators

this probably will work:

addEventHandler("onClientResourceStart", resourceRoot, 
       bindKey ("m", "down",               
        function() 
                showCursor( not isCursorShowing() ) 
        end) 
end) 

Keys can't be set when the resource hasn't start yet, as far as I know.

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