Just to be sure - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Just to be sure (
/showthread.php?tid=261573)
Just to be sure -
rt-2 - 14.06.2011
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
Re: Just to be sure -
Lorenc_ - 14.06.2011
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
Re: Just to be sure -
Calgon - 14.06.2011
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.
Re: Just to be sure -
rt-2 - 14.06.2011
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..