-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Description
- Problem:
From the TextDrawCreate wiki page:
If the last character in the text is a space (" "), the text will all be blank.
It also happens for gametexts. Not sure if it happens in TextDrawSetString too (probably does).
- Possible solution/implementation:
Hook TextDrawCreate/TextDrawSetString/GameTextForPlayer/GameTextForAll and let them look like
stock ALS_HookedFunction( [..,] text[ ] [, ..] )
{
if( text[ 0 ] != EOS && text[ 1 ] != EOS )
{
new lLastPos = 0;
for( new i = 1; text[ i ] != EOS; i ++ )
{
if( text[ i ] != ' ' )
lLastPos = i;
}
text[ lLastPos + 1 ] = EOS;
}
return HookedFunction( [..,] text [, ..] );
}
I think that I also managed to allow " " as a valid text. Maybe someone can come with a better/shorter alternative, if possible. I didn't use strlen
because the code would be slower. Here are the tests:
'' -> ''
' ' -> ' '
'a' -> 'a'
'a ' -> 'a'
'ab' -> 'ab'
'ab ' -> 'ab'
'a b' -> 'a b'
'a b ' -> 'a b'
'a b ' -> 'a b'
rt-2
Metadata
Metadata
Assignees
Labels
No labels