BulgariaRoam Posted March 23, 2018 Share Posted March 23, 2018 How can i completly disable warping into vehicle. so when someone try to warp into vehicle it will warp him as normal, not inside vehicle? if anyone know, please help me. thanks. function warpMe(targetPlayer) if getElementData ( source, "attached" ) then return end if isPedDead(source) then spawnMe() end local vehicle = getPedOccupiedVehicle(targetPlayer) if not vehicle then -- target player is not in a vehicle - just warp next to him local x, y, z = getElementPosition(targetPlayer) clientCall(source, 'setPlayerPosition', x + 2, y, z) else -- target player is in a vehicle - warp into it if there's space left if getPedOccupiedVehicle(source) then --removePlayerFromVehicle(source) outputChatBox('Get out of your vehicle first.', source) return end local numseats = getVehicleMaxPassengers(vehicle) for i=0,numseats do if not getVehicleOccupant(vehicle, i) then if isPedDead(source) then local x, y, z = getElementPosition(vehicle) spawnMe(x + 4, y, z + 1) end warpPedIntoVehicle(source, vehicle, i) return end end outputChatBox('No free seats left in ' .. getPlayerName(targetPlayer) .. '\'s vehicle.', source, 255, 0, 0) end local interior = getElementInterior(targetPlayer) setElementInterior(source, interior) setCameraInterior(source, interior) end Link to comment
Skully Posted March 23, 2018 Share Posted March 23, 2018 So you want to teleport them outside of the vehicle next to it? Link to comment
BulgariaRoam Posted March 23, 2018 Author Share Posted March 23, 2018 next to the vehicle, as he regularly do. because teleporting in vehicles not good. if anyone can help me Link to comment
Skully Posted March 24, 2018 Share Posted March 24, 2018 (edited) Try this. (Assuming spawnMe is a function which exists and sets the player's position.) function warpMe(targetPlayer) if getElementData ( source, "attached" ) then return end if isPedDead(source) then spawnMe() end local vehicle = getPedOccupiedVehicle(targetPlayer) if not vehicle then -- target player is not in a vehicle - just warp next to him local x, y, z = getElementPosition(targetPlayer) clientCall(source, 'setPlayerPosition', x + 2, y, z) else -- target player is in a vehicle - warp into it if there's space left if getPedOccupiedVehicle(source) then --removePlayerFromVehicle(source) outputChatBox('Get out of your vehicle first.', source) return end local x, y, z = getElementPosition(vehicle) spawnMe(x, y + 3, z + 1) end local interior = getElementInterior(targetPlayer) setElementInterior(source, interior) setCameraInterior(source, interior) end Edited March 24, 2018 by Skully 1 Link to comment
BulgariaRoam Posted March 24, 2018 Author Share Posted March 24, 2018 Smart solution. Thanks working good! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now