Jump to content

Small problem


DrifteR

Recommended Posts

Hi ,

Can someone help me with this?

local x,y,z,rx,ry,rz= 0,15,15,0,0,0 
  
function createpirateship(cmd) 
    local lx,ly,lz = getElementPosition(getLocalPlayer())  
    lx = lx + 5  
  
    veh = createVehicle( 484, lx, ly, lz)  
    base = createObject( 8493, 2,2,2)  
    setElementCollisionsEnabled ( base, false )  
     
    attachElements ( base, veh,  x,y,z,rx,ry,rz)  
end 
  
function rotateIt(cmd, addZ) 
    if(addZ) then 
        rz=rz+addZ 
        setElementAttachedOffsets (base,x,y,z,rx,ry,rz)  
    end 
end 
  
addCommandHandler("pirate", createpirateship) 
addCommandHandler("rotate", rotateIt) 

The problem is that after i created the vehicle , i can't drive it.

I know im a noob (started to learn lua 2 days ago)

Can someone help me correct this problem , and is there any "GetCurrentVehicle" to attach the objects on the vehicle while i'm in it?

Link to comment

Yup, as Zango said - create vehicle on server side.

You will need (on clientside)

triggerServerEvent

and on server:

addEvent

addEventHandler

And for getting vehicle (also remember to check seat - to be sure if player is DRIVING vehicle, not seating as passenger)

getPedOccupiedVehicle

Useful links:

Functions lists:

https://wiki.multitheftauto.com/wiki/Cli ... _Functions

https://wiki.multitheftauto.com/wiki/Ser ... _Functions

Events:

https://wiki.multitheftauto.com/wiki/Cli ... ing_Events

https://wiki.multitheftauto.com/wiki/Ser ... ing_Events

Tutorial:

https://wiki.multitheftauto.com/wiki/Scr ... troduction

And wiki in general :)

https://wiki.multitheftauto.com/wiki/Main_Page

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