Skip to content

Fix deprecations, correct return values #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion amx/server/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ addEventHandler('OnPlayerPickUpPickup_Ev', root,

if model == 370 then
-- Jetpack pickup
givePedJetPack(player)
setPedWearingJetpack(player, true)
end
end
)
Expand Down
8 changes: 6 additions & 2 deletions amx/server/natives/a_actors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function DestroyActor(amx, actor)

removeElem(g_Actors, actor)
destroyElement(actor)
return true
end

function IsActorStreamedIn(amx, actorId, player)
Expand All @@ -22,27 +23,30 @@ end
function ApplyActorAnimation(amx, actor, animlib, animname, fDelta, loop, lockx, locky, freeze, time)
setPedAnimation(actor, animlib, animname, time, loop, lockx or locky, false, freeze)
setPedAnimationSpeed(actor, animname, fDelta)
return true
end

function ClearActorAnimations(amx, actor)
setPedAnimation(actor, false)
return setPedAnimation(actor, false)
end

function SetActorFacingAngle(amx, actor, ang)
local rotX, rotY, rotZ = getElementRotation(actor) -- get the local players's rotation
setElementRotation(actor, rotX, rotY, ang, "default", true) -- turn the player 10 degrees clockwise
return setElementRotation(actor, rotX, rotY, ang, "default", true) -- turn the player 10 degrees clockwise
end

function GetActorFacingAngle(amx, actor, refAng)
local rX, rY, rZ = getElementRotation(actor)
writeMemFloat(amx, refAng, rZ)
return true
end

function GetActorPos(amx, actor, refX, refY, refZ)
local x, y, z = getElementPosition(actor)
writeMemFloat(amx, refX, x)
writeMemFloat(amx, refY, y)
writeMemFloat(amx, refZ, z)
return true
end

-- stub
Expand Down
19 changes: 10 additions & 9 deletions amx/server/natives/a_mta.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function AddPlayerClothes(amx, player, type, index)
local texture, model = getClothesByTypeIndex(type, index)
addPedClothes(player, texture, model, type)
return addPedClothes(player, texture, model, type)
end

function GetPlayerClothes(amx, player, type)
Expand All @@ -13,7 +13,7 @@ function GetPlayerClothes(amx, player, type)
end

function RemovePlayerClothes(amx, player, type)
removePedClothes(player, type)
return removePedClothes(player, type)
end

-----------------------------------------------------
Expand All @@ -40,7 +40,7 @@ function IsPlayerInWater(amx, player)
end

function IsPlayerOnFire(amx, player)
return isPedOnFire(player)
return isElementOnFire(player)
end

function IsPlayerDucked(amx, player)
Expand All @@ -52,7 +52,7 @@ function IsPlayerOnGround(amx, player)
end

function SetPlayerOnFire(amx, player, state)
return setPedOnFire(player, state)
return setElementOnFire(player, state)
end

function GetPlayerStat(amx, player, stat)
Expand All @@ -69,8 +69,7 @@ end

function SetPlayerDoingDriveBy(amx, ped, state)
clientCall(root, 'setPedDoingGangDriveby', ped, state)
setElementData(ped, 'DoingDriveBy', state)
return true
return setElementData(ped, 'DoingDriveBy', state)
end

function GetPlayerCanBeKnockedOffBike(amx, ped)
Expand All @@ -79,7 +78,7 @@ end

function SetPlayerCanBeKnockedOffBike(amx, ped, state)
clientCall(root, 'setPedCanBeKnockedOffBike', ped, state)
setElementData(ped, 'CanBeKnockedOffBike', state)
return setElementData(ped, 'CanBeKnockedOffBike', state)
end

function SetPlayerWeaponSlot(amx, ped, slot)
Expand Down Expand Up @@ -141,6 +140,7 @@ end
function DestroyBot(amx, bot)
removeElem(g_Bots, bot)
destroyElement(bot)
return true
end

function GetBotState(amx, bot)
Expand Down Expand Up @@ -181,10 +181,11 @@ function GetBotRot(amx, ped, refX, refY, refZ)
writeMemFloat(amx, refX, rX)
writeMemFloat(amx, refY, rY)
writeMemFloat(amx, refZ, rZ)
return true
end

function SetBotRot(amx, Ped, rX, rY, rY)
setPedRotation(ped, rX, rY, rZ)
return setPedRotation(ped, rX, rY, rZ)
end

function GetBotName(amx, bot, nameBuf, bufSize)
Expand Down Expand Up @@ -580,7 +581,7 @@ end
-----------------------------------------------------

function ShowCursor(amx, player, show, controls)
showCursor(player, show, controls)
return showCursor(player, show, controls)
end

function AddEventHandler(amx, event, func)
Expand Down
27 changes: 20 additions & 7 deletions amx/server/natives/a_objects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function AttachObjectToObject(amx)
end

function AttachObjectToPlayer(amx, object, player, offsetX, offsetY, offsetZ, rX, rY, rZ)
attachElements(object, player, offsetX, offsetY, offsetZ, rX, rY, rZ)
return attachElements(object, player, offsetX, offsetY, offsetZ, rX, rY, rZ)
end

function SetObjectPos(amx, object, x, y, z)
Expand All @@ -34,24 +34,28 @@ function SetObjectPos(amx, object, x, y, z)
setElementVelocity(object, 0, 0, 0)
setTimer(setElementFrozen, 500, 1, object, false)
end

return true
end

function GetObjectPos(amx, object, refX, refY, refZ)
local x, y, z = getElementPosition(object)
writeMemFloat(amx, refX, x)
writeMemFloat(amx, refY, y)
writeMemFloat(amx, refZ, z)
return true
end

function GetObjectRot(amx, object, refX, refY, refZ)
local rX, rX, rZ = getObjectRotation(object)
writeMemFloat(amx, refX, rX)
writeMemFloat(amx, refY, rY)
writeMemFloat(amx, refZ, rZ)
return true
end

function SetObjectRot(amx, object, rX, rY, rY)
setObjectRotation(object, rX, rY, rZ)
return setObjectRotation(object, rX, rY, rZ)
end

function GetObjectModel(amx, objID)
Expand All @@ -72,17 +76,19 @@ end
function DestroyObject(amx, object)
removeElem(g_Objects, object)
destroyElement(object)
return true
end

function MoveObject(amx, object, x, y, z, speed)
local distance = getDistanceBetweenPoints3D(x, y, z, getElementPosition(object))
local time = distance/speed*1000
moveObject(object, time, x, y, z, 0, 0, 0)
setTimer(procCallOnAll, time, 1, 'OnObjectMoved', getElemID(object))
return true
end

function StopObject(amx, object)
stopObject(object)
return stopObject(object)
end

function IsObjectMoving(amx)
Expand All @@ -101,7 +107,7 @@ end
function SetPlayerObjectPos(amx, player, objID, x, y, z)
local obj = g_PlayerObjects[player] and g_PlayerObjects[player][objID]
if not obj then
return
return false
end
if obj.moving then
if isTimer(obj.moving.timer) then
Expand All @@ -111,15 +117,17 @@ function SetPlayerObjectPos(amx, player, objID, x, y, z)
end
obj.x, obj.y, obj.z = x, y, z
clientCall(player, 'SetPlayerObjectPos', objID, x, y, z)
return true
end

function SetPlayerObjectRot(amx, player, objID, rX, rY, rZ)
local obj = g_PlayerObjects[player] and g_PlayerObjects[player][objID]
if not obj then
return
return false
end
obj.rx, obj.ry, obj.rz = rX, rY, rZ
clientCall(player, 'SetPlayerObjectRot', objID, rX, rY, rZ)
return true
end

local function getPlayerObjectPos(amx, player, objID)
Expand Down Expand Up @@ -154,6 +162,7 @@ function GetPlayerObjectPos(amx, player, objID, refX, refY, refZ)
writeMemFloat(amx, refX, x)
writeMemFloat(amx, refY, y)
writeMemFloat(amx, refZ, z)
return true
end

function GetPlayerObjectRot(amx, player, objID, refX, refY, refZ)
Expand All @@ -164,6 +173,7 @@ function GetPlayerObjectRot(amx, player, objID, refX, refY, refZ)
writeMemFloat(amx, refX, obj.rx)
writeMemFloat(amx, refY, obj.ry)
writeMemFloat(amx, refZ, obj.rz)
return true
end

function GetPlayerObjectModel(amx, player, object)
Expand All @@ -178,12 +188,13 @@ end
function DestroyPlayerObject(amx, player, objID)
g_PlayerObjects[player][objID] = nil
clientCall(player, 'DestroyPlayerObject', objID)
return true
end

function MovePlayerObject(amx, player, objID, x, y, z, speed)
local obj = g_PlayerObjects[player] and g_PlayerObjects[player][objID]
if not obj then
return
return false
end
local distance = getDistanceBetweenPoints3D(x, y, z, getPlayerObjectPos(amx, player, objID))
local duration = distance/speed*1000
Expand All @@ -193,12 +204,13 @@ function MovePlayerObject(amx, player, objID, x, y, z, speed)
local timer = setTimer(procCallOnAll, duration, 1, 'OnPlayerObjectMoved', getElemID(player), objID)
obj.moving = { x = x, y = y, z = z, starttick = getTickCount(), duration = duration, timer = timer }
clientCall(player, 'MovePlayerObject', objID, x, y, z, speed)
return true
end

function StopPlayerObject(amx, player, objID)
local obj = g_PlayerObjects[player] and g_PlayerObjects[player][objID]
if not obj then
return
return false
end
if obj.moving then
obj.x, obj.y, obj.z = getPlayerObjectPos(amx, player, objID)
Expand All @@ -208,6 +220,7 @@ function StopPlayerObject(amx, player, objID)
obj.moving = nil
end
clientCall(player, 'StopPlayerObject', objID)
return true
end


Expand Down
Loading