Strings...
Q1.
If you initialise a string like this Code:
Can I check if [1][5][2] is empty by doing this? Code:
--- Q2 If I do this in the global (outside any function) Code:
Wouldn't it reserve an awfull lot of memory by doing this? (24576 chars if I'm not mistaken, but I forgot how much an int takes) Or am I totally wrong, since I read somewhere that declaring variables globally is free storage. Should compare with C. Code:
|
No, you have to use something like:
Code:
Also, arrays are free storage, but Pawn zeroes each cell automatically. This is a huge CPU hit, so you should avoid making arrays that large if you can do it other ways. |
Lol, I took the if(!myString[0]) literally from another post.
Forgot to edit it to my needs :P Thanks :D |
Code:
Code:
2 * 32 * 3 * 128 = 24.576 BytesCode:
24.576 * 4 = 98,304 Bytes | 24.576 * 8 = 196.608 BytesCode:
98,304 / 1024 = 96 KB | 196.608 / 1024 = 192 KBstupid mistake |
Are you joking? It might be something like 192 kb, but if it was 192 mb then it would be impossible to do anything, there wouldn't be enough data on the computer.
Think logically. |
yea....byte go to KB before MB
|
Nice calculations GreenBeret :D
But, eh, 1 MB = 1048576 bytes --- You calculations are perfectly correct until the final outcome: Now divide this by 1024 so we have the KB Code:
98,304 / 1024 = 96 KB | 196.608 / 1024 = 192 KB |
Allright, next question:
I have a string that can contain 5 arguments maximum: %map%de_dust %map%de_dust%min_players%12 %map%de_dust%min_players%12%max_players%12 How can I put each different argument into another place? Map: de_dust Map: de_dust AND Minimal Players: 12 Map: de_dust AND Minimal Players: 12 AND Maximal Players: 12 -*- Parse can take an unkown amount of arguments, but I don't think it very suitable. Can this work? Code:
Firstly I don't even know if strfind will return the number of occurences. Secondly, I don't think it is very efficient. Does anyone else know a more efficient way to do this? |
parse or strbreak is what you want, probably parse. parse will split each argument into a string. If they only give 2 args, that's ok, it'll just make the 3 last strings empty.
|
oops sry^^
I forgot, that there is also the kb step :oops: |
| All times are GMT -4. The time now is 05:14. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.