[HELP] Read From A File...
#1

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;
}
Reply
#2

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;
}
Reply
#3

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;
}
Reply
#4

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()?
Reply
#5

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;
}
Reply
#6

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.
Reply
#7

Thanks
Reply
#8

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))
Reply
#9

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)