Sall issue
#1

How can I create a file specified to each player, which open randomly and only for a certain player ? I tried to add this but It didn't work it gave me a warning:
pawn Код:
number of arguments does not match definition
pawn Код:
new File:example = fopen("adminjail/%s.txt", io_write, sendername);
Reply
#2

%s is a format sign, you can only use it in format. https://sampwiki.blast.hk/wiki/Format
So format the string at first, and then use it for fopen:

pawn Код:
new fname[32];
format(fname, 32, "adminjail/%s.txt", sendername);
new File:example = fopen(fname, io_write);
Reply
#3

Код:
new filename[128];
format(filename,sizeof(filename),"adminjail/%s.txt",sendername);
new File:jail=fopen(string,io_readwrite);
i presume you already got the sendername as string.
the fopen only takes the filename, and the read/writemode as parameters, so you need to create the string for the filename first. thats all
Reply
#4

I have last question, when I try to put it into a read command it just shows:
PHP код:
adminjail/%username.txt 
and here is the reading file code:
pawn Код:
if (strcmp(cmd, "/killrecord", true) ==0 )
    {
        if(IsPlayerConnected(playerid))
        {
       
            {
    GetPlayerName(playerid, sendername, sizeof(sendername));
       format(string, sizeof(string), "adminjail/%s.ini", sendername);
       new File:example = fopen(string, io_read);
       if (example)
           
     fread(example, string)    
    fclose(example); // Close the file
    format(string, 256, "Admin kills: %s", string);
    SendClientMessage(playerid, COLOR_GRAD1, string);
    printf("%s",string); // Print what was read
return 1;
            }
and here is the openfile script:
pawn Код:
GetPlayerName(playerid, sendername, sizeof(sendername));
                        new fname[32];
                        format(fname, 32, "adminjail/%s.ini", sendername);
                        new File:example = fopen(fname, io_write);
                        format(string, 256, "%s was killed by Admin %s time: %d min ago, weapons: %s", giveplayer, sendername, jailtime, (result));
                        fwrite(example, string);
                        fclose(example);
Reply
#5

It worked, but It only ads one line, when I re kill someone it edits his current file and the current line and makes it a new line, without showing the previous kill how can I remove that ? .
Reply
#6

Код:
new File:example = fopen(fname, io_append);
should solve it. the io_write creates a new file, thats not what you want
also you can try to add a "\n" to the very end of the string in format() , so each entry will start at a new line.
Reply
#7

It worked, but only in the file I can see the logs, while I use the command it only shows the first kill log, how can I show everything ?
my reading command is :
pawn Код:
new File:example = fopen(string, io_read);
fread(example, string);
Reply
#8

I think that the problem is with the length, can anyone tell me how to increase the length of the message that will appear in game while showing the kill logs ?
I noticed that it only shows half of the first killlog,
Reply
#9

Quote:
Originally Posted by Scriptissue
Посмотреть сообщение
I think that the problem is with the length, can anyone tell me how to increase the length of the message that will appear in game while showing the kill logs ?
I noticed that it only shows half of the first killlog,
Well the SA-MP chat only supports 128 length output, so if you want to show more information in-game, then you need to split it into more lines and send them all out one by one.

You could make use of strmid for splitting the string into two strings at the max length of the chat output.

https://sampwiki.blast.hk/wiki/Strmid
Reply
#10

Edit it didn't work, here is what I did
this is only part of the script that attached the content into the file,
I can't see everything as usual nothing changed, still looks like parts from the kill logs are missing due to the lack of lengh
pawn Код:
new wstring[128];
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        new fname[32];
                        format(fname, 32, "adminjail/%s.ini", sendername);
                        new File:example = fopen(fname, io_append);
                        format(string, 256, "%s was admin jailed by Admin %s for: %d min, Reason: %s", giveplayer, sendername, jailtime, (result));
                        strmid(wstring, string, 0, strlen(string), 255);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)