Jump to content

I am looking for a finished script "Push"


matito6

Recommended Posts

Include NamePart

Example : /push mat or /push o6

for bind u can use /bind "key" (example p) "name" (example youself) = /bind p mati

Enjoy (server-side)

  
function pushim (thePlayer, commandName, ...) 
     player = findPlayer(...) 
      if not player then 
        outputChatBox("* /push: player not found", thePlayer) 
      elseif isPedInVehicle(player) then 
        local vehicle = getPedOccupiedVehicle(player) 
        x,y,z = getElementVelocity(vehicle) 
        setElementVelocity ( vehicle, x, y, z+0.30) 
        outputChatBox( getPlayerName(thePlayer)..  " Push "  ..getPlayerName(player), getRootElement(), 255, 255, 0, true) 
   end 
    
  end 
   
   addCommandHandler("push", pushim) 
  
   function findPlayer(namepart) 
    for i, player in ipairs(getElementsByType("player")) do 
        local name = getPlayerName(player) 
        if string.find(name:lower(), namepart:lower(), 1, true) then 
            return player, name 
             
        end 
    end 
    return false 
end 
  

Link to comment

That will not work with hex codes, e.g: Player's name will be GT#ff0000X and you will write /push GTX. This will not work.

You can use that:

  
function findPlayer(namepart) 
    local player = getPlayerFromName(namepart) 
    if player then 
        return player 
    end 
    for _,player in ipairs(getElementsByType("player")) do 
        if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), namepart:lower(), 1, true) then 
            return player 
        end 
    end 
return false 
end 
  
  

Link to comment
function pushim (thePlayer, commandName, ...) 
    local player = findPlayer(...) 
    if (not player) then 
        outputChatBox("* /push: player not found", thePlayer) 
        return 
    end 
    if isPedInVehicle(player) then 
        local vehicle = getPedOccupiedVehicle(player) 
        x,y,z = getElementVelocity(vehicle) 
        setElementVelocity ( vehicle, x, y, z+0.30) 
        outputChatBox( getPlayerName(thePlayer)..  " Push "  ..getPlayerName(player), getRootElement(), 255, 255, 0, true) 
    end    
end 
addCommandHandler("push", pushim) 
  
  
function findPlayer(namepart) 
    local player = getPlayerFromName(namepart) 
    if player then 
        return player 
    end 
    for _,player in ipairs(getElementsByType("player")) do 
        if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), namepart:lower(), 1, true) then 
            return player 
        end 
    end 
return false 
end 

Link to comment

meta.xml well done but will not turn on the script. What wrong have I done? I give what I have written in .lua :):

  
function pushim (thePlayer, commandName, ...) 
     player = findPlayer(...) 
      if not player then 
        outputChatBox("* /push: player not found", thePlayer) 
      elseif isPedInVehicle(player) then 
        local vehicle = getPedOccupiedVehicle(player) 
        x,y,z = getElementVelocity(vehicle) 
        setElementVelocity ( vehicle, x, y, z+0.30) 
        outputChatBox( getPlayerName(thePlayer)..  " Push "  ..getPlayerName(player), getRootElement(), 255, 255, 0, true) 
   end 
    
  end 
  
   addCommandHandler("push", pushim) 
  
   function findPlayer(namepart) 
    for i, player in ipairs(getElementsByType("player")) do 
        local name = getPlayerName(player) 
        if string.find(name:lower(), namepart:lower(), 1, true) then 
            return player, name 
            
        end 
    end 
    return false 
end 

Edit: as part of the console, push start, writes: Resource could not be found, what I did wrong!

Link to comment

still the same (Resource could not be found) will help? I do not know how to do it, and I care about this :) why is not working: (?

@Solidsnake14 Could you do me this script? Please, I'm green at this: (

Edit: guys! script to push off, but it does not work when you type /push Euro, you know why?

Link to comment

Use this one:

function pushim (thePlayer, commandName, ...) 
    local player = findPlayer(...) 
    if (not player) then 
        outputChatBox("* /push: player not found", thePlayer) 
        return 
    end 
    if isPedInVehicle(player) then 
        local vehicle = getPedOccupiedVehicle(player) 
        x,y,z = getElementVelocity(vehicle) 
        setElementVelocity ( vehicle, x, y, z+0.30) 
        outputChatBox( getPlayerName(thePlayer)..  " Push "  ..getPlayerName(player), getRootElement(), 255, 255, 0, true) 
    end   
end 
addCommandHandler("push", pushim) 
  
function findPlayer(namepart) 
    local player = getPlayerFromName(namepart) 
    if player then 
        return player 
    end 
    for _,player in ipairs(getElementsByType("player")) do 
        if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), namepart:lower(), 1, true) then 
            return player 
        end 
    end 
return false 
end 

Link to comment

Let me give you the contents of .xml file and .lua

xml :

    "Euro" type="script" name="push" /> 
    "meta.xml" type="server"/> 
    

Lua :

function pushim (thePlayer, commandName, ...) 
    local player = findPlayer(...) 
    if (not player) then 
        outputChatBox("* /push: player not found", thePlayer) 
        return 
    end 
    if isPedInVehicle(player) then 
        local vehicle = getPedOccupiedVehicle(player) 
        x,y,z = getElementVelocity(vehicle) 
        setElementVelocity ( vehicle, x, y, z+0.30) 
        outputChatBox( getPlayerName(thePlayer)..  " Push "  ..getPlayerName(player), getRootElement(), 255, 255, 0, true) 
    end   
end 
addCommandHandler("push", pushim) 
  
function findPlayer(namepart) 
    local player = getPlayerFromName(namepart) 
    if player then 
        return player 
    end 
    for _,player in ipairs(getElementsByType("player")) do 
        if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), namepart:lower(), 1, true) then 
            return player 
        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...