ViRuZGamiing Posted October 15, 2013 Posted October 15, 2013 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)
ViRuZGamiing Posted October 15, 2013 Author Posted October 15, 2013 Maybe: local id = getElementModel ( theVehicle ) onClientClick and if id == Car'sID then -- At Car'sID some ID could be writen. Could this work?
WASSIm. Posted October 15, 2013 Posted October 15, 2013 function onVehicleClick ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if ( clickedElement ) and ( clickedElement == getElementType ( "vehicle" ) )then end end addEventHandler ( "onClientClick", getRootElement(), onVehicleClick )
sackforever Posted October 15, 2013 Posted October 15, 2013 You forgot to add the ")" at the end of the bindKey on the first post.
ViRuZGamiing Posted October 15, 2013 Author Posted October 15, 2013 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
ViRuZGamiing Posted October 15, 2013 Author Posted October 15, 2013 Sorry just trying to help. I understand and I guess your new aswell... just if your not sure skip it Thank for trying bro!
WASSIm. Posted October 15, 2013 Posted October 15, 2013 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 )
ViRuZGamiing Posted October 15, 2013 Author Posted October 15, 2013 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. !
ViRuZGamiing Posted October 15, 2013 Author Posted October 15, 2013 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
cheez3d Posted October 15, 2013 Posted October 15, 2013 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 IIYAMA Posted October 15, 2013 Moderators Posted October 15, 2013 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 Citizen Posted October 15, 2013 Moderators Posted October 15, 2013 if ( getElementModel == (523 or 598 or 596 or 597 or 599) ) then wut ? Indeed, thanks WASSIm. ! O_o what kind of magic is it ?!
Moderators IIYAMA Posted October 15, 2013 Moderators Posted October 15, 2013 if ( getElementModel == (523 or 598 or 596 or 597 or 599) ) then wut ? Indeed, thanks WASSIm. ! O_o what kind of magic is it ?! "failing"
ViRuZGamiing Posted October 15, 2013 Author Posted October 15, 2013 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 IIYAMA Posted October 15, 2013 Moderators Posted October 15, 2013 (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 October 15, 2013 by Guest
ViRuZGamiing Posted October 15, 2013 Author Posted October 15, 2013 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'
Moderators Citizen Posted October 15, 2013 Moderators Posted October 15, 2013 You failed to copy the IIYAMA's code, don't forget the ")" after the last end, it's not an error.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now