SA-MP Forums Archive
I never understood those - 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 never understood those (/showthread.php?tid=473900)



I never understood those - Battlezone - 05.11.2013

Please help, i tried my best to understand this but could not
Example: str[64] , str[256] ....
Why dont we use str[1] , or a str[a letter].. ?


Re: I never understood those - Keyhead - 05.11.2013

The number in the "[]" is defining the length of a string.

SA-MP Strings

Formatting strings

Understanding Strings


Re: I never understood those - Battlezone - 05.11.2013

OH thanks you very much!


Re: I never understood those - Keyhead - 05.11.2013

It's the amount of characters.

pawn Код:
CMD:test(playerid, params[])
{
    new string[128]; // Defining a new string and it's length
    format(string, 128, "Hello There, This is a test string!");// You define the "String", the length which is "128" and
    //The text in the "" is the actual string you're formatting.
    SendClientMessage(playerid, -1 ,string);// You then send it to the player.
    return 1;
}
Just look at the links I gave you.


Re: I never understood those - Battlezone - 05.11.2013

Thanks that was very helpful!