SA-MP Forums Archive
Y_INI or Pawn - 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: Y_INI or Pawn (/showthread.php?tid=320132)



Y_INI or Pawn - ombre - 21.02.2012

Hi,

What's the better use Y_INI or original pawn for this check ban? (Call when the player connect in the server.)
Bans.txt is a file with many names, no key = val. so... original pawn is the best?
Код:
stock Ban(playerid)
{

    GetPlayerName(playerid,player,sizeof(player));
    file = fopen("Bans.txt",io_read);
    if (file)
    {
        while(fread(file,open,sizeof(open)))
        {
            if (strfind(open, player, true) != -1)
 	        {
	            SendClientMessage(playerid, ADMIN_RED, "You'r ban");
	            fclose(open);
                    Kick(playerid);
	            return 1;
	        }
    	}
    }
    fclose(file);
    return true;
}
thanks


Re: Y_INI or Pawn - admantis - 21.02.2012

There is little difference, but you are more comfort using the native file functions, because you open the file, read everything in one hit, and close it. That is what y_INI does, but I can't tell if there is something faster than the /original/ function.
The file format is a point up.

So yes, you might want to use it. Also, I recommend replacing "strfind" with "strcmp"; if the player "John" is banned, for example, "John2" will be banned too.


Re: Y_INI or Pawn - FuTuяe - 21.02.2012

MySQL Ftw.