Jump to content

Gotocar


Woovie

Recommended Posts

I am working on a Gotocar. I think I am probably messing up. It has been written based on the warpto command and a command OffRoader23 wrote to do teleports.

Here is what I have done so far. I have VERY little insight with LUA. But here is what I have.

function consoleGoToCar ( player, commandName, player2nick ) 
local player2 = getPlayerFromNick ( player2nick ) 
local vehicle = getPlayerOccupiedVehicle(player) 
    if vehicle ~= nil then 
        if player == getVehicleOccupant(vehicle) then -- check if player is driver 
            setElementPosition(vehicle, x, y, z+1.5) 
            setElementVelocity(vehicle, 0, 0, 0) 
            setVehicleTurnVelocity(vehicle, 0, 0, 0) 
            setVehicleRotation(vehicle, 0, 0, r) 
            setTimer(stopCar, 50, 4, vehicle, x, y, z, r) 
                if ( isPlayerInVehicle ( player2 ) ) then 
                            x, y, z = getElementPosition ( player2 ) 
                            r = getPlayerRotation ( player2 ) then 
                                setElementPosition(vehicle, x+3, y+3, z+1.5) 
                                setElementRotation(vehicle, r) 
            end 
        end 
    end 
end 
function stopCar(vehicle, x, y, z, r) 
    setElementPosition(vehicle, x, y, z+1.5) 
    setElementVelocity(vehicle, 0, 0, 0) 
    setVehicleTurnVelocity(vehicle, 0, 0, 0) 
    setVehicleRotation(vehicle, 0, 0, r) 
    fixVehicle(vehicle) 
end 

Edited by Guest
Link to comment

Nearly everything needs to have an end, the "end" name is just a way of letting LUA Know that "Between Here and the End is a ".

The can be alot of things, such as a function, an if statement, for loops, while loops, all stuff like that.

So, if you have a IF Statement, you need to close it off with an end

  
if ( this == that )  
   --Do Something 
end 
  

Same with loops

  
for k=1, 100 do 
   outputChatBox ( "Current Number: " .. k ) 
end 
  

List goes on and on really.

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