Detect -
radi - 19.07.2009
how can i make from this pawn code
this is the pawn code that if a player says kanker it wil be banned
like this Radi:kanker
but i want to make it that it wil also ban if the word kanker is some where else like
Radi: You are kanker
[pawn]
if(strcmp(text, "kanker", true) == 0)
{
new playername[MAX_PLAYER_NAME];
new string[256];
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "=>|[Anti-Flame]|<= Banned: %s for Flaming with a disease ", playername);
SendClientMessageToAll(COLOR_RED, string);
format(string, sizeof(string), "=>|[Anti-Flame]|<= You Got Banned For 2 Days ");
SendClientMessage(COLOR_RED, string);
format(string, sizeof(string), "=>|[Anti-Flame]|<= Make a unban appeal on the forum ");
SendClientMessage(COLOR_RED, string);
Ban(playerid);
}
return 0;
}
[/pawn
Re: Detect -
Weirdosport - 19.07.2009
You need to use strfind like this:
pawn Код:
if(strfind(text, "kanker", true) != -1)
//they said kanker somewhere
else
//they didn't
And for the record your SendClientMessage Sytax is wrong, and you need not format the 2nd and 3rd message. I'll tidy this up and post here.
https://sampwiki.blast.hk/wiki/Scripting...ns_Old#strfind
pawn Код:
#include <a_samp>
new
playername[MAX_PLAYER_NAME],
string[128];
#define COLOR_RED 0xFF0000AA
public OnPlayerText(playerid, text[])
{
if(strfind(text, "kanker", true) != -1)
{
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "=>|[Anti-Flame]|<= Banned: %s for Flaming with a disease", playername);
SendClientMessageToAll(COLOR_RED, string);
SendClientMessage(playerid, COLOR_RED, "=>|[Anti-Flame]|<= You Got Banned For 2 Days");
SendClientMessage(playerid, COLOR_RED, "=>|[Anti-Flame]|<= Make a unban appeal on the forum");
Ban(playerid);
return 0;
}
return 1;
}
Fixes:
- I took out the unnecessary formats
- Used fewer cells in your string
- Took out the IsPlayerConnected check (non-connected players don't usually say stuff)
- Put the strfind in
- Moved your array declarations outside the command (so they don't have to be declared everytime someone is stupid enough to say kanker).
Re: Detect -
radi - 19.07.2009
how it works like that
can put it in the way it supose to be in my thing because i dont know how it works
Re: Detect -
Weirdosport - 19.07.2009
I can't put it in your script without actually seeing your script. Do you have the OnPlayerText callback?
Re: Detect -
radi - 19.07.2009
THANK YOU
it works
Re: Detect -
Pawno_Master - 19.07.2009
isnt it a little hard to ban a player is he sayas kanker
maybe you can warn him
or something