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;
}
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;
}
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;
}
Separate the whole block into a separate function and then feed playerid and text into the new function. Place function where necessary.
|
This function doesn't make any sense in OnPlayerCommandText. You should check if player is trying send IP number through certain commands, for instance private message or announce commands or any other commands that are sending messages to the player(s).
Your way of doing it is wrong. Also, what would happen if I join the server and text in the chat "Oh, the number is 9912... dummy.." I think it's going to ban me. Either way it is too rough to ban player, since you might have some false positives, so you should kick them out instead. edit:// @Vince, You got me first, damn antispam number count. |
That's what I've had an issue doing, I don't know how to separate it where it'll work that way so if they type in /b, or /f or /pm with the IP that it will check it, and take the action accordingly[...]
|
You just simply need to check message that player has sent to another player. String that you need to pass by reference depends on the name of your variable array in your command.
|
COMMAND:pm(playerid, params[]) {
if(GetPVarInt(playerid, "Muted") == 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: You are currently muted.");
new message[128],
user;
if(sscanf(params, "us[128]", user, message)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /pm [playerid] [message]");
if(user == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID is either invalid or a maskID).");
if(!IsPlayerConnected(user)) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID is not connected).");
if(IsPlayerNPC(user)) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID points at NPC).");
if(user == playerid) return SendClientMessage(playerid, COLOR_GREY, "You cannot send yourself private messages.");
if(GetPVarInt(user, "TogglePM") == 1 && PlayerInfo[playerid][pAdminlevel] == 0 && PlayerInfo[playerid][pModLevel] == 0) return SendClientMessage(playerid, COLOR_GREY, "The Private Messages of this user are currently blocked.");
new len = strlen(message);
if(len + MAX_PLAYER_NAME + 30 > 128) {
new buffer[128],
msg[128];
strmid(buffer, message, 0, 128 - MAX_PLAYER_NAME - 30 - 4);
format(msg, sizeof(msg), "(( PM sent to%s %s{E5C43E} [ID: %i]: %s ... ))", GetPVarInt(user, "AdminDuty") != 0? ("{CC9900}") : ("{E5C43E}"), GetNameWithSpace(user), user, buffer);
SendClientMessage(playerid, COLOR_DARKYELLOW, msg);
format(msg, sizeof(msg), "(( PM from%s %s{F0F000} [ID: %i]: %s ... ))", GetPVarInt(playerid, "AdminDuty") != 0? ("{CC9900}") : ("{F0F000}"), GetNameWithSpace(playerid), playerid, buffer);
SendClientMessage(user, COLOR_YELLOW, msg);
strdel(message, 0, 128 - MAX_PLAYER_NAME - 30 - 4);
format(msg, sizeof(msg), "(( PM sent to%s %s{E5C43E} [ID: %i]: ... %s ))",GetPVarInt(user, "AdminDuty") != 0? ("{CC9900}") : ("{E5C43E}"), GetNameWithSpace(user), user, message);
SendClientMessage(playerid, COLOR_DARKYELLOW, msg);
format(msg, sizeof(msg), "(( PM from%s %s{F0F000} [ID: %i]: ... %s ))", GetPVarInt(playerid, "AdminDuty") != 0? ("{CC9900}") : ("{F0F000}"), GetNameWithSpace(playerid), playerid, message);
SendClientMessage(user, COLOR_YELLOW, msg);
} else {
new buffer[128];
format(buffer, sizeof(buffer), "(( PM sent to%s %s{E5C43E} [ID: %i]: %s ))",GetPVarInt(user, "AdminDuty") != 0? ("{CC9900}") : ("{E5C43E}") , GetNameWithSpace(user), user, message);
SendClientMessage(playerid, COLOR_DARKYELLOW, buffer);
format(buffer, sizeof(buffer), "(( PM from%s %s{F0F000} [ID: %i]: %s ))", GetPVarInt(playerid, "AdminDuty") != 0? ("{CC9900}") : ("{F0F000}"), GetNameWithSpace(playerid), playerid, message);
SendClientMessage(user, COLOR_YELLOW, buffer);
}
SetPVarInt(user, "lpm", playerid);
return 1;
}
This function doesn't make any sense in OnPlayerCommandText. You should check if player is trying send IP number through certain commands, for instance private message or announce commands or any other commands that are sending messages to the player(s).
Your way of doing it is wrong. Also, what would happen if I join the server and text in the chat "Oh, the number is 9912... dummy.." I think it's going to ban me. Either way it is too rough to ban player, since you might have some false positives, so you should kick them out instead. edit:// @Vince, You got me first, damn forum's antispam system. |