PlayerTextDrawSetString not working with 'format'

I don't usually ask for help, but for some reason this very simple piece of code has got my head spun upside down for last hour,

for example, this piece of code will display the textdraw fine
pawn Код:
PlayerTextDrawSetString(playerid, weaponAmmo[1][playerid], "TEST");
PlayerTextDrawShow(playerid, weaponAmmo[1][playerid]);
but this piece of code will not display the textdraw at all.
pawn Код:
format(str, 8, "TEST");
SendClientMessage(playerid, -1, str); //Message appears in chat fine

PlayerTextDrawSetString(playerid, weaponAmmo[1][playerid], str);
PlayerTextDrawShow(playerid, weaponAmmo[1][playerid]);
This is absolutely driving me insane.

I'm running the code under OnPlayerSpawn, I have tried other areas and it doesn't work anywhere, I've tried running the same code from the default 'grandlarc' game mode, and it didn't work there either.

I have no idea why this isn't working as I've done it like this in the past and it works fine.

Anyone have ANY idea why this is happening?
try it yourself, just in the grandlarc game mode under OnPlayerSpawn, it's not working!

Use format when you're going to use variable variables.

For example:

format(string, sizeof(string), "Test: %d", variable);

Otherwise just use PlayerTextDrawSetString like you did in the first example

PlayerTextDrawSetString(playerid, weaponAmmo[1][playerid], "TEST");

Thanks for the reply,
I understand how format works and the uses of it, I did that as an example to show it's not working.

I'm using format to display the players ammo,

pawn Код:
format(str, sizeof(str), "%d : %d", magazines, ammoInMag);
that is what I'm working on, but in my example you can see it's not working at all, even with just a blank statement reading "test".

Forum Jump:

Users browsing this thread: 1 Guest(s)