Jump to content

Clientside warpPedIntoVehicle with players


Bonsai

Recommended Posts

Posted

Hey,

I want to move some parts of my script to be completly clientside as it doesn't need to be serverside.

So instead of creating a vehicle on the server, I thought about creating it on the client. 

But warpPedIntoVehicle does not allow to warp the player, who is a serverside element, into the clientside vehicle.

Therefore I need to trigger a server event just to create the vehicle and warp the player into it, even though the server has nothing much to do with it.

Since its a race gamemode, the player cannot just enter the vehicle manually.

 

Does anyone know a workaround for this problem?

 

Bonsai

Posted
16 minutes ago, loki2143 said:

If you create a vehicle on the client, only that client can see it other players won't.

Yes, but thats okay.

Thats actually what I want. There is no need to sync it between players, and make sure it doesn't keep existing on the server forever.

Only the local player needs it.

Posted (edited)

I don't know is it driveable but my experience with it that you can't enter it (with enter). It's bulletproof (zero damage) and it's not moveable (like it's freezed).
Looks like it's just an object if it's created on client side.

Edited by dugasz1
Posted

Well.. if the problem is the vehicle in serverside, you can try to create it in clientside, then send it as a parameter(also the player you want to warp) with triggerServerSide, and use the warpPedIntoVehicle function, using the parameters that you receive

Posted (edited)
5 hours ago, dugasz1 said:

I don't know is it driveable but my experience with it that you can't enter it (with enter). It's bulletproof (zero damage) and it's not moveable (like it's freezed).
Looks like it's just an object if it's created on client side.

I don't know if this is true or not, but you can try what @dugasz1 said. Also, if you want to warp the player into vehicle you can use the following:

-- client --
function createLocalVehicle()
  local vehicle = createVehicle(model, x, y, z)
  triggerServerEvent("onClientWarpRequest", localPlayer, vehicle)
end 
-- handler here

-- server --
function warpPlayerToLocalVehicle(vehicle)
  if isElement(vehicle) then
    warpPedIntoVehicle(source, vehicle)
  end  
end  
addEvent("onClientWarpRequest", true)
addEventHandler("onClientWarpRequest", root, warpPlayerToLocalVehicle)  
  

Edit: I just see warpPedIntoVehicle is a shared function, what are you talking about?

Edited by Gravestone
Posted

I'm talking about this:

" Available client side from 1.3.1 (It will only work with client side vehicles and peds) "

A player element (not a ped) is a serverside element.

Therefore I need to create the vehicles serverside to be able to warp a player into it.

And that is unnecessary since the vehicle doesn't need to exist on the server.

Posted (edited)

Well it's very simple. If you want to warp a player into a vehicle then you have to create it and warp the player in it on the server side. There's no other way.

It might be unnecessary for the vehicle to exist server side but so what? It won't affect the server in any way (well it does but it's negligible).

If you really don't want others to see the vehicle, use setElementVisibleTo. <-- That actually doesn't work with vehicles.

Edited by MIKI785
Posted

warpPlayerIntoVehicle is a deprecated function, you'll have to use warpPedIntoVehicle in combination with createVehicle at server side, else, I don't there's a way through which you can create vehicle client side and warp the ped server sided. (Already tried)

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