DeiwnEdits Posted May 30, 2019 Posted May 30, 2019 (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 May 30, 2019 by Naruto Edits
DNL291 Posted May 30, 2019 Posted May 30, 2019 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 Lord Henry Posted May 30, 2019 Moderators Posted May 30, 2019 (edited) Also, line 4 is client-side addEventHandler("onClientResourceStart", resourceRoot, initBind) The variable localPlayer is also client-side. Edited May 30, 2019 by Lord Henry Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! 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.
#BrosS Posted May 30, 2019 Posted May 30, 2019 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 ); 1 “من أراد الفشل عليه بالنجاح”
DeiwnEdits Posted May 31, 2019 Author Posted May 31, 2019 (edited) @#BrosS jump.lua:4 unexpected symbol near ' Edited May 31, 2019 by Naruto Edits
#BrosS Posted May 31, 2019 Posted May 31, 2019 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"/> “من أراد الفشل عليه بالنجاح”
DeiwnEdits Posted May 31, 2019 Author Posted May 31, 2019 (edited) @#BrosS I changed but same error so error not changed Edited May 31, 2019 by Naruto Edits
#BrosS Posted May 31, 2019 Posted May 31, 2019 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 also it's been happening alot when i copy codes from here they don't work unless i manually rewrite them “من أراد الفشل عليه بالنجاح”
Moderators Patrick Posted May 31, 2019 Moderators Posted May 31, 2019 (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 May 31, 2019 by stPatrick 1 community profile | map converters | map images | pDownloader | pAttach | model encrypter
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