Just to be sure
#1

Hi,
I am scripting a samp server and I have some questions here.(marked by numbers)

I've been using a variable "new message[400];" placed in the beginning of my file.
1- Please confirm me that I am creating 400 "messages" variables in the same variable "message[400]" with arrays?
2- I've noticed that if I put to many arrays in the variable the server can't open, why?

I keep using this script everytime i send aclient test message:
Quote:

format(message,sizeof(message),"The name %s is not found on the database.",pname);
SendClientMessage(playerid,COLOR_WHITE,message);

3- I understand a little why it get messed up but please someone tell me the exact truth?

4- Finally, why if i put more then lets say 400 character in the variable, it fails to have the rests, like if by calling "new message[400]" i'd say that the 400 is the avail. length in each string... why?

Thank you everyone
Reply
#2

Each 1 cell is 3-4 bytes.

What you're doing do you're doing is this:
4 * 400 = 1600 bytes.

You are not creating 400 "messages" though creating cells which in-large your AMX file and is really unefficent.
You might aswell create the variable Like:

pawn Код:
new message[41+MAX_PLAYER_NAME+10]; //41 characters in total, + the max player name and another extra 10 cells
Reply
#3

Quote:

1- Please confirm me that I am creating 400 "messages" variables in the same variable "message[400]" with arrays?

No, you are not. For every 'new message[400];' added, you're creating one new variable with 400 cells. This means you can fit 400 characters in to that variable, which is what we call a "string," because it strings together a combination of alphanumerical data.

Quote:

2- I've noticed that if I put to many arrays in the variable the server can't open, why?

Probably because you're consuming far too much memory.

Quote:

I keep using this script everytime i send aclient test message:
Quote:
format(message,sizeof(message),"The name %s is not found on the database.",pname);
SendClientMessage(playerid,COLOR_WHITE,message);
3- I understand a little why it get messed up but please someone tell me the exact truth?

pname is also a variable/string, if it's not created with 'new pname[(some number)];' then it will cause an error for your Pawn editor. If it is created, but there's no value assigned, it may return random symbols or nothing at all.

Quote:

4- Finally, why if i put more then lets say 400 character in the variable, it fails to have the rests, like if by calling "new message[400]" i'd say that the 400 is the avail. length in each string... why?

You can only send 128 characters per message in SA-MP, so you're wasting 272 cells, you should simply replace the 400 with 128. You should also read up on the SA-MP limits.
Reply
#4

Thanks guy for thoses rapid answer, I truly appreciate them they did helped me,,

2 things:

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Each 1 cell is 3-4 bytes.

You might aswell create the variable Like:

pawn Код:
new message[41+MAX_PLAYER_NAME+10]; //41 characters in total, + the max player name and another extra 10 cells
What are those 41 characters??


Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
pname is also a variable/string, if it's not created with 'new pname[(some number)];' then it will cause an error for your Pawn editor. If it is created, but there's no value assigned, it may return random symbols or nothing at all.
I know in this context pname was created

Thank you very much..
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)