Jump to content

Click Car


ViRuZGamiing

Recommended Posts

Posted

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) 

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

Posted

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 

Posted

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 ) 

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

Posted
Indeed, thanks WASSIm. !

You're Welcome

I just tried it, the bind "m" doesn't show cursor and if I try with F8's or Chat's Cursor it won't give a weapon.

Yes it's Client Sided

debug: bad argument @ getElementType

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

  • Moderators
Posted
local vehicleCheck = {[523]=true, [598]=true, [596]=true, [597]=true, [599]=true}  -- a both the function. 
  
  
  
-- ect 
if vehicleCheck[getElementModel(clickedElement)] then 

people, WTF!!!!????

  • Moderators
Posted
if ( getElementModel == (523 or 598  or 596 or 597 or 599) ) then 

wut ? :shock:

Indeed, thanks WASSIm. !

O_o what kind of magic is it ?!

  • Moderators
Posted
if ( getElementModel == (523 or 598  or 596 or 597 or 599) ) then 

wut ? :shock:

Indeed, thanks WASSIm. !

O_o what kind of magic is it ?!

"failing"

Posted
local vehicleCheck = {[523]=true, [598]=true, [596]=true, [597]=true, [599]=true}  -- a both the function. 
  
  
  
-- ect 
if vehicleCheck[getElementModel(clickedElement)] then 

people, WTF!!!!????

If I add the cursor bindKey "m" will it work?

  • Moderators
Posted (edited)

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
Posted

Problem with cursor:

[20:37:39] SCRIPT ERROR: car-click\cursor.lua:6: ')' expected (to close '(' at l

ine 1) near 'end'

[20:37:39] ERROR: Loading script failed: car-click\cursor.lua:6: ')' expected (t

o close '(' at line 1) near 'end'

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