17.01.2016, 10:14
Hello.
I'm trying to create it where anyone advertises, our server automatically bans them.
Currently it only does it in local chat, but no in chats that use commands like /b or /pm
Heres my coding, any assistance?
OnPlayerCommandText
OnPlayerText (This works)
The stock
Would love some help everyone!
I'm trying to create it where anyone advertises, our server automatically bans them.
Currently it only does it in local chat, but no in chats that use commands like /b or /pm
Heres my coding, any assistance?
OnPlayerCommandText
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
/*if(PlayerCmdFrq[playerid] != 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "You must wait before using another command.");
return 1;
}*/
if(stringContainsIP(cmdtext))
{
/*new szMsg[128];
GetPlayerName(playerid, szMsg, MAX_PLAYER_NAME);
format(szMsg, sizeof(szMsg), "%s has been banned due advertising!", szMsg);
SendClientMessageToAll(0xFF0000FF, szMsg);*/
SystemBanPlayer(playerid, "Server Advertising", PlayerInfo[playerid][pIP]);
}
//return PlayerCmdFrq[playerid] = 3;
return 0;
}
pawn Код:
public OnPlayerText(playerid, text[]) {
IdleInfo[playerid][idleX]++;
IdleInfo[playerid][idleY]++;
IdleInfo[playerid][idleZ]++;
IdleInfo[playerid][minCounter] = 0;
if(IdleInfo[playerid][idleMode] != 0) {
IdleInfo[playerid][unset] = 1;
}
if(stringContainsIP(text))
{
/*new szMsg[128];
GetPlayerName(playerid, szMsg, MAX_PLAYER_NAME);
format(szMsg, sizeof(szMsg), "%s has been banned due advertising!", szMsg);
SendClientMessageToAll(0xFF0000FF, szMsg);*/
SystemBanPlayer(playerid, "Server Advertising", PlayerInfo[playerid][pIP]);
}
//bunch of other stuff below this then..
return 0;
}
pawn Код:
stock stringContainsIP(const szStr[])
{
new
iDots,
i
;
while(szStr[i] != EOS)
{
if('0' <= szStr[i] <= '9')
{
do
{
if(szStr[i] == '.')
iDots++;
i++;
}
while(('0' <= szStr[i] <= '9') || szStr[i] == '.' || szStr[i] == ':' || szStr[i] == '/' || szStr[i] == '(' || szStr[i] == ')');
}
if(iDots > 2)
return 1;
else
iDots = 0;
i++;
}
return 0;
}