SA-MP Forums Archive
Writing multiple strings into one message - 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)
+--- Thread: Writing multiple strings into one message (/showthread.php?tid=388787)



Writing multiple strings into one message - EV007 - 30.10.2012

I've got a IP file of a player which contains some data, how could I read every data(without the values) and send a SINGLE message which would list every data it red from the file?


Re: Writing multiple strings into one message - EV007 - 30.10.2012

Trying my best to be specific. I log every different name to his ip file when the player connects to the server. I want to list those names into one message and send it so people know the names he used in the past


Re: Writing multiple strings into one message - tyler12 - 30.10.2012

What are you using to save it?


Re: Writing multiple strings into one message - EV007 - 30.10.2012

How can I display every name he used in one message? I've seen servers do similar thing, but don't know to do it. I'm using SII


Re: Writing multiple strings into one message - EV007 - 31.10.2012

What do you mean read it in one block? Read everything during the first time and store it into string? I've never used reading/writing functions so much before.. Can you please give me a more detailed explanation?


Re: Writing multiple strings into one message - Wayn - 31.10.2012

Do you mean something like this?
Код:
format(String, sizeof(String), "*%s (ID:%d)joined the server( OtherNicks: %s , %s , %s )",PlayerName,PlayerID,PlayerName2,PlayerName3,PlayerName4);
This is showing more than one names per string


Re: Writing multiple strings into one message - EV007 - 31.10.2012

No. I need to make a loop somehow which loops every in the file so i could make the one string with his names.. Although SII already loops every line with this:
pawn Код:
new name[20];
INI_ReadString(name, pName(playerid),20);
I don't know how to get every single string it red through


Re: Writing multiple strings into one message - Unte99 - 31.10.2012

So you have to have a player variable that contains his all used nick names with that registered IP of his. When the player registers, add the first used name (Big_Benny or something...) to the variable. Then, when the player uses another name, just add it to the variable. For that adding part, your'e going to need str library. To detect the position of the last letter of the name and add another name at the end. But don't forget to check the IP, if the IP that is stored in the file is the same as the player's.


EDIT: I don't think that I have to explain the name showing part, yes ?


Re: Writing multiple strings into one message - EV007 - 31.10.2012

I don't use variables to display or save the name.

pawn Код:
new nicks;
new name[100];
new File:pipfile = fopen(string, io_read);
        nicks = fblockread(pipfile, name, 100);
        if(nicks > 0)
        {
            printf("Nicks red: %d",nicks);
        }
        for (new i = 0; i < 6; i++)
        {
            printf("%s", name[i]);
        }
        fclose(pipfile);
I'm getting somewhere, tried messing around with the string sizes a bit, but it's not really working as I expect it to since I just started with this function and haven't figured out how it works yet. Can you give me a hint on what I should be focusing? It prints out 3lines,each one has a part of the name that's written in the file and the string size keeps getting lower during each line display.


Re: Writing multiple strings into one message - Unte99 - 31.10.2012

Quote:
Originally Posted by EV007
Посмотреть сообщение
I don't use variables to display or save the name.
pawn Код:
new nicks;
new name[100];
printf("Nicks red: %d",nicks);
printf("%s", name[i]);
I'm sorry... I'm a little confused... So what is

pawn Код:
new name[100];
and

pawn Код:
printf("%s", name[i]);
if they aren't variables ? And to tell you the truth, aren't you showing names by printing them in the console (log file) ?