@@ -1548,84 +1548,87 @@ end
15481548
15491549-- Mainly just wrappers to the other non-player functions
15501550function PlayerTextDrawDestroy (amx , player , textdrawID )
1551- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1551+ if not IsPlayerTextDrawValid (player , textdrawID ) then
15521552 return false
15531553 end
15541554 clientCall (player , ' TextDrawDestroy' , amx .name , textdrawID )
1555- amx . playertextdraws [player ][textdrawID ] = nil
1555+ g_PlayerTextDraws [player ][textdrawID ] = nil
15561556end
15571557function PlayerTextDrawShow (amx , player , textdrawID )
1558- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1558+ if not IsPlayerTextDrawValid (player , textdrawID ) then
1559+ outputDebugString (' PlayerTextDrawShow: not showing anything, not valid' )
15591560 return false
15601561 end
1561- local textdraw = amx .playertextdraws [player ][textdrawID ]
1562- local playerdata = g_Players [getElemID (player )]
1563- playerdata .visibletextdraws = playerdata .visibletextdraws or {}
1564- if not textdraw or playerdata .visibletextdraws [textdraw ] then
1565- return
1566- end
1562+ g_PlayerTextDraws [player ][textdrawID ].visible = true
15671563 clientCall (player , ' TextDrawShowForPlayer' , amx .name , textdrawID )
1568- playerdata .visibletextdraws [textdraw ] = true
15691564 return true
15701565end
15711566function PlayerTextDrawHide (amx , player , textdrawID )
1572- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1567+ if not IsPlayerTextDrawValid (player , textdrawID ) then
15731568 return false
15741569 end
1575- local textdraw = amx .playertextdraws [player ][textdrawID ]
1576- local playerdata = g_Players [getElemID (player )]
1577- playerdata .visibletextdraws = playerdata .visibletextdraws or {}
1578- if not textdraw or not playerdata .visibletextdraws [textdraw ] then
1579- return
1580- end
1570+ g_PlayerTextDraws [player ][textdrawID ].visible = false
15811571 clientCall (player , ' TextDrawHideForPlayer' , amx .name , textdrawID )
1582- playerdata .visibletextdraws [textdraw ] = nil
15831572end
15841573function PlayerTextDrawBoxColor (amx , player , textdrawID , r , g , b , a )
1585- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1574+ if not IsPlayerTextDrawValid (player , textdrawID ) then
15861575 return false
15871576 end
1588- amx . playertextdraws [player ][textdrawID ].boxcolor = { r , g , b , a }
1577+ g_PlayerTextDraws [player ][textdrawID ].boxcolor = { r , g , b , a }
15891578end
15901579function PlayerTextDrawUseBox (amx , player , textdrawID , usebox )
1591- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1580+ if not IsPlayerTextDrawValid (player , textdrawID ) then
15921581 return false
15931582 end
1594- amx .playertextdraws [player ][textdrawID ].usebox = usebox
1583+ local pId = getElemID (player )
1584+ if pId ~= nil then
1585+ g_PlayerTextDraws [player ][textdrawID ].usebox = usebox
1586+ end
15951587 return true
15961588end
15971589function PlayerTextDrawTextSize (amx , player , textdrawID , x , y )
1598- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1590+ if not IsPlayerTextDrawValid (player , textdrawID ) then
15991591 return false
16001592 end
1601- amx .playertextdraws [player ][textdrawID ].boxsize = { x , y }
1593+ local pId = getElemID (player )
1594+ if pId ~= nil then
1595+ g_PlayerTextDraws [player ][textdrawID ].boxsize = { x , y }
1596+ end
16021597 return true
16031598end
16041599function PlayerTextDrawLetterSize (amx , player , textdrawID , x , y )
1605- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1600+ if not IsPlayerTextDrawValid (player , textdrawID ) then
16061601 return false
16071602 end
1608- amx .playertextdraws [player ][textdrawID ].lwidth = width
1609- amx .playertextdraws [player ][textdrawID ].lheight = height
1603+ local playerId = getElemID (player )
1604+ g_PlayerTextDraws [player ][textdrawID ].lwidth = width
1605+ g_PlayerTextDraws [player ][textdrawID ].lheight = height
16101606 return true
16111607end
1612- function IsPlayerTextDrawValid (amx , player , textdrawID )
1613- if not amx .playertextdraws [player ] then
1608+ function IsPlayerTextDrawValid (player , textdrawID )
1609+ if not g_PlayerTextDraws [player ] then
1610+ outputDebugString (" [ERROR] IsPlayerTextDrawValid: g_PlayerTextDraws[player] is nil! for textdrawID: " .. textdrawID )
16141611 return false
16151612 end
1616- local textdraw = amx . playertextdraws [ player ] and amx . playertextdraws [player ][textdrawID ]
1613+ local textdraw = g_PlayerTextDraws [player ][textdrawID ]
16171614 if not textdraw then
1615+ outputDebugString (" [ERROR] IsPlayerTextDrawValid: no textdraw properties for player with textdrawID: " .. textdrawID )
16181616 return false
16191617 end
16201618 return true
16211619end
16221620function CreatePlayerTextDraw (amx , player , x , y , text )
1623- if not amx .playertextdraws [player ] then
1624- amx .playertextdraws [player ] = {}
1625- end
16261621 outputDebugString (' CreatePlayerTextDraw called with args ' .. x .. ' ' .. y .. ' ' .. text )
1627- local textdraw = { x = x , y = y , shadow = {align = 1 , text = text , font = 1 , lwidth = 0.5 , lheight = 0.5 } }
1628- local id = # amx .textdraws + table.insert (amx .playertextdraws [player ], textdraw ) -- I want the ids to always be greater than the other textdraws so they don't collide when trying to use certain functions to hide them
1622+
1623+ if ( not g_PlayerTextDraws [player ] ) then -- Create dimension if it doesn't exist
1624+ outputDebugString (' Created dimension for g_PlayerTextDraws[player]' )
1625+ g_PlayerTextDraws [player ] = {}
1626+ end
1627+
1628+ local textdraw = { x = x , y = y , shadow = {visible = 0 , align = 1 , text = text , font = 1 , lwidth = 0.5 , lheight = 0.5 } }
1629+ local id = # amx .textdraws + table.insert (g_PlayerTextDraws [player ], textdraw )
1630+
1631+ textdraw .id = id
16291632 setmetatable (
16301633 textdraw ,
16311634 {
@@ -1642,65 +1645,68 @@ function CreatePlayerTextDraw(amx, player, x, y, text)
16421645 end
16431646 end
16441647 if different then
1645- clientCall (player , ' TextDrawPropertyChanged' , amx .name , id , k , v )
1648+ outputDebugString (' A property changed for ' .. textdraw .id .. ' string: ' .. textdraw .text )
1649+ clientCall (player , ' TextDrawPropertyChanged' , amx .name , textdraw .id , k , v )
16461650 t .shadow [k ] = v
16471651 end
16481652 end
16491653 }
16501654 )
1655+
1656+ outputDebugString (' assigned id ' .. id .. ' to playertextdraws' )
16511657 clientCall (player , ' TextDrawCreate' , amx .name , id , table .deshadowize (textdraw , true ))
16521658 return id
16531659end
16541660function PlayerTextDrawAlignment (amx , playerid , textdrawID , align )
1655- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1661+ if not IsPlayerTextDrawValid (player , textdrawID ) then
16561662 return false
16571663 end
1658- amx . playertextdraws [player ][textdrawID ].align = (align == 0 and 1 or align )
1664+ g_PlayerTextDraws [player ][textdrawID ].align = (align == 0 and 1 or align )
16591665 return true
16601666end
16611667function PlayerTextDrawBackgroundColor (amx , playerid , textdrawID , r , g , b , a )
1662- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1668+ if not IsPlayerTextDrawValid (player , textdrawID ) then
16631669 return false
16641670 end
1665- amx . playertextdraws [player ][textdrawID ].outlinecolor = { r , g , b , a }
1671+ g_PlayerTextDraws [player ][textdrawID ].outlinecolor = { r , g , b , a }
16661672 return true
16671673end
16681674function PlayerTextDrawFont (amx , playerid , textdrawID , font )
1669- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1675+ if not IsPlayerTextDrawValid (player , textdrawID ) then
16701676 return false
16711677 end
1672- amx . playertextdraws [player ][textdrawID ].font = font
1678+ g_PlayerTextDraws [player ][textdrawID ].font = font
16731679 return true
16741680end
16751681function PlayerTextDrawColor (amx , playerid , textdrawID , r , g , b , a )
1676- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1682+ if not IsPlayerTextDrawValid (player , textdrawID ) then
16771683 return false
16781684 end
1679- amx . playertextdraws [player ][textdrawID ].color = { r , g , b }
1685+ g_PlayerTextDraws [player ][textdrawID ].color = { r , g , b }
16801686 return true
16811687end
16821688function PlayerTextDrawSetOutline (amx , playerid , textdrawID , size )
1683- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1689+ if not IsPlayerTextDrawValid (player , textdrawID ) then
16841690 return false
16851691 end
1686- amx . playertextdraws [player ][textdrawID ].outlinesize = size
1692+ g_PlayerTextDraws [player ][textdrawID ].outlinesize = size
16871693 return true
16881694end
16891695function PlayerTextDrawSetProportional (amx , playerid , textdrawID , proportional )
16901696 -- TextDrawSetProportional(amx, textdraw, proportional)
16911697end
16921698function PlayerTextDrawSetShadow (amx , playerid , textdrawID , size )
1693- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1699+ if not IsPlayerTextDrawValid (player , textdrawID ) then
16941700 return false
16951701 end
1696- amx . playertextdraws [player ][textdrawID ].shade = size
1702+ g_PlayerTextDraws [player ][textdrawID ].shade = size
16971703 return true
16981704end
16991705function PlayerTextDrawSetString (amx , playerid , textdrawID , str )
1700- if not IsPlayerTextDrawValid (amx , player , textdrawID ) then
1706+ if not IsPlayerTextDrawValid (player , textdrawID ) then
17011707 return false
17021708 end
1703- amx . playertextdraws [player ][textdrawID ].text = str
1709+ g_PlayerTextDraws [player ][textdrawID ].text = str
17041710 return true
17051711end
17061712-- End of player textdraws
@@ -3153,7 +3159,7 @@ g_SAMPSyscallPrototypes = {
31533159 TextDrawTextSize = {' x' , ' f' , ' f' },
31543160 TextDrawUseBox = {' x' , ' b' },
31553161 -- Player textdraws
3156- PlayerTextDrawDestroy = {' p' , ' s ' },
3162+ PlayerTextDrawDestroy = {' p' , ' i ' },
31573163 PlayerTextDrawShow = {' p' , ' i' },
31583164 PlayerTextDrawHide = {' p' , ' i' },
31593165 PlayerTextDrawBoxColor = {' p' , ' i' , ' c' },
0 commit comments