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) 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

Maybe:

local id = getElementModel ( theVehicle ) 
onClientClick and if id == Car'sID then -- At Car'sID some ID could be writen. 
  
Could this work? 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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

Omerta Roleplay

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 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted
Sorry just trying to help.

I understand and I guess your new aswell... just if your not sure skip it :D

Thank for trying bro!

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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 ) 

Omerta Roleplay

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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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!!!!????

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • 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 ?!

The rEvolution is coming ...

  • 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"

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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?

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

  • 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

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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'

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

  • Moderators
Posted

You failed to copy the IIYAMA's code, don't forget the ")" after the last end, it's not an error.

The rEvolution is coming ...

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