Jump to content

[HELP]Push Script


SparkzZ

Recommended Posts

i did a Push Script But i dosn't work

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.5, 0+0.2) 
                outputChatBox(getPlayerName(p).." pushes "..getPlayerName(pushPlayer).." up!") 
            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's the probleme ? :(

Link to comment

Firstly, this should go in the Scripting section.

I only can see that you aren't pushing him up at all, so I've changed some things on it.

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, speedX, speedY, speedZ+0.2) 
                outputChatBox(getPlayerName(p).." pushes "..getPlayerName(pushPlayer).." up!") 
            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 

Link to comment
There is arguments for colors.
outputChatBox("RED", root, 255, 0, 0) 

255 , 0 , 0

Represents the color which will be red in this case.

Read the arguments of every function @ the wiki : https://wiki.multitheftauto.com/wiki/Main_Page

now it's outputChatBox("getPlayerName(p).." pushes "..getPlayerName(pushPlayer).." up!", root, 255, 0, 0)

after i did this script not working :(

can u give me Script with colors coz i tryied but when i put "getPlayerName(p).." with colors didn't work :(

if i removed " it works

Edited by Guest
Link to comment

k

/debugscript 3

WARNING:Loading Script Failed:push/push.lua:9: ')' exepted near 'pushes'

Script now

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 
 

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