SA-MP Forums Archive
loop break - 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: loop break (/showthread.php?tid=582703)



loop break - Lajko1 - 22.07.2015

Guys with this command it instantly saves me 50 (I have set limit to 50) lines of same reason I insert in command
So the question is how can I make that it will save it to only 1 line when I execute the command?

pawn Код:
#define LIMIT 50
new CrimeReasons[MAX_PLAYERS][LIMIT];
pawn Код:
CMD:makewanted(playerid,params[])
{
    new id, reason[80], string[50];
    if(sscanf(params, "us[80]",id ,reason)) return SendClientMessage(playerid,-1,"USAGE: REPORT <PlayerID/Part of Name> <Reason>");
    new INI:File = INI_Open(UserPath(id));
    for(new i;i<LIMIT;i++)
    {
        format(CrimeReasons[id][i],128,reason); // Params is the crime reason maybe you already have it formated then use the name of formated string
        format(string, sizeof(string), "Crime%d", i);  //To save in yini Crime1=50
        INI_WriteString(File,string,CrimeReasons[id][i]); // string and the crime reason being written
    }
    INI_Close(File);//Closing yini file
    return 1;
}



Re: loop break - J4Rr3x - 22.07.2015

Just add a "break;" under INI_WriteString(File,string,CrimeReasons[id][i]);


Re: loop break - Lajko1 - 22.07.2015

With this it doesn't make new line in player's file it keeps re-writing only 1 Crime that was saved in file, I want to make each crime = new line in player's saving file.


Re: loop break - xVIP3Rx - 22.07.2015

Maybe that's because you only have one crime ? even though it should write the crimeX, what's in the INI file and are you sure it's the right one ?

also how much is "LIMIT" ?


Re: loop break - Lajko1 - 22.07.2015

I'm using this:

pawn Код:
#define LIMIT 50
new CrimeReasons[MAX_PLAYERS][LIMIT];



Re: loop break - xVIP3Rx - 22.07.2015

Quote:
Originally Posted by Lajko1
Посмотреть сообщение
So the question is how can I make that it will save it to only 1 line when I execute the command?
Wait what are you trying to do ? Save them all in one line, I think that's impossible (or hard to do) using files


Re: loop break - Lajko1 - 23.07.2015

I told this many times, all I want to do is command /makewanted (id) (reason) which will save the crime to new line when I will use the command... so in my saving file it would look like this:

Crime0: Test1
Crime1: Test2
Crime2: Test3


Re: loop break - Lajko1 - 23.07.2015

Still need help with that..