\" post=\"266673\" timestamp=\"1335936855\"]
#include <a_samp>
new Bannolva[MAX_PLAYERS];
stock Tiltas(playerid)
{
Bannolva[playerid] = 1;
SendClientMessage(playerid,-1,\"Ki lettél tiltva a szerverrõl!\");
Kick(playerid);
return 1;
}
#define Ban Tiltas
public OnPlayerConnect(playerid)
{
if(Bannolva[playerid] != 0)
{
Ban(playerid);
return 1;
}
return 1;
}
[/quote]
Ez full hülyeség.. xD
Délután megírom sscanf-al.
Dupla hozzászólás automatikusan összefûzve. ( aszitted mi? xD )
#include <a_samp>
#include <sscanf>
#include <zcmd>
public OnFilterScriptInit() { //Kiírja, hogy hány Banolt IP szerepel a listán (unatkoztam xD)
new File:file = fopen(\"bans.ban\", io_read),
line[128],
count = 0;
while(fread(file, line)) count++;
fclose(file);
printf(\"%d bans loaded\", count);
return 1;
}
public OnPlayerConnect(playerid) { //Ellenõrzi, hogy a játékos IPje szerepel-e a BAN listán
new File:banfile = fopen(\"bans.ban\", io_read),
line[128],
IP[32];
while(fread(banfile, line)) {
printf(\"reading %s\", line);
if(sscanf(line, \"s\", IP)) continue;
new len = strlen(line);
if((line[len - 1] == \'\\n\') || (line[len - 1] == \'\\r\')) {
line[len - 1] = 0;
if((line[len - 2] == \'\\n\') || (line[len - 2] == \'\\r\')) line[len - 2] = 0;
}
if(strcmp(line, IP, false)) {
SendClientMessage(playerid, -1, \"Ki vagy **szva haver..\"); //ezt írd át amire akarod.
Kick(playerid);
}
}
fclose(banfile);
return 1;
}
CMD:ban(playerid, params[]) { //rögtönzött Ban parancs, ne használd, csak példa, meg teszt.
new player1;
if(sscanf(params, \"d\", player1)) return 1;
BanPlayer(player1);
return 1;
}
stock BanPlayer(playerid) { // funkció, ami \'banolja\' a játékost. Ahol Ban-t használsz, ezt használd.
new File:bfile = fopen(\"bans.ban\", io_append)
bip[32],
bstr[128];
GetPlayerIp(playerid, bip, 32);
format(bstring, sizeof(bstring), \"%s\\r\\n\", bip);
fwrite(bfile, bstring);
fclose(bfile);
return Kick(playerid);
}
EDIT: sima sscanf függvényt használtam, ha plugint akarsz, akkor át kell írni 1 dolgot.