09.06.2012, 06:22
There's no such thing as a string in pawn, it's just an array of " X * cell" and you can assign each cell one character.
In order to assign each cell with a character people designed format. Using format like this:
is SORT OF equal to
While format would be an equivalant of:
For your other question, you should use OnPlayerStateChange because OnPlayerUpdate is called WHENEVER something changes for the user which is pretty much ALL THE TIME resulting in the function literally being called almost every TICK. OnPlayerStateChange ONLY gets called when the STATE changes of the player.
EDIT:
And I forgot to mention that this obviously simplifies the insertion of other strings or data into an array e.g.
EDIT2:
Just so you understand the example above!
Hope it helps,
Regards.
In order to assign each cell with a character people designed format. Using format like this:
pawn Код:
new str[64];
format(str, 64, "Hello");
pawn Код:
for(new i = 0; i < 64; i++)
{
if(i<arraysize)
{
string[i] = array[i];
}
else
{
string[i] == 0;
break;
}
}
pawn Код:
format(string, loopmax, array);
For your other question, you should use OnPlayerStateChange because OnPlayerUpdate is called WHENEVER something changes for the user which is pretty much ALL THE TIME resulting in the function literally being called almost every TICK. OnPlayerStateChange ONLY gets called when the STATE changes of the player.
EDIT:
And I forgot to mention that this obviously simplifies the insertion of other strings or data into an array e.g.
pawn Код:
new number, new Float:floats, new str[128], new hello[32];
format(hello, 32, "Hello");
number = 1;
floats = 2.0;
format(str, 128, "Hello: %s Number: %d Float: %f", hello, number, floats);
pawn Код:
%s = string
%d = double (same as integer, theres no difference for pawn)
%i = integer (aka number)
%f = float (aka floating point number aka 1.123456)
Hope it helps,
Regards.