About string size cell numbers.
#1

Does it affect bad on your gamemode, if you for example have wrong numbers of cells?
Reply
#2

cell to small - sentence will be cut

cell to big - normal sentence, amx file will increase
Reply
#3

Yeah, but as far as i see it doesnt affect anything, why would people struggle on counting cells.
Reply
#4

Quote:
Originally Posted by wallen
View Post
Does it affect bad on your gamemode, if you for example have wrong numbers of cells?
Yes,

Here's a simple compare:

1- BAD:
PHP Code:
new PlayerName[128];
GetPlayerName(playeridPlayerNamesizeof(PlayerName)); 
2- GOOD:
PHP Code:
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playeridPlayerNamesizeof(PlayerName)); 
Because you're leaving that big array unused taking up space irrelevantly, why? it's really messy when people do random string[256] or string[128] for no absolute reason when it only needs 20/80 at the most.

It does, accumulating the unused variables/arrays building up is going to leave you with a big compiled file and longer time to compile, why?
Reply
#5

Thanks got the point now, appreciated
Reply
#6

im just gonna go made a memory located variable with 899999999999999999999999 null cells, my cpu won't die at all.










srsly, what even is this questions, it doesnt even have to do anything with samp scriptin
Reply
#7

Quote:
Originally Posted by Meller
View Post
im just gonna go made a memory located variable with 899999999999999999999999 null cells, my cpu won't die at all.










srsly, what even is this questions, it doesnt even have to do anything with samp scriptin
Self knowledge
Reply
#8

Quote:
Originally Posted by Meller
View Post
im just gonna go made a memory located variable with 899999999999999999999999 null cells, my cpu won't die at all.
CPU will be fine tho.
Reply
#9

This PlayerName is static array ?
Is it possible to create dynamic array that sets the size from the: sizeof(PlayerName) ?
Reply
#10

What was a problem long ago was the old

Code:
new string[256];
Code:
SendClientMessage(playerid, 1, string);
Same as the name example above... Where playername is only 32+1 or something, SendClientMessage can only send 144 characters, so the 256 is a waste of space, unless you do some breaking up of long-lines function.
Reply
#11

Quote:
Originally Posted by VeryTallMidget
Посмотреть сообщение
Is it possible to create dynamic array that sets the size from the: sizeof(PlayerName) ?
Pawn doesn't support dynamic allocation. There are some tricky library like ymalloc or any vector plugin can do this. But as far as I know dynamic allocation is not necessary in samp scripting.
Reply
#12

It's the same as going to buy a 2-seat sofa.
When you use a Smart vehicle, the sofa won't fit in the trunk of that Smart. Same as trying to store a playername in a string of size 5, it won't fit in there as a playername can be up to 24 chars long.
On the other hand, using a string of size 128 to store that playername (which is max 24 chars long), is the same as renting a truck + trailer (like the GTA Roadtrain + Article trailer) to buy that sofa, while you would do fine with your car and a trailer.
Using that Roadtrain+trailer will do the job too, but it's just overkill.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)