Jump to content

[help] Push Player


Recommended Posts

I want when I type / push (playername) the player chosen to come to me

My Client:

addCommandHandler("push", 
    function(p, c, t) 
        local pushPlayer = findPlayer(t) 
        if pushPlayer then 
            local pushVehicle = getPedOccupiedVehicle(pushPlayer) 
            if pushVehicle then 
                local speedX, speedY, speedZ = getElementVelocity(pushVehicle) 
                setElementVelocity(pushVehicle, 0, 0, 0+0.2) 
                outputChatBox("getPlayerName(p).." pushes "..getPlayerName(pushPlayer).." up!", root, 255, 0, 0) 
end 
       end 
   end 
) 
  
function findPlayer(name) 
   local name = name:lower() 
   for i, p in ipairs(getElementsByType("player")) do 
       local fullname = getPlayerName(p):lower() 
       if string.find(fullname:gsub("#%x%x%x%x%x%x", ""), name, 1, true) then 
           return p 
       end   
   end 
   return false 
end 
 

What did this wrong?

Link to comment

Replace this:

outputChatBox("getPlayerName(p).." pushes "..getPlayerName(pushPlayer).." up!", root, 255, 0, 0) 
 

With this:

outputChatBox(getPlayerName(p).." pushes "..getPlayerName(pushPlayer).." up!", root, 255, 0, 0) 

Link to comment
addCommandHandler("push", 
    function(p, c, t) 
        local pushPlayer = findPlayer(t) 
        if pushPlayer then 
            local pushVehicle = getPedOccupiedVehicle(pushPlayer) 
            if pushVehicle then 
                local speedX, speedY, speedZ = getElementVelocity(pushVehicle) 
                setElementVelocity(pushVehicle, 0, 0,0.2) 
               outputChatBox(" "..getPlayerName(p).." pushes "..getPlayerName(pushPlayer).." up!", root, 255, 0, 0) 
            end 
        end 
    end 
) 
  
function findPlayer(name) 
   local name = name:lower() 
   for i, p in ipairs(getElementsByType("player")) do 
       local fullname = getPlayerName(p):lower() 
       if string.find(fullname:gsub("#%x%x%x%x%x%x", ""), name, 1, true) then 
           return p 
       end   
   end 
   return false 
end 

Edited by Guest
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...