mirror of
https://github.com/jimathy/jim-boarding.git
synced 2026-03-31 06:33:43 -04:00
v2.0 - Jim_bridge + Cam + Cat Support
This commit is contained in:
17
README.md
17
README.md
@@ -1,14 +1,21 @@
|
||||
# ElectricSkateboardFiveM
|
||||
# Jim-Skateboard
|
||||
|
||||
```
|
||||
Electric Skateboard is a script in develop who use a base of the script rd_cars.
|
||||
If you have a supposition of upgrade to add in the script contact me in fiveM forum, my pseudo: 'Super_Chocolatine'.
|
||||
```
|
||||
|
||||
Disclaimer:
|
||||
```
|
||||
This is based originally on ElectricSkateboardFiveM but completely rewritten and changed to handle newer fivem features
|
||||
With the help of `jim_bridge` this also brings more optimization and more features and works on supported frameworks
|
||||
```
|
||||
|
||||
## How to install:
|
||||
1. Place the folder `ElectricSkateboard`` in your resources folder
|
||||
2. Add `start ElectricSkateboard` in your `server.cfg`
|
||||
3. Add the item to your items.lua:
|
||||
1. Install `jim_bridge` from github and add it before this script in your server load order
|
||||
2. Place the folder 'jim-skateboard' in your resources folder
|
||||
3. Add `start jim-skateboard` in your `server.cfg`
|
||||
4. Add the item to your items.lua:
|
||||
```lua
|
||||
["skateboard"] = {["name"] = "skateboard", ["label"] = "Skateboard", ["weight"] = 1, ["type"] = "item", ["image"] = "skateboard.png", ["unique"] = true, ["useable"] = true, ["shouldClose"] = true, ["combinable"] = nil, ["description"] = ""},
|
||||
```
|
||||
@@ -22,5 +29,5 @@ If you have a supposition of upgrade to add in the script contact me in fiveM fo
|
||||
- Target the board again and choose "Pick up" to pick it up again
|
||||
- Press the arrows to move the skateboard
|
||||
|
||||
This script use a base of the script `rdrp_rccars`` by qalle:
|
||||
This script use a base of the script rdrp_rccars by qalle:
|
||||
https://forum.fivem.net/t/release-rc-car-script/525015
|
||||
324
client.lua
Normal file
324
client.lua
Normal file
@@ -0,0 +1,324 @@
|
||||
|
||||
local skateboard, Dir, customCam, Attached, overSpeed = {}, {}, nil, false, nil
|
||||
|
||||
local function createSkateboardEntity()
|
||||
local entity = makeVeh("triBike3", vec4(0, 0, 0, 0))
|
||||
local prop = makeProp({ prop = "v_res_skateboard", coords = vec4(0, 0, 0, 0) }, 0, 1)
|
||||
while not DoesEntityExist(entity) or not DoesEntityExist(prop) do Wait(5) end
|
||||
|
||||
SetEntityVisible(entity, (Config.System.Debug), 0)
|
||||
|
||||
AttachEntityToEntity(prop, entity, GetPedBoneIndex(PlayerPedId(), 28422), 0.0, 0.0, -0.60, 0.0, 0.0, 90.0, false, true, true, true, 1, true)
|
||||
|
||||
SetEntityNoCollisionEntity(entity, PlayerPedId(), false)
|
||||
SetEntityNoCollisionEntity(prop, PlayerPedId(), false)
|
||||
|
||||
SetEntityCompletelyDisableCollision(entity, true, true)
|
||||
SetEntityCompletelyDisableCollision(prop, true, true)
|
||||
|
||||
SetVehicleDoorsLocked(entity, 10)
|
||||
|
||||
DisableCamCollisionForEntity(entity)
|
||||
DisableCamCollisionForEntity(prop)
|
||||
return entity, prop
|
||||
end
|
||||
|
||||
local function configureSkateboard(entity)
|
||||
for k, v in pairs({
|
||||
["fSteeringLock"] = 9.0,
|
||||
["fDriveInertia"] = 0.05,
|
||||
["fMass"] = 1800.0,
|
||||
["fPercentSubmerged"] = 105.0,
|
||||
["fDriveBiasFront"] = 0.0,
|
||||
["fInitialDriveForce"] = 0.25,
|
||||
["fInitialDriveMaxFlatVel"] = 135.0,
|
||||
["fTractionCurveMax"] = 2.2,
|
||||
["fTractionCurveMin"] = 2.12,
|
||||
["fTractionCurveLateral"] = 22.5,
|
||||
["fTractionSpringDeltaMax"] = 0.1,
|
||||
["fLowSpeedTractionLossMult"] = 0.7,
|
||||
["fCamberStiffnesss"] = 0.0,
|
||||
["fTractionBiasFront"] = 0.478,
|
||||
["fTractionLossMult"] = 0.0,
|
||||
["fSuspensionForce"] = 1.2,
|
||||
["fSuspensionReboundDamp"] = 1.7,
|
||||
["fSuspensionUpperLimit"] = 0.1,
|
||||
["fSuspensionLowerLimit"] = -0.3,
|
||||
["fSuspensionRaise"] = 0.0,
|
||||
["fSuspensionBiasFront"] = 0.5,
|
||||
["fAntiRollBarForce"] = 0.0,
|
||||
["fAntiRollBarBiasFront"] = 0.65,
|
||||
["fBrakeForce"] = 0.53 }) do
|
||||
SetVehicleHandlingFloat(entity, "CHandlingData", k, v)
|
||||
end
|
||||
end
|
||||
|
||||
local function createBikeDriver(bike)
|
||||
local entity = makePed("S_M_M_AutoShop_01", vec4(0.0, 0.0, 0.0, 0.0), 0, 1, nil, nil)
|
||||
SetEntityNoCollisionEntity(entity, PlayerPedId(), false)
|
||||
SetEntityCompletelyDisableCollision(entity, true, true)
|
||||
SetEnableHandcuffs(entity, true)
|
||||
SetEntityInvincible(entity, true)
|
||||
FreezeEntityPosition(entity, true)
|
||||
TaskWarpPedIntoVehicle(entity, bike, -1)
|
||||
SetEntityVisible(entity, (Config.System.Debug), 0)
|
||||
return entity
|
||||
end
|
||||
|
||||
local function makeFakeSkateboard(Ped, remove) -- The animation for picking up and placing the board
|
||||
local prop = makeProp({ prop = "v_res_skateboard", coords = vec4(0,0,0,0), false, true})
|
||||
if GetEntityModel(Ped) == `a_c_cat_01` then
|
||||
AttachEntityToEntity(prop, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 31086), 0.18, -0.14, 0.0, -87.0, -100.0, 1.0, true, true, false, false, 1, true)
|
||||
else
|
||||
AttachEntityToEntity(prop, Ped, GetPedBoneIndex(Ped, 57005), 0.3, 0.08, 0.09, -86.0, -60.0, 50.0, true, true, false, false, 1, true)
|
||||
playAnim("pickup_object", "pickup_low", -1, 0)
|
||||
end
|
||||
if remove then
|
||||
DeleteVehicle(skateboard.Bike)
|
||||
destroyProp(skateboard.Skate)
|
||||
DeleteEntity(skateboard.Driver)
|
||||
end
|
||||
Wait(900)
|
||||
destroyProp(prop)
|
||||
end
|
||||
|
||||
RegisterNetEvent("jim-skateboard:PickPlace", function() local Ped = PlayerPedId()
|
||||
if not IsPedSittingInAnyVehicle(Ped) then
|
||||
if DoesEntityExist(skateboard.Bike) then
|
||||
removeEntityTarget(skateboard.Skate)
|
||||
removeEntityTarget(skateboard.Driver)
|
||||
removeEntityTarget(skateboard.Bike)
|
||||
Attached = false
|
||||
Wait(100)
|
||||
stopTempCam()
|
||||
|
||||
makeFakeSkateboard(Ped, true) -- pick up animation
|
||||
|
||||
addItem("skateboard", 1)
|
||||
skateboard = {}
|
||||
Dir = {}
|
||||
else
|
||||
--Make and configure skateboard
|
||||
skateboard.Bike, skateboard.Skate = createSkateboardEntity()
|
||||
configureSkateboard(skateboard.Bike)
|
||||
|
||||
-- Driver properties
|
||||
skateboard.Driver = createBikeDriver(skateboard.Bike)
|
||||
|
||||
local options = {
|
||||
{ action = function() TriggerEvent("jim-skateboard:GetOn", { board = skateboard.Skate }) end,
|
||||
icon = "fas fa-car", label = "Get on", board = skateboard.Skate },
|
||||
{ action = function() TriggerEvent("jim-skateboard:PickPlace", { board = skateboard.Skate }) end,
|
||||
icon = "fas fa-hand-holding", label ="Pick up", board = skateboard.Skate },
|
||||
}
|
||||
createEntityTarget(skateboard.Skate, options, 2.5)
|
||||
createEntityTarget(skateboard.Driver, options, 2.5)
|
||||
createEntityTarget(skateboard.Bike, options, 2.5)
|
||||
|
||||
makeFakeSkateboard(Ped)
|
||||
SetEntityCoords(skateboard.Bike, GetOffsetFromEntityInWorldCoords(Ped, 0.0, 0.5, 1.5))
|
||||
SetEntityHeading(skateboard.Bike, GetEntityHeading(PlayerPedId())+90)
|
||||
removeItem("skateboard", 1)
|
||||
Dir = {}
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterKeyMapping('skategetoff', 'Skateboard: Get Off', 'keyboard', 'G')
|
||||
RegisterCommand('skategetoff', function()
|
||||
if Attached then
|
||||
if not IsEntityInAir(skateboard.Bike) then
|
||||
stopTempCam()
|
||||
DetachEntity(PlayerPedId(), false, false)
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Bike, 1, 100)
|
||||
Attached = false
|
||||
Dir = {}
|
||||
if GetEntityModel(PlayerPedId()) == `a_c_cat_01` then
|
||||
ClearPedTasks(PlayerPedId())
|
||||
else
|
||||
stopAnim("move_strafe@stealth", "idle")
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterKeyMapping('+skateforward', 'Skateboard: Forward', 'keyboard', 'W')
|
||||
RegisterCommand('+skateforward', function()
|
||||
if Attached and not overSpeed then
|
||||
CreateThread(function()
|
||||
if not Dir.forward then
|
||||
Dir.forward = true
|
||||
while Dir.forward do
|
||||
if not Dir.right and not Dir.left then TaskVehicleTempAction(skateboard.Driver, skateboard.Bike, 9, 0.1) end
|
||||
if Dir.left then TaskVehicleTempAction(skateboard.Driver, skateboard.Bike, 7, 0.1) end
|
||||
if Dir.right then TaskVehicleTempAction(skateboard.Driver, skateboard.Bike, 8, 0.1) end
|
||||
Wait(50)
|
||||
end
|
||||
else return end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
RegisterCommand('-skateforward', function() if Attached then Dir.forward = nil TaskVehicleTempAction(skateboard.Driver, skateboard.Bike, 1, 1) end end)
|
||||
|
||||
RegisterKeyMapping('+skatebackward', 'Skateboard: Backward', 'keyboard', 'S')
|
||||
RegisterCommand('+skatebackward', function()
|
||||
if Attached and not overSpeed then
|
||||
CreateThread(function()
|
||||
if not Dir.backward then
|
||||
Dir.backward = true
|
||||
while Dir.backward do
|
||||
if Dir.left then
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Bike, 13, 0.1)
|
||||
elseif Dir.right then
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Bike, 14, 0.1)
|
||||
elseif not Dir.right and not Dir.left then
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Bike, 22, 0.1)
|
||||
end
|
||||
Wait(50)
|
||||
end
|
||||
else return end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
RegisterCommand('-skatebackward', function() if Attached then Dir.backward = nil TaskVehicleTempAction(skateboard.Driver, skateboard.Bike, 1, 1) end end)
|
||||
|
||||
RegisterKeyMapping('+skateleft', 'Skateboard: Left', 'keyboard', 'A')
|
||||
RegisterCommand('+skateleft', function() if Attached and not overSpeed then Dir.left = true end end)
|
||||
RegisterCommand('-skateleft', function() if Attached then Dir.left = nil end end)
|
||||
|
||||
RegisterKeyMapping('+skateright', 'Skateboard: Right', 'keyboard', 'D')
|
||||
RegisterCommand('+skateright', function() if Attached and not overSpeed then Dir.right = true end end)
|
||||
RegisterCommand('-skateright', function() if Attached then Dir.right = nil end end)
|
||||
|
||||
RegisterKeyMapping('skatejump', 'Skateboard: Jump', 'keyboard', 'SPACE')
|
||||
RegisterCommand('skatejump', function() local Ped = PlayerPedId()
|
||||
if Attached then
|
||||
if not IsEntityInAir(skateboard.Bike) then
|
||||
local vel = GetEntityVelocity(skateboard.Bike)
|
||||
if GetEntityModel(Ped) == `a_c_cat_01` then
|
||||
playAnim("creatures@cat@move", "idle_dwn", -1, 1)
|
||||
else
|
||||
playAnim("move_crouch_proto", "idle_intro", -1, 1)
|
||||
end
|
||||
local duration = 0
|
||||
local boost = 0
|
||||
while IsControlPressed(0, 22) do
|
||||
Wait(10)
|
||||
duration = duration + 10.0
|
||||
end
|
||||
boost = 6.0 * duration / 250.0
|
||||
if boost > 6.0 then boost = 6.0 end
|
||||
|
||||
SetEntityVelocity(skateboard.Bike, vel.x, vel.y, vel.z + boost)
|
||||
if GetEntityModel(Ped) == `a_c_cat_01` then
|
||||
stopAnim("move_crouch_proto", "idle_dwn")
|
||||
playAnim("creatures@cat@move", "idle_upp", -1, 1)
|
||||
else
|
||||
stopAnim("move_crouch_proto", "idle_intro")
|
||||
playAnim("move_strafe@stealth", "idle", -1, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local toggleCam = false
|
||||
local flipCam = false
|
||||
RegisterKeyMapping('skatecam', 'Skateboard: Unlock/Lock Cam', 'keyboard', 'H')
|
||||
RegisterCommand('skatecam', function()
|
||||
if Attached then
|
||||
toggleCam = not toggleCam
|
||||
updateCamLoc()
|
||||
end
|
||||
end)
|
||||
RegisterKeyMapping('+flipcam', 'Skateboard: Flip Cam', 'keyboard', 'C')
|
||||
RegisterCommand('+flipcam', function()
|
||||
if Attached then
|
||||
AttachCamToEntity(customCam, skateboard.Bike, 0.25, 2.0, 1.5, true)
|
||||
flipCam = true
|
||||
end
|
||||
end)
|
||||
RegisterCommand('-flipcam', function()
|
||||
if Attached then
|
||||
AttachCamToEntity(customCam, skateboard.Bike, 0.25, -2.0, 1.0, true)
|
||||
flipCam = false
|
||||
end
|
||||
end)
|
||||
function updateCamLoc()
|
||||
CreateThread(function()
|
||||
while toggleCam and Attached do
|
||||
local coord = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, flipCam and -5.0 or 5.0, 0.0)
|
||||
if customCam == nil then
|
||||
customCam = createTempCam(coord, coord)
|
||||
AttachCamToEntity(customCam, skateboard.Bike, 0.25, -2.0, 1.0, true)
|
||||
startTempCam(customCam)
|
||||
end
|
||||
PointCamAtCoord(customCam, coord.x, coord.y, coord.z)
|
||||
Wait(0)
|
||||
end
|
||||
RenderScriptCams(false, true, 500, true, true)
|
||||
DestroyAllCams()
|
||||
customCam = nil
|
||||
end)
|
||||
end
|
||||
|
||||
RegisterNetEvent("jim-skateboard:GetOn", function() local Ped = PlayerPedId()
|
||||
if GetEntityModel(Ped) == `a_c_cat_01` then
|
||||
AttachEntityToEntity(Ped, skateboard.Bike, 20, 0.0, 0.10, -0.78, 0.4, 0.0, 0.0, -15.0, true, true, false, true, 1, true)
|
||||
playAnim("creatures@cat@move", "idle_upp", -1, 1)
|
||||
else
|
||||
playAnim("move_strafe@stealth", "idle", -1, 1)
|
||||
AttachEntityToEntity(Ped, skateboard.Bike, 20, 0.0, 0.15, 0.05, 0.0, 0.0, -15.0, true, true, false, true, 1, true)
|
||||
end
|
||||
SetEntityCollision(Ped, true, true)
|
||||
Attached = true
|
||||
updateCamLoc()
|
||||
drawText(nil, {"[G] - Get Off Stakeboard", "[H] - Unlock/Lock Cam"}, "w")
|
||||
CreateThread(function()
|
||||
while Attached do
|
||||
StopCurrentPlayingAmbientSpeech(skateboard.Driver)
|
||||
overSpeed = (GetEntitySpeed(skateboard.Bike)*3.6) > 90
|
||||
local x, y, z = table.unpack(GetEntityRotation(skateboard.Bike))
|
||||
if (-40.0 < x and x > 40.0) or (-40.0 < y and y > 40.0) then
|
||||
DetachEntity(Ped, false, false)
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Bike, 1, 1)
|
||||
Attached = false
|
||||
Dir = {}
|
||||
if GetEntityModel(Ped) ~= `a_c_cat_01` then stopAnim("move_strafe@stealth", "idle") end
|
||||
SetPedToRagdoll(Ped, 5000, 4000, 0, true, true, false)
|
||||
end
|
||||
|
||||
if not DoesEntityExist(skateboard.Bike) or GetPedInVehicleSeat(skateboard.Bike, -1) ~= skateboard.Driver then
|
||||
removeEntityTarget(skateboard.Skate)
|
||||
removeEntityTarget(skateboard.Bike)
|
||||
removeEntityTarget(skateboard.Driver)
|
||||
Attached = false
|
||||
Wait(100)
|
||||
makeFakeSkateboard(Ped, true)
|
||||
addItem("skateboard", 1)
|
||||
skateboard = {}
|
||||
Dir = {}
|
||||
end
|
||||
if not IsEntityAttachedToEntity(Ped, skateboard.Bike) then
|
||||
DetachEntity(Ped, false, false)
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Bike, 6, 2000)
|
||||
Attached = false
|
||||
Dir = {}
|
||||
if GetEntityModel(Ped) == `a_c_cat_01` then
|
||||
stopAnim("creatures@cat@move", "idle_upp")
|
||||
stopAnim("creatures@cat@move", "idle_dwn")
|
||||
else
|
||||
stopAnim("move_strafe@stealth", "idle")
|
||||
end
|
||||
end
|
||||
Wait(1000)
|
||||
end
|
||||
hideText()
|
||||
end)
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() then return end
|
||||
hideText()
|
||||
if DoesEntityExist(skateboard.Bike) then
|
||||
DeleteVehicle(skateboard.Bike)
|
||||
end
|
||||
end)
|
||||
@@ -1,229 +0,0 @@
|
||||
local Props, Targets, Peds, skateboard, Dir = {}, {}, {}, {}, {}
|
||||
|
||||
RegisterNetEvent("jim-skateboard:PickPlace", function()
|
||||
if not IsPedSittingInAnyVehicle(PlayerPedId()) then
|
||||
if DoesEntityExist(skateboard.Entity) then
|
||||
exports["qb-target"]:RemoveTargetEntity(skateboard.Skate)
|
||||
Attached = false
|
||||
Wait(100)
|
||||
TaskPlayAnim(PlayerPedId(), "pickup_object", "pickup_low", 8.0, -8.0, -1, 0, 0, false, false, false)
|
||||
Wait(600)
|
||||
AttachEntityToEntity(skateboard.Entity, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 28422), -0.1, 0.0, -0.2, 70.0, 0.0, 270.0, 1, 1, 0, 0, 2, 1)
|
||||
Wait(900)
|
||||
DeleteVehicle(skateboard.Entity)
|
||||
destroyProp(skateboard.Skate)
|
||||
DeleteEntity(skateboard.Driver)
|
||||
toggleItem(true, "skateboard", 1)
|
||||
skateboard = {}
|
||||
Dir = {}
|
||||
else
|
||||
loadModel(`triBike3`)
|
||||
loadModel(`S_M_M_AutoShop_01`)
|
||||
loadModel(`v_res_skateboard`)
|
||||
skateboard.Entity = CreateVehicle(`triBike3`, 0, 0, 0, 0, true)
|
||||
skateboard.Skate = makeProp({ prop = `v_res_skateboard`, coords = vec4(0,0,0,0) }, 0, 1)
|
||||
SetEntityNoCollisionEntity(skateboard.Entity, PlayerPedId(), false)
|
||||
SetEntityNoCollisionEntity(skateboard.Skate, PlayerPedId(), false)
|
||||
|
||||
while not DoesEntityExist(skateboard.Entity) do Wait(5) end
|
||||
while not DoesEntityExist(skateboard.Skate) do Wait(5) end
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fSteeringLock", 9.0)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fDriveInertia", 0.05)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fMass", 1800.0)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fPercentSubmerged", 105.0)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fDriveBiasFront", 0.0)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fInitialDriveForce", 0.25)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fInitialDriveMaxFlatVel", 135.0)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fTractionCurveMax", 2.2)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fTractionCurveMin", 2.12)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fTractionCurveLateral", 22.5)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fTractionSpringDeltaMax", 0.1)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fLowSpeedTractionLossMult", 0.7)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fCamberStiffnesss", 0.0)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fTractionBiasFront", 0.478)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fTractionLossMult", 0.0)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fSuspensionForce", 5.2)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fSuspensionForce", 1.2)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fSuspensionReboundDamp", 1.7)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fSuspensionUpperLimit", 0.1)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fSuspensionLowerLimit", -0.3)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fSuspensionRaise", 0.0)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fSuspensionBiasFront", 0.5)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fAntiRollBarForce", 0.0)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fAntiRollBarBiasFront", 0.65)
|
||||
SetVehicleHandlingFloat(skateboard.Entity, "CHandlingData", "fBrakeForce", 0.53)
|
||||
|
||||
SetEntityCompletelyDisableCollision(skateboard.Entity, true, true)
|
||||
SetEntityVisible(skateboard.Entity, false)
|
||||
AttachEntityToEntity(skateboard.Skate, skateboard.Entity, GetPedBoneIndex(PlayerPedId(), 28422), 0.0, 0.0, -0.60, 0.0, 0.0, 90.0, false, true, true, true, 1, true)
|
||||
|
||||
local loc = vec4(GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0, 1.0, 0).x, GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0, 1.0, 0).y, GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0, 1.0, 0).z, GetEntityHeading(PlayerPedId()))
|
||||
skateboard.Driver = makePed(68070371, loc, 0, 1, nil, nil)
|
||||
SetEntityNoCollisionEntity(skateboard.Driver, PlayerPedId(), false)
|
||||
|
||||
-- Driver properties
|
||||
SetEnableHandcuffs(skateboard.Driver, true)
|
||||
SetEntityInvincible(skateboard.Driver, true)
|
||||
SetEntityVisible(skateboard.Driver, false)
|
||||
FreezeEntityPosition(skateboard.Driver, true)
|
||||
TaskWarpPedIntoVehicle(skateboard.Driver, skateboard.Entity, -1)
|
||||
Targets[#Targets+1] =
|
||||
exports["qb-target"]:AddTargetEntity(skateboard.Skate, { options = {
|
||||
{ event = "jim-skateboard:GetOn", icon = "fas fa-car", label = "Get on", board = skateboard.Skate },
|
||||
{ event = "jim-skateboard:PickPlace", icon = "fas fa-hand-holding", label = "Pick up", board = skateboard.Skate },
|
||||
}, distance = 2.5, })
|
||||
|
||||
loadAnimDict("pickup_object")
|
||||
AttachEntityToEntity(skateboard.Entity, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 28422), -0.1, 0.10, -0.2, 70.0, 0.0, 270.0, 1, 1, 0, 0, 2, 1)
|
||||
TaskPlayAnim(PlayerPedId(), "pickup_object", "pickup_low", 8.0, -8.0, -1, 0, 0, false, false, false)
|
||||
Wait(800)
|
||||
DetachEntity(skateboard.Entity, false, true)
|
||||
PlaceObjectOnGroundProperly(skateboard.Entity)
|
||||
toggleItem(false, "skateboard", 1)
|
||||
Dir = {}
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterKeyMapping('skategetoff', 'Skateboard: Get Off', 'keyboard', 'G')
|
||||
RegisterCommand('skategetoff', function()
|
||||
if IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) then
|
||||
if not IsEntityInAir(skateboard.Entity) then
|
||||
DetachEntity(PlayerPedId(), false, false)
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 1, 100)
|
||||
Attached = false
|
||||
Dir = {}
|
||||
StopAnimTask(PlayerPedId(), "move_strafe@stealth", "idle", 1.0)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterKeyMapping('+skateforward', 'Skateboard: Forward', 'keyboard', 'W')
|
||||
RegisterCommand('+skateforward', function()
|
||||
if IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) and not overSpeed then
|
||||
CreateThread(function()
|
||||
if not Dir.forward then
|
||||
Dir.forward = true
|
||||
while Dir.forward do
|
||||
if not Dir.right and not Dir.left then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 9, 0.1) end
|
||||
if Dir.left then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 7, 0.1) end
|
||||
if Dir.right then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 8, 0.1) end
|
||||
Wait(50)
|
||||
end
|
||||
else return end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
RegisterCommand('-skateforward', function() if IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) then Dir.forward = nil TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 1, 1) end end)
|
||||
|
||||
RegisterKeyMapping('+skatebackward', 'Skateboard: Backward', 'keyboard', 'S')
|
||||
RegisterCommand('+skatebackward', function()
|
||||
if IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) and not overSpeed then
|
||||
CreateThread(function()
|
||||
if not Dir.backward then
|
||||
Dir.backward = true
|
||||
while Dir.backward do
|
||||
if Dir.left then
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 13, 0.1)
|
||||
elseif Dir.right then
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 14, 0.1)
|
||||
elseif not Dir.right and not Dir.left then
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 22, 0.1)
|
||||
end
|
||||
Wait(50)
|
||||
end
|
||||
else return end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
RegisterCommand('-skatebackward', function() if IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) then Dir.backward = nil TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 1, 1) end end)
|
||||
|
||||
RegisterKeyMapping('+skateleft', 'Skateboard: Left', 'keyboard', 'A')
|
||||
RegisterCommand('+skateleft', function() if IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) and not overSpeed then Dir.left = true end end)
|
||||
RegisterCommand('-skateleft', function() if IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) then Dir.left = nil end end)
|
||||
|
||||
|
||||
RegisterKeyMapping('+skateright', 'Skateboard: Right', 'keyboard', 'D')
|
||||
RegisterCommand('+skateright', function() if IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) and not overSpeed then Dir.right = true end end)
|
||||
RegisterCommand('-skateright', function() if IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) then Dir.right = nil end end)
|
||||
|
||||
RegisterKeyMapping('skatejump', 'Skateboard: Jump', 'keyboard', 'SPACE')
|
||||
RegisterCommand('skatejump', function()
|
||||
if IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) then
|
||||
if not IsEntityInAir(skateboard.Entity) then
|
||||
local vel = GetEntityVelocity(skateboard.Entity)
|
||||
TaskPlayAnim(PlayerPedId(), "move_crouch_proto", "idle_intro", 5.0, 8.0, -1, 0, 0, false, false, false)
|
||||
local duration = 0
|
||||
local boost = 0
|
||||
while IsControlPressed(0, 22) do
|
||||
Wait(10)
|
||||
duration = duration + 10.0
|
||||
--ForceVehicleEngineAudio(skateboard.Entity, 0)
|
||||
end
|
||||
boost = 6.0 * duration / 250.0
|
||||
if boost > 6.0 then boost = 6.0 end
|
||||
StopAnimTask(PlayerPedId(), "move_crouch_proto", "idle_intro", 1.0)
|
||||
SetEntityVelocity(skateboard.Entity, vel.x, vel.y, vel.z + boost)
|
||||
TaskPlayAnim(PlayerPedId(), "move_strafe@stealth", "idle", 8.0, 2.0, -1, 1, 1.0, false, false, false)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local Attached = false
|
||||
local overSpeed = 0
|
||||
RegisterNetEvent("jim-skateboard:GetOn", function()
|
||||
loadAnimDict("move_strafe@stealth")
|
||||
loadAnimDict("move_crouch_proto")
|
||||
TaskPlayAnim(PlayerPedId(), "move_strafe@stealth", "idle", 8.0, 8.0, -1, 1, 1.0, false, false, false)
|
||||
AttachEntityToEntity(PlayerPedId(), skateboard.Entity, 20, 0.0, 0.15, 0.05, 0.0, 0.0, -15.0, true, true, false, true, 1, true)
|
||||
SetEntityCollision(PlayerPedId(), true, true)
|
||||
Attached = true
|
||||
CreateThread(function()
|
||||
while Attached do
|
||||
StopCurrentPlayingAmbientSpeech(skateboard.Driver)
|
||||
overSpeed = (GetEntitySpeed(skateboard.Entity)*3.6) > 90
|
||||
local x, y, z = table.unpack(GetEntityRotation(skateboard.Entity))
|
||||
if (-40.0 < x and x > 40.0) or (-40.0 < y and y > 40.0) then
|
||||
DetachEntity(PlayerPedId(), false, false)
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 1, 1)
|
||||
Attached = false
|
||||
Dir = {}
|
||||
StopAnimTask(PlayerPedId(), "move_strafe@stealth", "idle", 1.0)
|
||||
SetPedToRagdoll(PlayerPedId(), 5000, 4000, 0, true, true, false)
|
||||
end
|
||||
|
||||
if not DoesEntityExist(skateboard.Entity) then
|
||||
exports["qb-target"]:RemoveTargetEntity(skateboard.Skate)
|
||||
Attached = false
|
||||
Wait(100)
|
||||
TaskPlayAnim(PlayerPedId(), "pickup_object", "pickup_low", 8.0, -8.0, -1, 0, 0, false, false, false)
|
||||
Wait(600)
|
||||
AttachEntityToEntity(skateboard.Entity, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 28422), -0.1, 0.0, -0.2, 70.0, 0.0, 270.0, 1, 1, 0, 0, 2, 1)
|
||||
Wait(900)
|
||||
DeleteVehicle(skateboard.Entity)
|
||||
destroyProp(skateboard.Skate)
|
||||
DeleteEntity(skateboard.Driver)
|
||||
skateboard = {}
|
||||
Dir = {}
|
||||
end
|
||||
if not IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) then
|
||||
DetachEntity(PlayerPedId(), false, false)
|
||||
TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 6, 2000)
|
||||
Attached = false
|
||||
Dir = {}
|
||||
StopAnimTask(PlayerPedId(), "move_strafe@stealth", "idle", 1.0)
|
||||
end
|
||||
Wait(1000)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() or not LocalPlayer.state.isLoggedIn then return end
|
||||
for _, v in pairs(Peds) do unloadModel(GetEntityModel(v)) DeletePed(v) end
|
||||
for i = 1, #Props do unloadModel(GetEntityModel(Props[i])) DeleteObject(Props[i]) end
|
||||
if DoesEntityExist(skateboard.Entity) then
|
||||
DeletePed(skateboard.Driver)
|
||||
DeleteVehicle(skateboard.Entity)
|
||||
DeleteObject(skateboard.Skate)
|
||||
end
|
||||
end)
|
||||
10
config.lua
Normal file
10
config.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
Config = {
|
||||
System = {
|
||||
Debug = false,
|
||||
|
||||
drawText = "gta",
|
||||
},
|
||||
Crafting = {
|
||||
craftCam = true,
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,26 @@
|
||||
name "ElectricSkateboard"
|
||||
name "jim-stakeboard"
|
||||
author "Jimathy"
|
||||
version "v1.0.1"
|
||||
version "2.0"
|
||||
description "Electric Skateboard Script By Jimathy"
|
||||
fx_version "cerulean"
|
||||
game "gta5"
|
||||
lua54 'yes'
|
||||
|
||||
shared_scripts { 'shared/*.lua' }
|
||||
client_scripts { 'client/*.lua', }
|
||||
server_script { 'server/*.lua' }
|
||||
shared_scripts {
|
||||
'config.lua',
|
||||
-- Required core scripts
|
||||
'@ox_lib/init.lua',
|
||||
'@ox_core/imports/client.lua',
|
||||
'@es_extended/imports.lua',
|
||||
'@qbx_core/modules/playerdata.lua',
|
||||
|
||||
--Jim Bridge
|
||||
'@jim_bridge/exports.lua',
|
||||
'@jim_bridge/functions.lua',
|
||||
'@jim_bridge/wrapper.lua',
|
||||
'@jim_bridge/crafting.lua',
|
||||
}
|
||||
client_script 'client.lua'
|
||||
server_script 'server.lua'
|
||||
|
||||
dependancy 'jim_bridge'
|
||||
1
server.lua
Normal file
1
server.lua
Normal file
@@ -0,0 +1 @@
|
||||
createUseableItem("skateboard", function(source, item) TriggerClientEvent("jim-skateboard:PickPlace", source) end)
|
||||
@@ -1,14 +0,0 @@
|
||||
QBCore.Functions.CreateUseableItem("skateboard", function(source, item) TriggerClientEvent("jim-skateboard:PickPlace", source) end)
|
||||
|
||||
RegisterNetEvent('jim-skateboard:server:toggleItem', function(give, item, amount)
|
||||
local src = source
|
||||
if not give then
|
||||
if QBCore.Functions.GetPlayer(src).Functions.RemoveItem(item, amount or 1) then
|
||||
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "remove", amount or 1)
|
||||
end
|
||||
elseif give then
|
||||
if QBCore.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
|
||||
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "add", amount or 1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -1,37 +0,0 @@
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
function loadModel(model) if not HasModelLoaded(model) then RequestModel(model) while not HasModelLoaded(model) do Wait(0) end end end
|
||||
function unloadModel(model) SetModelAsNoLongerNeeded(model) end
|
||||
function loadAnimDict(dict) while not HasAnimDictLoaded(dict) do RequestAnimDict(dict) Wait(5) end end
|
||||
function unloadAnimDict(dict) RemoveAnimDict(dict) end
|
||||
|
||||
function destroyProp(entity)
|
||||
SetEntityAsMissionEntity(entity) Wait(5)
|
||||
DetachEntity(entity, true, true) Wait(5)
|
||||
DeleteObject(entity)
|
||||
end
|
||||
|
||||
function makeProp(data, freeze, synced)
|
||||
loadModel(data.prop)
|
||||
local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z-1.03, synced or 0, synced or 0, 0)
|
||||
SetEntityHeading(prop, data.coords.w)
|
||||
FreezeEntityPosition(prop, freeze or 0)
|
||||
return prop
|
||||
end
|
||||
|
||||
function makePed(model, coords, freeze, collision, scenario, anim)
|
||||
loadModel(model)
|
||||
local ped = CreatePed(0, model, coords.x, coords.y, coords.z-1.03, coords.w, false, false)
|
||||
SetEntityInvincible(ped, true)
|
||||
SetBlockingOfNonTemporaryEvents(ped, true)
|
||||
FreezeEntityPosition(ped, freeze or true)
|
||||
if collision then SetEntityNoCollisionEntity(ped, PlayerPedId(), false) end
|
||||
if scenario then TaskStartScenarioInPlace(ped, scenario, 0, true) end
|
||||
if anim then
|
||||
loadAnimDict(anim[1])
|
||||
TaskPlayAnim(ped, anim[1], anim[2], 1.0, 1.0, -1, 1, 0.2, 0, 0, 0)
|
||||
end
|
||||
return ped
|
||||
end
|
||||
|
||||
function toggleItem(give, item, amount) TriggerServerEvent("jim-skateboard:server:toggleItem", give, item, amount) end
|
||||
BIN
skateboard.png
Normal file
BIN
skateboard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
1
version.txt
Normal file
1
version.txt
Normal file
@@ -0,0 +1 @@
|
||||
2.0
|
||||
Reference in New Issue
Block a user