Can someone help explain
#1

new string[6] = "Hello";

Ok look how did we get [6] there i need serious help

How is it [6] how to get what i put there?

So like if i want like new string[6] = "gun";
Where do i get this value [6] to replace with and how to find it? what is this called?
Reply
#2

You're creating what's called an array. 6 is the number of cells in the array, each cell can contain 32 bits of information and in PAWN each cell can contain a single character. So we're basically forming a string that can contain 6 characters (from 0 to 5 in the array).

pawn Код:
new arr[6] = "Hello";

// It looks like this:

arr[0] = 'H';
arr[1] = 'e';
arr[2] = 'l';
arr[3] = 'l';
arr[4] = 'o';
So as you can see, you actually have one cell left over (cell 5), now you might be thinking what about cell 6? Well that cell is actually unusable. So in total, you have 6 cells, and you're using 5 of them.

These define a space in memory (RAM) during server runtime, so it's best not to create ridiculously over-sized variables that will never be completely made use of.

Does that help?

You should consider reading the PAWN manuals over at Compuphase and maybe some basic generic programming tutorials.
Reply
#3

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
So as you can see, you actually have one cell left over (cell 5), now you might be thinking what about cell 6? Well that cell is actually unusable. So in total, you have 6 cells, and you're using 5 of them.
Nope, one cell isn't left over. It's actually being used.
Read, http://en.wikipedia.org/wiki/Null-terminated_string
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)