I dont get any idea, what to do?
#1

Hello. I've made a Player Kill FS, what it does that if a player is killed in a roleplay, he gets kicked and his name is saved in the log. Now, OnPlayerConnect(), if the player comes with a name which is killed, it must kick him, but it doesn't work. It saves the name in the log, but it doesn't kick if someone comes with the name which is killed [the name in the log]. What to do?

CODE:

pawn Код:
public OnPlayerConnect(playerid)
{
    new Gpd[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Gpd, sizeof Gpd);
    fopen("PK_list.txt", io_read);
    if(fexist("PK_list.txt"))
    {
        fread(PK_Log, Gpd, sizeof Gpd);
        if(strcmp(Gpd,Gpd,true))
        {
            Kick(playerid);
        }
    }
    return 1;
}
Reply
#2

pawn Код:
public OnPlayerConnect(playerid)
{
    new Gpd[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Gpd, sizeof(Gpd));
    new File:killfile = fopen("PK_list.txt", io_read);
    if(fexist("PK_list.txt"))
    {
        new string[25];
        while(fread(killfile, string))
        {
            if(strcmp(Gpd, string, true) == 0)
            {
                Kick(playerid);
            }
        }
    }
    return 1;
}
You need to read line by line in this file, so you must use:
pawn Код:
while(fread(filename, stringtosaveto))
{
    if(strcmp(stringtofind, stringtosaveto, ignorecase) == 0)
    {
        //etc.
    }
}
As explained in: https://sampwiki.blast.hk/wiki/Fread
Reply
#3

pawn Код:
public OnPlayerConnect(playerid)
{
    new Gpd[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
    new File:PK_Log = fopen("PK_list.txt", io_read);
    if(fexist("PK_list.txt"))
    {
        while(fread(PK_Log, Gpd)
        {
            if(strcmp(Gpd,PlayerName,true)==0)
            {
                Kick(playerid);
            }
        }
    }
    return 1;
}
Try this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)