From b1d4e9cf22d6b1d2649ccc46f1025534e152a204 Mon Sep 17 00:00:00 2001 From: ds1-e <51768772+ds1-e@users.noreply.github.com> Date: Sat, 2 Nov 2024 04:49:52 +0100 Subject: [PATCH 1/3] Initial fixes for superman --- [gameplay]/superman/client.lua | 22 +++++++++++----------- [gameplay]/superman/server.lua | 14 +++++--------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/[gameplay]/superman/client.lua b/[gameplay]/superman/client.lua index d8a7ac7ad..e35336bf4 100644 --- a/[gameplay]/superman/client.lua +++ b/[gameplay]/superman/client.lua @@ -271,7 +271,7 @@ function Superman.startFlight() return end - triggerServerEvent("superman:start", root) + triggerServerEvent("superman:start", localPlayer) setPlayerFlying(localPlayer, true) setElementVelocity(localPlayer, 0, 0, 0) self.currentSpeed = 0 @@ -285,7 +285,7 @@ function Superman.processControls() local self = Superman if not isPlayerFlying(localPlayer) then - jump, oldJump = getPedControlState("jump"), jump + jump, oldJump = getPedControlState(localPlayer, "jump"), jump if not oldJump and jump then Superman.onJump() end @@ -295,15 +295,15 @@ function Superman.processControls() -- Calculate the requested movement direction local Direction = Vector3D:new(0, 0, 0) - if getPedControlState("forwards") then + if getPedControlState(localPlayer, "forwards") then Direction.y = 1 - elseif getPedControlState("backwards") then + elseif getPedControlState(localPlayer, "backwards") then Direction.y = -1 end - if getPedControlState("left") then + if getPedControlState(localPlayer, "left") then Direction.x = 1 - elseif getPedControlState("right") then + elseif getPedControlState(localPlayer, "right") then Direction.x = -1 end @@ -314,7 +314,7 @@ function Superman.processControls() local SightDirection = Vector3D:new((lookX - cameraX), (lookY - cameraY), (lookZ - cameraZ)) SightDirection:Normalize() - if getPedControlState("look_behind") then + if getPedControlState(localPlayer, "look_behind") then SightDirection = SightDirection:Mul(-1) end @@ -322,10 +322,10 @@ function Superman.processControls() local maxSpeed = MAX_SPEED local acceleration = ACCELERATION - if getPedControlState("sprint") then + if getPedControlState(localPlayer, "sprint") then maxSpeed = MAX_SPEED * EXTRA_SPEED_FACTOR acceleration = acceleration * EXTRA_ACCELERATION_FACTOR - elseif getPedControlState("walk") then + elseif getPedControlState(localPlayer, "walk") then maxSpeed = MAX_SPEED * LOW_SPEED_FACTOR acceleration = acceleration * LOW_ACCELERATION_FACTOR end @@ -449,7 +449,7 @@ function Superman.processFlight() self:restorePlayer(player) if player == localPlayer then setGravity(serverGravity) - triggerServerEvent("superman:stop", root) + triggerServerEvent("superman:stop", localPlayer) end elseif distanceToGround and distanceToGround < LANDING_DISTANCE then self:processLanding(player, Velocity, distanceToGround) @@ -476,7 +476,7 @@ function Superman:processIdleFlight(player) local Sight = Vector3D:new(lookX - cameraX, lookY - cameraY, lookZ - cameraZ) Sight:Normalize() - if getPedControlState("look_behind") then + if getPedControlState(localPlayer, "look_behind") then Sight = Sight:Mul(-1) end diff --git a/[gameplay]/superman/server.lua b/[gameplay]/superman/server.lua index 3eae6e1cf..4bca45d1f 100644 --- a/[gameplay]/superman/server.lua +++ b/[gameplay]/superman/server.lua @@ -1,24 +1,20 @@ local Superman = {} --- Static global values -local thisResource = getThisResource() - --- Resource events -addEvent("superman:start", true) -addEvent("superman:stop", true) - -- -- Start/stop functions -- function Superman.Start() local self = Superman + addEvent("superman:start", true) + addEvent("superman:stop", true) + addEventHandler("superman:start", root, self.clientStart) addEventHandler("superman:stop", root, self.clientStop) - addEventHandler("onPlayerJoin", root, Superman.setStateOff) -- + addEventHandler("onPlayerJoin", root, Superman.setStateOff) addEventHandler("onPlayerVehicleEnter", root, self.enterVehicle) end -addEventHandler("onResourceStart", getResourceRootElement(thisResource), Superman.Start, false) +addEventHandler("onResourceStart", resourceRoot, Superman.Start, false) function Superman.clientStart() setElementData(client, "superman:flying", true) From efea47a91ecf3d41913f0c97f40aae168828ce9d Mon Sep 17 00:00:00 2001 From: ds1-e <51768772+ds1-e@users.noreply.github.com> Date: Sat, 2 Nov 2024 04:53:21 +0100 Subject: [PATCH 2/3] Update meta.xml --- [gameplay]/superman/meta.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/[gameplay]/superman/meta.xml b/[gameplay]/superman/meta.xml index 603fa4994..7eee34f1f 100644 --- a/[gameplay]/superman/meta.xml +++ b/[gameplay]/superman/meta.xml @@ -1,5 +1,6 @@ - -