Using GameTextForAll with a string doesn't work.
#1

I'm working on a simple script, but somehow I've got a bug or problem I've never seen before.

pawn Код:
format(string, sizeof(string), "~%s~%i", color, messageNumber);
        print(string);
        GameTextForAll(string, 1000, 4);
This piece of code will show the messagenumber with the default color, it doesn't matter what color is.

e.g color = b(blue), messageNumber = 2.
The GameText will not show the color, just the integer 2.
I tried to debug it, but that shows the correct string: "~b~2".
Reply
#2

ex usage: /gt b 1337

GameText out put: 1337

pawn Код:
COMMAND:gt(playerid, params[])
{
    new color[2], messageNumber;
    if(sscanf(params, "s[2]d", color, messageNumber)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /gt (color) (number message)");
    {
        new string[128];
        format(string, sizeof(string), "~%s~ %d", color, messageNumber);
        GameTextForAll(string, 1000, 4);
    }
    return 1;
}
Reply
#3

I'm having almost the exact same code. Anyway, it still doesn't work.
Reply
#4

I do not know why people seem to think all the time that colors are strings, because they are not. Colors are just numbers. A little more into depth: Wanna know why using -1 as color gives you white? Contrary to popular believe, it is not the 'default' color, but white (well, technically that's the default color, but if the SA-MP team decides to change it to something else, it won't be anymore). -1 equals 0xFFFFFFFF in hexadecimal notation (try it on a calculator), which - as you may know - is white.

So use %d instead of %s in your format.

Edit: nvm, didn't read it well. How did you define your 'color' variable?
Reply
#5

Quote:
Originally Posted by Biesmen
Посмотреть сообщение
I'm having almost the exact same code. Anyway, it still doesn't work.
Works fine for me.



Image 1
Image 2
Reply
#6

@CyberGhost; Weird.

@Vince
new color[2];

Edit:
It's fixed, I had a typo.
Reply
#7

Hmm, I actually had to look this up in the Pawn manual, but try like this:
pawn Код:
format(string, sizeof(string), "~%c~%d", color[0], messageNumber);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)