Jump to content

[HELP] Give ACL to bindKey


Recommended Posts

Posted (edited)

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
Posted

You are mixing server-side functions with a client-side script.

These functions (which you included in the code) are server-side only:

getAccountName
getPlayerAccount
isObjectInACLGroup
aclGetGroup

 

Please do not PM me with scripting related question nor support, use the forums instead.

  • Moderators
Posted (edited)

Also, line 4 is client-side

addEventHandler("onClientResourceStart", resourceRoot, initBind)

 

The variable localPlayer is also client-side.

Edited by Lord Henry

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted

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

 

 

 

 

من أراد الفشل عليه بالنجاح

Posted
50 minutes ago, Naruto Edits said:

<script src="jump.lua" type="client" cache="false"/>

also replace that with this 

<script src="jump.lua" type="server"/>

 

من أراد الفشل عليه بالنجاح

Posted
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

من أراد الفشل عليه بالنجاح

  • Moderators
Posted (edited)

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

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