OnPlayerText
#1

hey guys im trying to make this Stuff which won't Allow a player to use offensive/bad language, so here is it what i made, but the problem is, compiling shows errors, here is my code :

pawn Код:
if(text[0] == 'fuck') {
        SendClientMessage(playerid, yellow, "That's Not Allowed In This Server");
        return 0;
    }
Errors :
pawn Код:
L:\SAGW\filterscripts\XtremeAdmin2.pwn(1163) : error 027: invalid character constant
L:\SAGW\filterscripts\XtremeAdmin2.pwn(1163) : error 017: undefined symbol "uck"
L:\SAGW\filterscripts\XtremeAdmin2.pwn(1163) : error 029: invalid expression, assumed zero
L:\SAGW\filterscripts\XtremeAdmin2.pwn(1163) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

if(text[0] == 'fuck')
should have "fuck" instead of 'fuck'..
' ' is for one letter.. as to why you can't have "uck" there.
I aslo suggest you use "strlib" it's a include on the forums... to make this simpler for example
if(strfind(text,"fuck"))
is how it would look w/ strlib.
Also, text[0], is only the FIRST letter of the text.
Reply
#3

Quote:
Originally Posted by 1337connor
Посмотреть сообщение
if(text[0] == 'fuck')
should have "fuck" instead of 'fuck'..
' ' is for one letter.. as to why you can't have "uck" there.
I aslo suggest you use "strlib" it's a include on the forums... to make this simpler for example
if(strfind(text,"fuck"))
is how it would look w/ strlib.
Also, text[0], is only the FIRST letter of the text.
thank you but i found error:
pawn Код:
L:\SAGW\filterscripts\XtremeAdmin2.pwn(1163) : error 033: array must be indexed (variable "-unknown-")
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

Use strcmp for more accurate detection.
pawn Код:
if (strcmp(text, "fuck", true) == 0)
{
    // do something
}
Reply
#5

I suggest the strlib include.
Way easier.
Reply
#6

pawn Код:
for(new i; i < 128; ++)
{
if(!strfind(text[i], "Fuck", true))
{
      SendClientMessage(playerid, yellow, "That's Not Allowed In This Server");
      return 0;
}
}
strfind = Search word in the sentence.
Reply
#7

Its Not Working D:
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
strfind gets the location of the second string (the "needle") in the first string (the "haystack"), that will only work if the word is at the start of the string (i.e. position 0). You need:

pawn Код:
if (strfind(text[i], "Fuck", true) != -1)
"-1" is an invalid string location, so is returned when the needle is not in the haystack.
i got this error :
pawn Код:
L:\SAGW\gamemodes\SAGW.pwn(1580) : error 017: undefined symbol "i"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#9

Quote:
Originally Posted by 0_o
Посмотреть сообщение
i got this error :
pawn Код:
L:\SAGW\gamemodes\SAGW.pwn(1580) : error 017: undefined symbol "i"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
-.-

pawn Код:
for(new i=0;i<128;i++)
{
    if(strfind(text[i], "fuck") != -1)
    {
        return 0;
    }
}
Reply
#10

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
-.-

pawn Код:
for(new i=0;i<128;i++)
{
    if(strfind(text[i], "fuck") != -1)
    {
        return 0;
    }
}
WORKS! THanks dude!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)