Jump to content

[HELP] Unique vehicle replaced for ONE veh.


Recommended Posts

Hello, I want to create a test script for unique vehicle using "engineRequestModel". I have problem, because i don't know how I can give vehicle ID from c.side to s.side.

 

c. side script.

[lua]

function sultan_create (heatchback)

    id_sultan = engineRequestModel("vehicle", 560)
    local txd = engineLoadTXD("sultan.txd")
    engineImportTXD(txd, id_sultan)

    local dff = engineLoadDFF("sultan.dff")
    engineReplaceModel(dff, id_sultan, true)
    outputChatBox("created")
end

addEvent( "sultan:heatchback", true )
addEventHandler( "sultan:heatchback", localPlayer, sultan_create, id_sultan, heatchback )

[/lua]

 

s. side script:

[lua]
addCommandHandler ( "sultan_heachback",  
function (thePlayer ) 
    local x,y,z = getElementPosition(thePlayer)
    heatchback = createVehicle(560, x, y+2.5, z+0.5, 0, 0, 0)
    triggerClientEvent ( thePlayer, "sultan:heatchback", thePlayer, id_sultan, heachback)
end) 

[/lua]

Link to comment

Hello Polak0,Unfortunately, you cannot create a rideable vehicle on the server side at the moment, but you can do it on the client side.

 

local id_sultan
addEventHandler("onClientResourceStart", resourceRoot,
    function()
       id_sultan = engineRequestModel("vehicle", 411)
       local txd = engineLoadTXD("sultan.txd")
       engineImportTXD(txd, id_sultan)

       local dff = engineLoadDFF("sultan.dff")
       engineReplaceModel(dff, id_sultan)
       outputDebugString("Custom sultan id: "..id_sultan)
    end
)

addCommandHandler ("sultan",
function () 
    triggerServerEvent("requestCreateCustomSultan", root, id_sultan)
end) 


addEvent("createCustomSultan", true)
addEventHandler("createCustomSultan", root,
    function()
       createVehicle(id_sultan, 0, 0, 3)
    end
)

 

this is sample code.

server :

addEvent("requestCreateCustomSultan", true)
addEventHandler("requestCreateCustomSultan", root,
    function()
       triggerClientEvent(root, "createCustomSultan", root)
    end
)

 

Edited by eoL|Shady
  • Like 1
Link to comment
  • 3 weeks later...
On 15/01/2022 at 01:17, The_GTA said:

Sounds like you want to use this MTA library resource:

How about you try creating a script that uses this resource by @FernandoMTA?

I heard about this script, but I don't wanna use it. I want to create script just for one vehicle that I can drive, spawn whenever I want - and I don't know how I can do it.

I tried something with setElementModel, but it still not working.

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