Jump to content

[HELP] Give ACL to bindKey


Recommended Posts

Hi guys , I ask question. What's false?

function initBind()
    bindKey("lshift", "down", jumpKey)
end
addEventHandler("onClientResourceStart", resourceRoot, initBind)

function jumpKey()
    if not isPedInVehicle(localPlayer) then return end
    local vehicle = getPedOccupiedVehicle(localPlayer)
    local accName = getAccountName ( getPlayerAccount ( player ) )
  	if vehicle and getVehicleController(vehicle) == localPlayer  and isObjectInACLGroup("user."..accName, aclGetGroup ( "Admin" )) then
        local vehType = getVehicleType(vehicle)
        if vehType == "Plane" or vehType == "Helicopter" then return end
        local sx, sy, sz = getElementVelocity(vehicle)
        setElementVelocity(vehicle, sx, sy, sz + 0.33)
    end    
end

Meta.xml

<meta>
    <info type="script" version="1.0.2" name="Jump with vehicles" author="Dutchman101"/>
    <script src="jump.lua" type="client" cache="false"/>
</meta>

 

Edited by Naruto Edits
Link to comment

use this on serverside

addEventHandler("onResourceStart",resourceRoot,
function ()
	for _, player in ipairs (getElementsByType("player")) do 
		bindKey(player,"lshift", "down",
			function()
				if not isPedInVehicle(player) then return end
                 local vehicle = getPedOccupiedVehicle(player)
                  local accName = getAccountName ( getPlayerAccount ( player ) )
  	                if vehicle and getVehicleController(vehicle) == player  and isObjectInACLGroup("user."..accName, aclGetGroup ( "Admin" )) then
                  local vehType = getVehicleType(vehicle)
                 if vehType == "Plane" or vehType == "Helicopter" then return end
               local sx, sy, sz = getElementVelocity(vehicle)
             setElementVelocity(vehicle, sx, sy, sz + 0.33)
				end
			end
		);
	end
end
);

 

 

 

 

  • Like 1
Link to comment
13 hours ago, Naruto Edits said:

@#BrosS I changed but same error so error not changed

 

try it again

addEventHandler("onResourceStart",resourceRoot,
function ()
	for _, player in ipairs (getElementsByType("player")) do 
		bindKey(player,"lshift", "down",
			function()
				if not isPedInVehicle(player) then return end
                 local vehicle = getPedOccupiedVehicle(player)
                  local accName = getAccountName ( getPlayerAccount ( player ) )
  	                if vehicle and getVehicleController(vehicle) == player  and isObjectInACLGroup("user."..accName, aclGetGroup ( "Admin" )) then
                  local vehType = getVehicleType( vehicle )
                 if vehType == "Plane" or vehType == "Helicopter" then return end
               local sx, sy, sz = getElementVelocity( vehicle )
              setElementVelocity(vehicle, sx , sy, sz +0.33)
             --outputChatBox("executed")
			end
		end)
	end
end)

i have no idea what happened I just rewrote the code getVehicleType

5egv1eK.png

also it's been happening alot when i copy codes from here they don't work unless i manually rewrite them

Link to comment
  • Moderators

Fixed code

-- SERVER SIDE

function jumpWithVehicle(playerWhoPressedTheButton)
	if not isPedInVehicle(playerWhoPressedTheButton) then return end -- kill function if player is not in vehicle
	local vehicleElement = getPedOccupiedVehicle(playerWhoPressedTheButton) -- we know player is in a vehicle, so get the vehicle's element
	if getVehicleController(vehicleElement) ~= playerWhoPressedTheButton then return end -- check player is who drive this vehicle (if not -> kill function)
	
	local playerAccountName = getAccountName(getPlayerAccount(playerWhoPressedTheButton)) -- get the player's account name
	if isObjectInACLGroup("user."..playerAccountName, aclGetGroup("Admin")) then -- check is player in the 'Admin' ACL group.
		local vehicleType = getVehicleType(vehicleElement)
		if vehicleType == "Plane" or vehicleType == "Helicopter" then return end -- kill function if the vehicle is a Plane/Helicopter
		
        local velocity_x, velocity_y, velocity_z = getElementVelocity(vehicleElement)
        setElementVelocity(vehicleElement, velocity_x, velocity_y, velocity_z + 0.33) -- boost vehicle's Z velocity
	end
end

addEventHandler("onResourceStart", resourceRoot, function()
	for _, onlinePlayer in ipairs(getElementsByType("player")) do
		bindKey(onlinePlayer, "lshift", "down", jumpWithVehicle)
	end
end)
addEventHandler("onPlayerJoin", root, function()
	bindKey(source, "lshift", "down", jumpWithVehicle)
end)

 

Edited by stPatrick
  • Thanks 1
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...