'%i' and 'random(5)+1' sometimes creates a blank string - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: '%i' and 'random(5)+1' sometimes creates a blank string (
/showthread.php?tid=589852)
FIXED. '%i' and 'random(5)+1' sometimes creates a blank string -
Sellize - 23.09.2015
So with this code, sometimes it shows a blank space instead of the number. Most of the time it works but sometimes it just doesn't show anything.
PHP код:
new am = random(5)+1;
new str[128];
format(str, sizeof(str), "~w~Collected ~b~%i~w~ lumber.", am);
GameTextForPlayer(playerid, str, 3000, 4);
Re: '%i' and 'random(5)+1' sometimes creates a blank string -
thefirestate - 23.09.2015
This is the code I used and it worked perfectly for me(made a randomnum CMD and spammed it 10000 times, no problem):
new am = random(5)+1;
new str[128];
format(str, sizeof(str), "~w~Collected~b~ %d ~w~lumber.", am);
GameTextForPlayer(playerid, str, 3000, 4);
Re: '%i' and 'random(5)+1' sometimes creates a blank string -
Lordzy - 23.09.2015
Just add a space after embedding your gametext ("~b~"). This is an issue found on GameText functions.
Re: '%i' and 'random(5)+1' sometimes creates a blank string -
Sellize - 23.09.2015
Quote:
Originally Posted by thefirestate
This is the code I used and it worked perfectly for me(made a randomnum CMD and spammed it 10000 times, no problem):
new am = random(5)+1;
new str[128];
format(str, sizeof(str), "~w~Collected~b~ %d ~w~lumber.", am);
GameTextForPlayer(playerid, str, 3000, 4);
|
It works like 90% of the time for me too, but sometimes this happens... :
http://imgur.com/2YO8pwe
Quote:
Originally Posted by Lordzy
Just add a space after embedding your gametext ("~b~"). This is an issue found on GameText functions.
|
Thanks, repped you both, didn't see the space at first.
Re: '%i' and 'random(5)+1' sometimes creates a blank string -
thefirestate - 23.09.2015
That's actually what I done, apart from changing %i to %d

, have you add spaces between, exactly as mine looks?