Jump to content

[Script] Change bindkey to cmd


MitnickP56

Recommended Posts

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

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
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);92111931789484045974.png

-||- (server-side): 13957605843478759091.png

Link to comment

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
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);92111931789484045974.png

-||- (server-side): 13957605843478759091.png

getLocalPlayer() -- client side not use for server side 
and addCommandHandler --# in Client parameter Player == nil or arg1 , use getLocalPlayer 

Link to comment
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

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

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

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

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