Efficient way using RAW File Proccessor
#1

Using 'format' like a hundred times doesn't looks like the most efficient way to script a file reading. I'm really confused at this and will appreciate if someone told me a better way to get around this.
Reply
#2

What do you mean using format? The only time you'd have to use that is formatting the player's name and directory of the INI file (assuming that's even how you save the files).
Reply
#3

Using 'format', for example, getting a player's AdminLevel. First we will have to use 'PlayerInfo[playerid][pInfo]' and save it in a string. Then we can write it in the user file. That 'format'
Reply
#4

Ah, I suppose you're correct there. However, there is nothing wrong with using the format function! You also wouldn't need to use the function more than once, as long as you format all values into one line:
pawn Code:
format(
   write, sizeof( write ), "Password=%s\r\nAdminLevel=%i\r\nScore=%i",
   PlayerInfo[ playerid ][ Password ],
   PlayerInfo[ playerid ][ AdminLevel ],
   GetPlayerScore( playerid )
);
The reason the more modern day INI systems don't use format to write to the file, at least not after the initial data is already in the file, is because they store what is read into variables.
Reply
#5

Alright thank you. Also, I would like you to ask you, why have you used the %i, instead of %d. As, GetPlayerScore and PlayerAdminLevel will be in numericals. I don't know what does %i does btw. Thanks for the reply.
Reply
#6

%i = %d. Integer or number. Without deciaml or so. Like 1, 2 or 19293. Not 99.7. That's a float.

Wiki link: https://sampwiki.blast.hk/wiki/Format
Reply
#7

Quote:
Originally Posted by Berlovan
View Post
%i = %d. Integer or number. Without deciaml or so. Like 1, 2 or 19293. Not 99.7. That's a float.

Wiki link: https://sampwiki.blast.hk/wiki/Format
So you mean it saves the value just like a float does, but only without a decimal?
Reply
#8

Both %i and %d do the same thing, I just prefer to use %i.
Reply
#9

It is used for saving a whole number. It does not work as a float. You can try that yourself! Use Pawno and the main() function. Let me give you an example!

new Float:a, Float:b;

main()
{
a = 10;
b = 5;
printf("a/b = %d",floatdiv(a,b));
}
Reply
#10

Thank you. +Rep for both of you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)