Jump to content

[Solved] Custom "push"


HunT

Recommended Posts

Hi all.i want edit the script push in /push "name player" "ammount position z"

This is normaly script push /push "name player"

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) 
     

Ok i want edit this with this example (raw :| )

1 = setElementVelocity ( vehicle, x, y, z+0.10) or only 1 = (vehicle, x, y, z+0.10)

2 = setElementVelocity ( vehicle, x, y, z+0.30)

3 = setElementVelocity ( vehicle, x, y, z+0.50)

etc . . .

With command /push "name" 2 . . . and call " setElementVelocity ( vehicle, x, y, z+0.30) "

Its possible? For me is very hard this :oops:

Tnx :fadein:

Edited by Guest
Link to comment
local pushData = {[1] = "0.10", [2] = "0.20", [3] = "0.30"} 
  
function pushim (thePlayer, commandName, id, ...) 
     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) 
        local data = tonumber(pushData[tonumber(id)]) 
        setElementVelocity ( vehicle, x, y, z+data) 
        outputChatBox( getPlayerName(thePlayer)..  " Push "  ..getPlayerName(player), getRootElement(), 255, 255, 0, true) 
       end 
end 
addCommandHandler("push", pushim) 

Link to comment

Assuming you can find the playername without passing all the command arguments to findPlayer:

function pushim (thePlayer, commandName, namepart, ammount) 
     player = findPlayer(namepart) 
      if not player then 
        outputChatBox("* /push: player not found", thePlayer) 
      elseif isPedInVehicle(player) then 
        local vehicle = getPedOccupiedVehicle(player) 
        x,y,z = getElementVelocity(vehicle) 
        if tonumber(amount) then 
              amount = tonumber(amount) - 1 
        else 
              amount = 0 
        end 
        z = z + 0.10 + 0.20 * amount 
        setElementVelocity ( vehicle, x, y, z ) 
        outputChatBox( getPlayerName(thePlayer)..  " Push "  ..getPlayerName(player), getRootElement(), 255, 255, 0, true) 
   end 
    
  end 
   
   addCommandHandler("push", pushim) 
  
   function findPlayer(namepart) 
     

Link to comment

The Castillo version is awesome :mrgreen: but i change the "id" to "ammount" and "..." with "namepart" . . .why without (namepart) no work :|

now is perfect :lol:

Very Tnx Castillo & SDK fast help 8)

This :

local pushData = {[1] = "0.10", [2] = "0.20", [3] = "0.30"} 
     
    function pushim (thePlayer, commandName, namepart, ammount) 
         player = findPlayer(namepart) 
          if not player then 
            outputChatBox("* /push: player not found", thePlayer) 
          elseif isPedInVehicle(player) then 
            local vehicle = getPedOccupiedVehicle(player) 
            x,y,z = getElementVelocity(vehicle) 
           local data = tonumber(pushData[tonumber(ammount)]) 
           setElementVelocity ( vehicle, x, y, z+data) 
           outputChatBox( getPlayerName(thePlayer)..  " Push "  ..getPlayerName(player), getRootElement(), 255, 255, 0, true) 
          end 
   end 
   addCommandHandler("push", pushim) 
  
   function findPlayer(namepart) 

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