DouglaS666 Posted July 2, 2018 Share Posted July 2, 2018 Velocimetro\speedo_S.lua:22: Bad argument @ 'bindKey' [Expected function at argument 4, got nil] function initCarLocks () local players = getElementsByType ( "player" ) for k,p in ipairs(players) do removeElementData ( p, "cl_ownedvehicle" ) bindKey ( p, "l", "down", doToggleLocked ) end local vehicles = getElementsByType ( "vehicle" ) for k,v in ipairs(vehicles) do removeElementData ( v, "cl_vehicleowner" ) removeElementData ( v, "cl_vehiclelocked" ) removeElementData ( v, "cl_enginestate" ) setVehicleLocked ( v, false ) setVehicleOverrideLights ( v, 0 ) end end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), initCarLocks ) addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource () ), initCarLocks ) function cl_PlayerJoin ( ) bindKey ( source, "l", "down", doToggleLocked ) bindKey ( source, "k", "down", theVehicle ) end addEventHandler ( "onPlayerJoin", getRootElement(), cl_PlayerJoin ) function cl_PlayerQuit ( ) local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerQuit", getRootElement(), cl_PlayerQuit ) function cl_PlayerWasted ( ) local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerWasted", getRootElement(), cl_PlayerWasted ) function cl_VehicleStartEnter ( enteringPlayer, seat, jacked ) local theVehicle = source local theOwner if ( getElementData ( theVehicle, "cl_vehiclelocked" ) == true ) then theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if theOwner ~= false and theOwner ~= enteringPlayer then end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), cl_VehicleStartEnter ) function cl_PlayerDriveVehicle ( player, seat, jacked ) if ( seat == 0 ) then oldVehicle = getElementData ( player, "cl_ownedvehicle" ) if ( (cl_VehicleLocked(source) == true) and (cl_VehicleOwner(source) ~= player) ) then removePedFromVehicle( player ) Err_Msg("este veículo está trancado.", player) return false end cl_SetVehicleOwner ( source, player ) end return true end addEventHandler ( "onVehicleEnter", getRootElement(), cl_PlayerDriveVehicle ) function cl_VehicleRespawn ( exploded ) cl_RemoveVehicleOwner ( source ) end addEventHandler ( "OnVehicleRespawn", getRootElement(), cl_VehicleRespawn ) function cl_VehicleExplode ( ) local theOwner = getElementData ( source, "cl_vehicleowner" ) if ( theOwner ~= false ) then cl_RemoveVehicleOwner ( source ) end end addEventHandler ( "onVehicleExplode", getRootElement(), cl_VehicleExplode ) function cl_SetVehicleOwner ( theVehicle, thePlayer ) local oldVehicle = getElementData ( thePlayer, "cl_ownedvehicle" ) if ( oldVehicle ~= false ) then removeElementData ( theVehicle, "cl_ownedvehicle" ) removeElementData ( theVehicle, "cl_vehicleowner" ) removeElementData ( theVehicle, "cl_vehiclelocked" ) setVehicleLocked ( theVehicle, false ) end setElementData ( theVehicle, "cl_vehicleowner", thePlayer ) setElementData ( theVehicle, "cl_vehiclelocked", false ) setElementData ( thePlayer, "cl_ownedvehicle", theVehicle ) setElementData( theVehicle, "cl_enginestate", true ) end function cl_RemoveVehicleOwner ( theVehicle ) if isElement (theVehicle) then local theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if ( theOwner ~= false ) then removeElementData ( theOwner, "cl_ownedvehicle" ) removeElementData ( theVehicle, "cl_vehicleowner" ) removeElementData ( theVehicle, "cl_vehiclelocked" ) removeElementData ( theOwner, "cl_enginestate" ) end setVehicleLocked ( theVehicle, false ) end end function cl_FlashLights ( thePlayer ) setTimer ( doToggleLights, 300, 4, thePlayer, true ) end function cl_FlashOnce ( thePlayer ) setTimer ( doToggleLights, 300, 2, thePlayer, true ) end function cl_VehicleOwner ( theVehicle ) return getElementData( theVehicle, "cl_vehicleowner" ) end function cl_VehicleLocked ( theVehicle ) return getElementData( theVehicle, "cl_vehiclelocked" ) end function Err_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 200, 0, 10 ) end function Car_Msg ( strout, theVehicle ) numseats = getVehicleMaxPassengers ( theVehicle ) for s = 0, numseats do local targetPlayer = getVehicleOccupant ( theVehicle, s ) if targetPlayer ~= false then outputChatBox ( strout, targetPlayer, 30, 144, 255 ) end end end function Info_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 102, 205, 170 ) end function doToggleLocked ( source ) local theVehicle , strout if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then local vehiclename = getVehicleName ( theVehicle ) if ( getElementData ( theVehicle, "cl_vehiclelocked") == true ) then doUnlockVehicle ( source ) else doLockVehicle ( source ) end else Err_Msg("Erro: Entre em um Veículo Para poder trancar!", source) end end function doLockVehicle ( source ) local theVehicle , strout if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then local vehiclename = getVehicleName ( theVehicle ) if ( getElementData ( theVehicle, "cl_vehiclelocked") == true ) then strout = "Aracın " .. vehiclename .. " Kiliti Acıldı" Err_Msg(strout, source) else setElementData ( theVehicle, "cl_vehiclelocked", true) setVehicleLocked ( theVehicle, true ) Car_Msg( "Veículo " .. vehiclename .. " Trancou", theVehicle) Info_Msg ( "Veículo " .. vehiclename .. " Você Trancou seu carro.", source ) if ( getVehicleController ( theVehicle ) == false ) then cl_FlashLights ( source ) end end else Err_Msg("3", source) end end function doUnlockVehicle ( source ) local theVehicle, strout if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then local vehiclename = getVehicleName ( theVehicle ) if ( getElementData ( theVehicle, "cl_vehiclelocked") == false ) then strout = "Arac " .. vehiclename .. " Arac Calinabilir" Err_Msg(strout, source) else setElementData ( theVehicle, "cl_vehiclelocked", false) setVehicleLocked ( theVehicle, false ) Car_Msg( "Veículo " .. vehiclename .. " Destrancou", theVehicle ) Info_Msg ( "Veículo " .. vehiclename .. " Você destrancou o carro.", source ) if ( getVehicleController ( theVehicle ) == false ) then cl_FlashOnce ( source ) end end else Err_Msg("2", source) end end function doToggleLights ( source, beep ) local theVehicle if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then -- if he was in one if ( getVehicleOverrideLights ( theVehicle ) ~= 2 ) then setVehicleOverrideLights ( theVehicle, 2 ) if ( beep == true ) then local theElement = theVehicle end else setVehicleOverrideLights ( theVehicle, 1 ) end else Err_Msg("1", source ) end end addCommandHandler ( "lights", doToggleLights, false) addCommandHandler ( "lock", doLockVehicle ) addCommandHandler ( "unlock", doUnlockVehicle ) Link to comment
kieran Posted July 2, 2018 Share Posted July 2, 2018 You have declared "theVehicle" to be a function, it is not a function in your script. Please tell us what you're trying to do with this script, from what I can see you have tried to bind a key to a vehicle, it MUST be a function or a command. Link to comment
DouglaS666 Posted July 2, 2018 Author Share Posted July 2, 2018 11 minutes ago, kieran said: You have declared "theVehicle" to be a function, it is not a function in your script. Please tell us what you're trying to do with this script, from what I can see you have tried to bind a key to a vehicle, it MUST be a function or a command. I downloaded the resource already with this warning. but I have already removed this line and apparently there are no more errors. Link to comment
kieran Posted July 2, 2018 Share Posted July 2, 2018 4 hours ago, DouglaS666 said: I downloaded the resource already with this warning. but I have already removed this line and apparently there are no more errors. This brings me back to the same point, what is your goal with this script? I can't help you until you help me understand what you are trying to do. Link to comment
JeViCo Posted July 4, 2018 Share Posted July 4, 2018 maybe this? bindKey ( source, "k", "down", doToggleLights, false ) Link to comment
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