SA-MP Forums Archive
[HELP] Read From A File... - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Read From A File... (/showthread.php?tid=204626)



[HELP] Read From A File... - Larsey123IsMe - 30.12.2010

It compile fine.. but it dont work =/ and i have looked at Wiki, but mu english isent soo good =/


pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[64];
    new File:forbiddenwords = fopen("ForbiddenWords.txt", io_read);
    while(fread(forbiddenwords, string))
    {
        SendClientMessage(playerid, 0xFFFFFFF, "That word is forbidden!!!");
    }
    fclose(forbiddenwords);
    return 1;
}



Re: [HELP] Read From A File... - _rAped - 30.12.2010

First of all you are searching for a string that contains nothing.
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[64];
    new File:forbiddenwords = fopen("ForbiddenWords.txt", io_read);
    while(fread(forbiddenwords, string))
    {
        if(strfind(string, text, true) != -1)
        {
            return SendClientMessage(playerid, 0xFFFFFFF, "That word is forbidden!!!");
        }
    }
    fclose(forbiddenwords);
    return 1;
}



Re: [HELP] Read From A File... - Backwardsman97 - 30.12.2010

Ummmmmm... Try this.

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[64];
    new File:forbiddenwords = fopen("ForbiddenWords.txt", io_read);
    while(fread(forbiddenwords, string))
    {
        if(!strcmp(string,text))
        {
            SendClientMessage(playerid, 0xFFFFFFF, "That word is forbidden!!!");
            fclose(forbiddenwords);
            return 0;
    }
    }
    fclose(forbiddenwords);
    return 1;
}



Re: [HELP] Read From A File... - _rAped - 30.12.2010

Quote:
Originally Posted by Backwardsman97
Посмотреть сообщение
Ummmmmm... Try this.

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[64];
    new File:forbiddenwords = fopen("ForbiddenWords.txt", io_read);
    while(fread(forbiddenwords, string))
    {
        if(!strcmp(string,text))
        {
            SendClientMessage(playerid, 0xFFFFFFF, "That word is forbidden!!!");
            fclose(forbiddenwords);
            return 0;
    }
    }
    fclose(forbiddenwords);
    return 1;
}
Warnings: Loose intendation
And why do you loop the fclose()?


Re: [HELP] Read From A File... - Backwardsman97 - 30.12.2010

I don't. It returns 0 right after it closes it. Ending the loop. And if you want to complain about indentations...

pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        string[64],
        File:forbiddenwords = fopen("ForbiddenWords.txt", io_read);
       
    while(fread(forbiddenwords, string))
    {
        if(!strcmp(string,text))
        {
            SendClientMessage(playerid, 0xFFFFFFF, "That word is forbidden!!!");
            fclose(forbiddenwords);
            return 0;
        }
    }
    fclose(forbiddenwords);
    return 1;
}



Re: [HELP] Read From A File... - _rAped - 30.12.2010

Quote:
Originally Posted by Backwardsman97
Посмотреть сообщение
I don't. It returns 0 right after it closes it. Ending the loop. And if you want to complain about indentations...

pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        string[64],
        File:forbiddenwords = fopen("ForbiddenWords.txt", io_read);
       
    while(fread(forbiddenwords, string))
    {
        if(!strcmp(string,text))
        {
            SendClientMessage(playerid, 0xFFFFFFF, "That word is forbidden!!!");
            fclose(forbiddenwords);
            return 0;
        }
    }
    fclose(forbiddenwords);
    return 1;
}
Yeah just noticed, my bad.


Re: [HELP] Read From A File... - Larsey123IsMe - 30.12.2010

Thanks


Re: [HELP] Read From A File... - Larsey123IsMe - 30.12.2010

And GAH! lol

Sorry for double post tho...

pawn Код:
public OnPlayerConnect(playerid)
{
    new string[64], File:forbiddennames = fopen("ForbiddenNames.txt", io_read);

    while(fread(forbiddennames, string))
    {
        if(!strcmp(string))
        {
            SendClientMessage(playerid, 0xFFFFFFF, "Forbidden Name!!!");
            Kick(playerid);
            fclose(forbiddennames);
            return 0;
        }
    }
    fclose(forbiddennames);
    return 1;
}
Problem:
pawn Код:
C:\Users\Larsey123\Documents\SAMP Server\My server\filterscripts\OpenFile.pwn(26) : warning 202: number of arguments does not match definition
Line:
pawn Код:
if(!strcmp(string))



Re: [HELP] Read From A File... - _rAped - 30.12.2010

pawn Код:
if(!strcmp(string,text))



Re: [HELP] Read From A File... - Larsey123IsMe - 30.12.2010

Quote:
Originally Posted by _rAped
Посмотреть сообщение
pawn Код:
if(!strcmp(string,text))
Already tried.. Dont work =/

pawn Код:
error 017: undefined symbol "text"