Add files via upload

This commit is contained in:
Jim Shield
2022-08-17 23:02:17 +01:00
committed by GitHub
parent 67505d78e1
commit 76b5849d8b
6 changed files with 294 additions and 24 deletions

View File

@@ -1,24 +1,26 @@
# ElectricSkateboardFiveM
Electric Skateboard is a script in develop who use a base of the scrip rd_cars.
If you have a supposition of upgrade to add in the script contact me in fiveM forum, my pseudo: 'Super_Chocolatine'.
How to install:
1) Place the folder 'electric-skateboard'in your resources folder
3) Add start electric-skateboard in your server.cfg
4) If you want add a menu config the triggers events
5) Start your server
How to use:
- '/longboard' to do spawn the skateboard
- Press 'G' for get in the skate and get off the skate
- Press 'E' to pick up the skateboard
- Press the arrows to move the skateboard
This script use a base of the script rdrp_rccars by qalle:
https://forum.fivem.net/t/release-rc-car-script/525015
A QBCore version of this script exist:
https://github.com/ikovaa/ElectricSkateboardFiveM/tree/qbcore
Thank you
# ElectricSkateboardFiveM
```
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'.
```
## 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:
```lua
["skateboard"] = {["name"] = "skateboard", ["label"] = "Skateboard", ["weight"] = 1, ["type"] = "item", ["image"] = "skateboard.png", ["unique"] = true, ["useable"] = true, ["shouldClose"] = true, ["combinable"] = nil, ["description"] = ""},
```
4. Add the image to your inventory images
5. Start your server
## How to use:
- Use the board in your inventory to place on the ground
- Target the board and choose "Get on"
- When you want to get off the skateboard press "G"
- 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:
https://forum.fivem.net/t/release-rc-car-script/525015

200
client/client.lua Normal file
View File

@@ -0,0 +1,200 @@
local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end)
local Props = {}
local Targets = {}
local Peds = {}
local skateboard = {}
RegisterNetEvent("jim-skateboard:PickPlace", function()
if DoesEntityExist(skateboard.Entity) then
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 = {}
else
loadModel(`triBike3`)
loadModel(68070371)
loadModel(`v_res_skateboard`)
skateboard.Entity = CreateVehicle(`triBike3`, 0, 0, 0, 0, true)
skateboard.Skate = makeProp({prop = `v_res_skateboard`, coords = vector4(0,0,0,0)}, 0, 1)
SetEntityNoCollisionEntity(skateboard.Entity,PlayerPedId(), false)
SetEntityNoCollisionEntity(skateboard.Skate,PlayerPedId(), false)
-- load models
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)
SetEntityNoCollisionEntity(skateboard.Entity, PlayerPedId(), false) -- disable collision between the player and the rc
SetEntityNoCollisionEntity(skateboard.Skate,PlayerPedId(), false)
SetEntityCollision(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 = vector4(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.Entity, { options = {
{ event = "jim-skateboard:GetOn", icon = "fas fa-car", label = "Get on", board = skateboard.Entity },
{ event = "jim-skateboard:PickPlace", icon = "fas fa-hand-holding", label = "Pick up", board = skateboard.Entity },
}, distance = 2.5, })
--TriggerServerEvent("jim-skateboard:ShareTarget", NetworkGetNetworkIdFromEntity(skateboard.Entity))
--can't figure out how to an entity id with other players so they can target it too
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)
end
end)
--[[RegisterNetEvent("jim-skateboard:GetTarget", function(board, src)
print(src)
print(PlayerPedId())
print(board)
print(NetToEnt(board))
Targets[#Targets+1] =
exports["qb-target"]:AddTargetEntity(NetToEnt(board), { options = {
{ event = "jim-skateboard:PickPlace", icon = "fas fa-hand-holding", label = "Pick up", board = NetToEnt(board) },
}, distance = 2.5, })
end)]]
local Attached = false
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)
local x = GetEntityRotation(skateboard.Entity).x
local y = GetEntityRotation(skateboard.Entity).y
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
StopAnimTask(PlayerPedId(), "move_strafe@stealth", "idle", 1.0)
SetPedToRagdoll(PlayerPedId(), 5000, 4000, 0, true, true, false)
end
if IsControlJustReleased(0, 113) then DetachEntity(PlayerPedId(), false, false) end
local overSpeed = (GetEntitySpeed(skateboard.Entity)*3.6) > 90
TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 1, 1)
ForceVehicleEngineAudio(skateboard.Entity, 0)
if IsControlPressed(0, 87) and not IsControlPressed(0, 88) and not overSpeed then
TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 9, 1)
end
if IsControlPressed(0, 22) then
-- Jump system
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
if IsControlJustReleased(0, 87) or IsControlJustReleased(0, 88) and not overSpeed then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 6, 2500) end
if IsControlPressed(0, 88) and not IsControlPressed(0, 87) and not overSpeed then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 22, 1) end
if IsControlPressed(0, 89) and IsControlPressed(0, 88) and not overSpeed then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 13, 1) end
if IsControlPressed(0, 90) and IsControlPressed(0, 88) and not overSpeed then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 14, 1) end
if IsControlPressed(0, 87) and IsControlPressed(0, 88) and not overSpeed then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 30, 100) end
if IsControlPressed(0, 89) and IsControlPressed(0, 87) and not overSpeed then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 7, 1) end
if IsControlPressed(0, 90) and IsControlPressed(0, 87) and not overSpeed then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 8, 1) end
if IsControlPressed(0, 89) and not IsControlPressed(0, 87) and not IsControlPressed(0, 88) and not overSpeed then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 4, 1) end
if IsControlPressed(0, 90) and not IsControlPressed(0, 87) and not IsControlPressed(0, 88) and not overSpeed then TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 5, 1) end
if not DoesEntityExist(skateboard.Entity) then
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 = {}
end
if not IsEntityAttachedToEntity(PlayerPedId(), skateboard.Entity) then
DetachEntity(PlayerPedId(), false, false)
TaskVehicleTempAction(skateboard.Driver, skateboard.Entity, 1, 100)
Attached = false
StopAnimTask(PlayerPedId(), "move_strafe@stealth", "idle", 1.0)
end
Wait(7)
end
end)
end)
AddEventHandler('onResourceStop', function(resource) if resource ~= GetCurrentResourceName() 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
DeleteEntity(cardHat)
if DoesEntityExist(skateboard.Entity) then
DeletePed(skateboard.Driver)
DeleteVehicle(skateboard.Entity)
DeleteObject(skateboard.Skate)
end
end)

11
fxmanifest.lua Normal file
View File

@@ -0,0 +1,11 @@
name "ElectricSkateboard"
author "Jimathy"
version "v1.0"
description "Electric Skateboard Script By Jimathy"
fx_version "cerulean"
game "gta5"
dependencies { 'qb-target', }
shared_scripts { 'shared/*.lua' }
client_scripts { 'client/*.lua', }
server_script { 'server/*.lua' }

BIN
images/skateboard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

19
server/server.lua Normal file
View File

@@ -0,0 +1,19 @@
local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Server:UpdateObject', function() if source ~= '' then return false end QBCore = exports['qb-core']:GetCoreObject() end)
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)
--RegisterNetEvent("jim-skateboard:ShareTarget", function(board) local src = source TriggerClientEvent("jim-skateboard:GetTarget", -1, board, src) end)

38
shared/shared.lua Normal file
View File

@@ -0,0 +1,38 @@
local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-core']:GetCoreObject() end)
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