MitnickP56 Posted January 30, 2016 Share Posted January 30, 2016 Hi, I found code: bindKey ( "lshift","down", function () local vehicle = getPedOccupiedVehicle(localPlayer) if (isVehicleOnGround( vehicle ) == true) then local sx,sy,sz = getElementVelocity ( vehicle ) setElementVelocity( vehicle ,sx, sy, sz+0.3 ) end end ) I'm trying to change it to command. (addCommandHandler) I can't do it - someone can help me ? cmd: flyman nick Link to comment
Mann56 Posted January 30, 2016 Share Posted January 30, 2016 function fly(thePlayer) local vehicle = getPedOccupiedVehicle(localPlayer) if (isVehicleOnGround( vehicle ) == true) then local sx,sy,sz = getElementVelocity ( vehicle ) setElementVelocity( vehicle ,sx, sy, sz+0.3 ) end end addCommandHandler("flyman",fly) Link to comment
MitnickP56 Posted January 30, 2016 Author Share Posted January 30, 2016 Working, rly thanks. Link to comment
MitnickP56 Posted January 30, 2016 Author Share Posted January 30, 2016 You're welcome Ehh, not working 100%. Look 2 players. test1 and test2 when test1 write /flyman test2 -- then jumping test1 not test2 . What I need to change ? Link to comment
Mann56 Posted January 30, 2016 Share Posted January 30, 2016 local player was used in your script so i thought it was for the player itself... I suggest you to make it server sided... like this -> function fly(cmd,targetPlayer) local vehicle = getPedOccupiedVehicle(targetPlayer) if (isVehicleOnGround( vehicle ) == true) then local sx,sy,sz = getElementVelocity ( vehicle ) setElementVelocity( vehicle ,sx, sy, sz+0.3 ) end end addCommandHandler("flyman",fly) But beware, the player must be in a car to execute this! Link to comment
MitnickP56 Posted January 30, 2016 Author Share Posted January 30, 2016 local player was used in your script so i thought it was for the player itself... I suggest you to make it server sided... like this -> function fly(cmd,targetPlayer) local vehicle = getPedOccupiedVehicle(targetPlayer) if (isVehicleOnGround( vehicle ) == true) then local sx,sy,sz = getElementVelocity ( vehicle ) setElementVelocity( vehicle ,sx, sy, sz+0.3 ) end end addCommandHandler("flyman",fly) But beware, the player must be in a car to execute this! code: function fly(cmd,targetPlayer) local vehicle = getPedOccupiedVehicle(targetPlayer) local localPlayerName = getPlayerName(getLocalPlayer()) if (isVehicleOnGround( vehicle ) == true) then local sx,sy,sz = getElementVelocity ( vehicle ) setElementVelocity( vehicle ,sx+0.5, sy, sz+0.6 ) outputChatBox(localPlayerName.." #CFECEC was KICKED #ffcc33UP UP #00ff33", 213, 255, 255, true) end end addCommandHandler("flyman",fly) debugscript (client-side); -||- (server-side): Link to comment
Mann56 Posted January 30, 2016 Share Posted January 30, 2016 Server side function fly(cmd,targetPlayer) local name = getPlayerFromName(targetPlayer) local vehicle = getPedOccupiedVehicle(name) if (isVehicleOnGround( vehicle ) == true) then local sx,sy,sz = getElementVelocity ( vehicle ) setElementVelocity( vehicle ,sx+0.5, sy, sz+0.6 ) end end addCommandHandler("flyman",fly) Link to comment
LoOs Posted January 30, 2016 Share Posted January 30, 2016 local player was used in your script so i thought it was for the player itself... I suggest you to make it server sided... like this -> function fly(cmd,targetPlayer) local vehicle = getPedOccupiedVehicle(targetPlayer) if (isVehicleOnGround( vehicle ) == true) then local sx,sy,sz = getElementVelocity ( vehicle ) setElementVelocity( vehicle ,sx, sy, sz+0.3 ) end end addCommandHandler("flyman",fly) But beware, the player must be in a car to execute this! code: function fly(cmd,targetPlayer) local vehicle = getPedOccupiedVehicle(targetPlayer) local localPlayerName = getPlayerName(getLocalPlayer()) if (isVehicleOnGround( vehicle ) == true) then local sx,sy,sz = getElementVelocity ( vehicle ) setElementVelocity( vehicle ,sx+0.5, sy, sz+0.6 ) outputChatBox(localPlayerName.." #CFECEC was KICKED #ffcc33UP UP #00ff33", 213, 255, 255, true) end end addCommandHandler("flyman",fly) debugscript (client-side); -||- (server-side): getLocalPlayer() -- client side not use for server side and addCommandHandler --# in Client parameter Player == nil or arg1 , use getLocalPlayer Link to comment
Mann56 Posted January 30, 2016 Share Posted January 30, 2016 getLocalPlayer() -- client side not use for server side and addCommandHandler --# in Client parameter Player == nil or arg1 , use getLocalPlayer Corrected it! Made whole server side. Link to comment
LoOs Posted January 30, 2016 Share Posted January 30, 2016 Server side function fly(cmd,targetPlayer) local name = getPlayerFromName(targetPlayer) local vehicle = getPedOccupiedVehicle(name) if (isVehicleOnGround( vehicle ) == true) then local sx,sy,sz = getElementVelocity ( vehicle ) setElementVelocity( vehicle ,sx+0.5, sy, sz+0.6 ) end end addCommandHandler("flyman",fly) getPlayerFromName --# ?? is tragetPlayer return Player not Name Player Delete The Name Value --# Code Edit --# ServerSide function fly(targetPlayer) local vehicle = getPedOccupiedVehicle(targetPlayer) if (isVehicleOnGround( vehicle ) == true) then local sx,sy,sz = getElementVelocity ( vehicle ) setElementVelocity( vehicle ,sx+0.5, sy, sz+0.6 ) end end addCommandHandler("flyman",fly) Link to comment
1LoL1 Posted January 30, 2016 Share Posted January 30, 2016 Try this: addCommandHandler("flyman", function (target, command) local target = getPlayerFromName(target) if (target) then if (isVehicleOnGround(getPedOccupiedVehicle(target)) == true) then local sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(target)) setElementVelocity(getPedOccupiedVehicle(target), sx+0.5, sy, sz+0.6 ) end end end) Link to comment
LoOs Posted January 30, 2016 Share Posted January 30, 2016 Try this: addCommandHandler("flyman", function (target, command) local target = getPlayerFromName(target) if (target) then if (isVehicleOnGround(getPedOccupiedVehicle(target)) == true) then local sx,sy,sz = getElementVelocity (getPedOccupiedVehicle(target)) setElementVelocity(getPedOccupiedVehicle(target),sx+0.5, sy, sz+0.6 ) end end end) target return player , not name player !!!!!!!! Link to comment
Enargy, Posted January 30, 2016 Share Posted January 30, 2016 addCommandHandler("flyman", function (_,target) local targetElement = getPlayerFromName(tostring(target)) if not targetElement then return end if (isVehicleOnGround(getPedOccupiedVehicle(targetElement)) == true) then local sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(targetElement)) setElementVelocity(getPedOccupiedVehicle(targetElement), sx+0.5, sy, sz+0.6 ) end end) Link to comment
KariiiM Posted January 30, 2016 Share Posted January 30, 2016 Should works, copy the whole code carefully. function fly(_,target) if target then local targetplayer = getPlayerFromParticalName(target) if targetplayer then local vehicle = getPedOccupiedVehicle(targetplayer) if (isVehicleOnGround(vehicle) == true) then local sx, sy, sz = getElementVelocity (vehicle) setElementVelocity( vehicle ,sx+0.5, sy, sz+0.6 ) outputChatBox(getPlayerName(targetplayer).." #CFECEC was KICKED #ffcc33UP UP #00ff33", 213, 255, 255, true) end end end end addCommandHandler("flyman",fly) function getPlayerFromParticalName (name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Link to comment
MitnickP56 Posted January 31, 2016 Author Share Posted January 31, 2016 Should works, copy the whole code carefully. function fly(_,target) if target then local targetplayer = getPlayerFromParticalName(target) if targetplayer then local vehicle = getPedOccupiedVehicle(targetplayer) if (isVehicleOnGround(vehicle) == true) then local sx, sy, sz = getElementVelocity (vehicle) setElementVelocity( vehicle ,sx+0.5, sy, sz+0.6 ) outputChatBox(getPlayerName(targetplayer).." #CFECEC was KICKED #ffcc33UP UP #00ff33", 213, 255, 255, true) end end end end addCommandHandler("flyman",fly) function getPlayerFromParticalName (name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end So, it's working on client-side. outputchatbox is correct but when I wanna use this on other player then he fly 1 meter and back on the road. Link to comment
KariiiM Posted January 31, 2016 Share Posted January 31, 2016 So, it's working on client-side. outputchatbox is correct but when I wanna use this on other player then he fly 1 meter and back on the road. Yes I made it client sided but what do you want? do you want the player fly more than one meter? Link to comment
MitnickP56 Posted January 31, 2016 Author Share Posted January 31, 2016 So, it's working on client-side. outputchatbox is correct but when I wanna use this on other player then he fly 1 meter and back on the road. Yes I made it client sided but what do you want? do you want the player fly more than one meter? No, look. If I using this cmd for urself then I fly good, when I trying to use on other player then this not working. 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