Skip to content

Commit 95402ef

Browse files
committed
Make 3d text labels show, also fix formatting. Fixes regarding vehicle deletion. Remove some dummy functions that actually had their implementations already added.
1 parent d58ebc5 commit 95402ef

File tree

8 files changed

+36
-42
lines changed

8 files changed

+36
-42
lines changed

amx/client/client.lua

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,22 +1139,16 @@ function renderTextLabels()
11391139
end
11401140

11411141
local screenX, screenY = getScreenFromWorldPosition(textlabel.X, textlabel.Y, textlabel.Z, textlabel.dist, false)
1142-
local pX, pY, pZ = getElementPosition(localPlayer)
1142+
local pX, pY, pZ, _, _, _ = getCameraMatrix()--getElementPosition(localPlayer)
11431143
local dist = getDistanceBetweenPoints3D(pX, pY, pZ, textlabel.X, textlabel.Y, textlabel.Z)
11441144
local vw = getElementDimension(localPlayer)
1145-
--[[if textlabel.attached then
1146-
local LOS = isLineOfSightClear(pX, pY, pZ, textlabel.X, textlabel.Y, textlabel.Z, true, true, true, true, true, false, false, textlabel.attachedTo)
1147-
else]] --íåðàáîòàåò, ïîõîæå ôóíêöèÿ isLineOfSightClearíå ðàáîòàåò ñ àðãóìåíòîì ignoredElement.
1148-
local LOS = isLineOfSightClear(pX, pY, pZ, textlabel.X, textlabel.Y, textlabel.Z, true, false, false)--ïîêà òàê, ïîòîì ðàçáåðóòñÿ ñ ôóíêöèåé ñäåëàå êàê íóæíî :)
1149-
--end
1150-
local len = string.len(textlabel.text)
1151-
if screenX and dist <= textlabel.dist and vw == textlabel.vw then
1145+
local LOS = isLineOfSightClear(pX, pY, pZ, textlabel.X, textlabel.Y, textlabel.Z, true, false, false)
1146+
1147+
if screenX and dist <= textlabel.dist and (vw == textlabel.vw or textlabel.vw == -1) then --Because player textlabels don't have VW's, since we're processing both here
11521148
if not textlabel.los then
1153-
--dxDrawText(textlabel.text, screenX, screenY, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "default")--, "center", "center")--, true, false)
1154-
dxDrawText(textlabel.text, screenX, screenY, screenWidth, screenHeight, tocolor(textlabel.color.r, textlabel.color.g, textlabel.color.b, textlabel.color.a), 1, "default-bold")--, "center", "center", true, false)
1149+
dxDrawText(textlabel.text, screenX, screenY, screenX, screenY, tocolor(textlabel.color.r, textlabel.color.g, textlabel.color.b, textlabel.color.a), 1.0, "default-bold", "center", "top", false, false, false, true)
11551150
elseif LOS then
1156-
--dxDrawText(textlabel.text, screenX, screenY, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "default")--, "center", "center")--, true, false)
1157-
dxDrawText(textlabel.text, screenX - (len), screenY, screenWidth, screenHeight, tocolor(textlabel.color.r, textlabel.color.g, textlabel.color.b, textlabel.color.a), 1, "default-bold")--, "center", "center", true, false)
1151+
dxDrawText(textlabel.text, screenX, screenY, screenX, screenY, tocolor(textlabel.color.r, textlabel.color.g, textlabel.color.b, textlabel.color.a), 1.0, "default-bold", "center", "top", false, false, false, true)
11581152
end
11591153
end
11601154
end
@@ -1182,6 +1176,7 @@ function Create3DTextLabel(id, textlabel)
11821176
textlabel.id = id
11831177
textlabel.enabled = false
11841178
g_TextLabels[id] = textlabel
1179+
outputConsole('Created text label with id ' .. textlabel.id)
11851180
end
11861181

11871182
function Delete3DTextLabel(id)
@@ -1190,7 +1185,9 @@ function Delete3DTextLabel(id)
11901185
end
11911186

11921187
function Attach3DTextLabel(textlabel)
1188+
outputConsole('Attaching text label with id ' .. textlabel.id)
11931189
local id = textlabel.id
1190+
textlabel.enabled = true
11941191
g_TextLabels[id] = textlabel
11951192
end
11961193

amx/server/defines.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ PLAYER_VARTYPE_FLOAT = 3
201201

202202
INVALID_ACTOR_ID = 0xFFFF
203203
INVALID_OBJECT_ID = 0xFFFF
204+
INVALID_PLAYER_ID = 0xFFFF
205+
INVALID_VEHICLE_ID = 0xFFFF
204206

205207
ManualVehEngineAndLights = false
206208
ShowUnimplementedErrors = false

amx/server/events.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ addEventHandler('onVehicleEnter', root,
415415
end
416416

417417
if ManualVehEngineAndLights then
418-
if (getVehicleType(source) ~= "Plane" and getVehicleType(source) ~= "Helicopter") then
418+
if (g_Vehicles[vehID] and getVehicleType(source) ~= "Plane" and getVehicleType(source) ~= "Helicopter") then
419419
setVehicleEngineState(source, g_Vehicles[vehID].engineState)
420420
end
421421
end
@@ -495,7 +495,7 @@ addEventHandler('onVehicleExplode', root,
495495

496496
procCallOnAll('OnVehicleDeath', vehID, 0) -- NOES, MY VEHICLE DIED
497497

498-
if g_Vehicles[vehID].respawntimer then
498+
if g_Vehicles[vehID] and g_Vehicles[vehID].respawntimer then
499499
killTimer(g_Vehicles[vehID].respawntimer)
500500
g_Vehicles[vehID].respawntimer = nil
501501
end

amx/server/natives/a_objects.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
function CreateObject(amx, model, x, y, z, rX, rY, rZ)
2-
outputConsole('CreateObject(' .. model .. ')')
32
local obj = createObject(model, x, y, z, rX, rY, rZ)
43
if obj == false then
54
obj = createObject(1337, x, y, z, rX, rY, rZ) --Create a dummy object anyway since createobject can also be used to make camera attachments
@@ -88,7 +87,6 @@ function IsObjectMoving(amx)
8887
end
8988

9089
function CreatePlayerObject(amx, player, model, x, y, z, rX, rY, rZ)
91-
outputConsole('CreatePlayerObject(' .. model .. ')')
9290
if not g_PlayerObjects[player] then
9391
g_PlayerObjects[player] = {}
9492
end

amx/server/natives/a_players.lua

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -854,11 +854,6 @@ function SetPlayerVirtualWorld(amx, player, dimension)
854854
setElementDimension(player, dimension)
855855
end
856856

857-
function GetPlayerVirtualWorld(amx)
858-
notImplemented('GetPlayerVirtualWorld')
859-
return false
860-
end
861-
862857
function EnableStuntBonusForAll(amx, enable)
863858
notImplemented('EnableStuntBonusForAll')
864859
end

amx/server/natives/a_samp.lua

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,6 @@ function GetVehiclePoolSize(amx)
201201
return highestId
202202
end
203203

204-
205-
function GetActorPoolSize(amx)
206-
notImplemented('GetActorPoolSize')
207-
return false
208-
end
209-
210204
-- Security
211205

212206
function SHA256_PassHash(amx, pass, salt, ret_hash, ret_hash_len)
@@ -824,11 +818,7 @@ function GangZoneStopFlashForAll(amx, zone)
824818
end
825819

826820
function Create3DTextLabel(amx, text, r, g, b, a, x, y, z, dist, vw, los)
827-
text = text:lower()
828-
for mta,samp in pairs(g_CommandMapping) do
829-
text = text:gsub('/' .. samp, '/' .. mta)
830-
end
831-
local textlabel = { text = text, color = {r = r, g = g, b = b, a = a}, X = x, Y = y, Z = z, dist = dist, vw = vw, los = los }
821+
local textlabel = { text = colorizeString(text), color = {r = r, g = g, b = b, a = a}, X = x, Y = y, Z = z, dist = dist, vw = vw, los = los }
832822
local id = table.insert(g_TextLabels, textlabel)
833823

834824
textlabel.id = id
@@ -837,17 +827,29 @@ function Create3DTextLabel(amx, text, r, g, b, a, x, y, z, dist, vw, los)
837827
return id
838828
end
839829

840-
function CreatePlayer3DTextLabel(amx, player, text, r, g, b, a, x, y, z, dist, vw, los)
841-
text = text:lower()
842-
for mta,samp in pairs(g_CommandMapping) do
843-
text = text:gsub('/' .. samp, '/' .. mta)
844-
end
845-
local textlabel = { text = text, color = {r = r, g = g, b = b, a = a}, X = x, Y = y, Z = z, dist = dist, vw = vw, los = los }
830+
function CreatePlayer3DTextLabel(amx, player, text, r, g, b, a, x, y, z, dist, attachedplayer, attachedvehicle, los)
831+
local textlabel = { text = colorizeString(text), color = {r = r, g = g, b = b, a = a}, X = x, Y = y, Z = z, dist = dist, vw = -1, los = los, attached = false }
846832
local id = table.insert(g_TextLabels, textlabel)
847833

848-
textlabel.id = id
834+
textlabel.id = id
835+
if attachedplayer ~= INVALID_PLAYER_ID or attachedvehicle ~= INVALID_VEHICLE_ID then
836+
textlabel.attached = true
837+
end
849838

839+
if attachedplayer ~= INVALID_PLAYER_ID then
840+
textlabel.attachedTo = g_Players[attachedplayer] and g_Players[attachedplayer].elem
841+
end
842+
843+
if attachedvehicle ~= INVALID_VEHICLE_ID then
844+
textlabel.attachedTo = g_Vehicles[attachedvehicle] and g_Vehicles[attachedvehicle].elem
845+
end
846+
847+
textlabel.offX = 0.0
848+
textlabel.offY = 0.0
849+
textlabel.offZ = 0.0
850+
850851
clientCall(root, 'Create3DTextLabel', id, textlabel)
852+
851853
return id
852854
end
853855

amx/server/natives/a_vehicles.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
CreateVehicle = AddStaticVehicleEx
22

33
function DestroyVehicle(amx, vehicle)
4-
clientCall(root, 'DestroyVehicle', getElemID(vehicle))
5-
removeElem(g_Vehicles, vehicle)
64
local vehicleID = getElemID(vehicle)
5+
clientCall(root, 'DestroyVehicle', vehicleID)
76
for i,playerdata in pairs(g_Players) do
87
playerdata.streamedVehicles[vehicleID] = nil
98
end
9+
removeElem(g_Vehicles, vehicle)
1010
destroyElement(vehicle)
1111
end
1212

amx/server/syscalls.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ g_SAMPSyscallPrototypes = {
655655
HTTP = {'i', 'i', 's', 's', 's'},
656656

657657
Create3DTextLabel = {'s', 'c', 'f', 'f', 'f', 'f', 'i', 'i'},
658-
CreatePlayer3DTextLabel = {'p', 's', 'c', 'f', 'f', 'f', 'f', 'i', 'i'},
658+
CreatePlayer3DTextLabel = {'p', 's', 'c', 'f', 'f', 'f', 'f', 'i', 'i', 'i'},
659659
Delete3DTextLabel = {'a'},
660660
DeletePlayer3DTextLabel = {'p', 'a'},
661661
Attach3DTextLabelToPlayer = {'a', 'p', 'f', 'f', 'f'},

0 commit comments

Comments
 (0)