#include <a_samp> #define PM_WAIT 2 // How many seconds between PM's #define MAX_WARNS 5 // How many warnings before the player is kicked #define MAX_PLAY 32 // How many slots your server has #define PM_SOUND 1 //0 - disabled 1 - enabled #define COLOR_RED 0xFF0000AA #define COLOR_ORANGE 0xFF9900AA #define COLOR_GREEN 0x33AA33AA new PMspam[MAX_PLAY]; new PMspammer[MAX_PLAY]; new pmon[MAX_PLAY]; #if PM_SOUND == 1 new pmallowed[MAX_PLAY]; #endif forward PMunspam(playerid); public OnFilterScriptInit() { for(new i=0; i<MAX_PLAY; i++) PMspam[i] = 0; return 1; } public OnPlayerRequestClass(playerid, classid) { PMspam[playerid] = 0; pmon[playerid] = 1; return 1; } public OnPlayerPrivmsg(playerid, recieverid, text[]) { if(PMspam[playerid] == MAX_WARNS+1) { new pName[MAX_PLAYER_NAME]; new string[128]; GetPlayerName(playerid,pName,sizeof(pName)); format(string, sizeof(string), "NG-RP SYSTEM:%s has been kicked from the server (Reason: Spamming Via PM)",pName); SendClientMessageToAll(COLOR_ORANGE,string); SendClientMessage(playerid,COLOR_RED, "You have been kicked for spamming via PM!"); Kick(playerid); } if(PMspam[playerid] < MAX_WARNS && PMspam[playerid] > 0) { PMspam[playerid]++; KillTimer(PMspammer[playerid]); SendClientMessage(playerid,COLOR_RED,"Don't Spam!"); PMspammer[playerid] = SetTimerEx("PMunspam",PM_WAIT*1000, false, "i", playerid); return 0; } if(PMspam[playerid] == 0) { PMspam[playerid]++; KillTimer(PMspammer[playerid]); PMspammer[playerid] = SetTimerEx("PMunspam",PM_WAIT*1000, false, "i", playerid); } if(pmon[recieverid] == 0) { SendClientMessage(playerid,COLOR_RED,"NG-RP System: This player has PMs disabled."); return 0; } #if PM_SOUND == 1 if(pmallowed[recieverid] == 1) { PlayerPlaySound(recieverid,1085,0.0,0.0,0.0); PlayerPlaySound(recieverid,1085,0.0,0.0,0.0); PlayerPlaySound(recieverid,1085,0.0,0.0,0.0); } #endif return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext,"/togglepm",true)==0) { SendClientMessage(playerid,COLOR_GREEN,"Private Messages enabled!"); pmon[playerid] = 1; return 0; } else { SendClientMessage(playerid,COLOR_RED,"Private Messages disabled!"); pmon[playerid] = 0; return 1; } return 0; }
public OnPlayerConnect(playerid)
{
pmon[playerid]=1;
return 1;
}
Originally Posted by Tnt12340
Do i just place that at the bottom?
|
Originally Posted by Tnt12340
Oh, This is a filterscript. XD I forgot to mention that. So i imagine i would add a OnPlayerConnect?
|
if(strcmp(cmd, "/pm", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /pm [playerid/PartOfName] [text]");
return 1;
}
if(PlayerInfo[playerid][pMuted] == 1)
{
SendClientMessage(playerid, COLOR_GRAD2, "You are muted, you can't speak.");
return 1;
}
giveplayerid = ReturnUser(tmp);
if (IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /pm [playerid/PartOfName] [text]");
return 1;
}
format(string, sizeof(string), "* PM from %s(ID: %d): %s", sendername, playerid, (result));
SendClientMessage(giveplayerid, COLOR_YELLOW, string);
format(string, sizeof(string), "* PM to %s(ID: %d): %s", giveplayer, giveplayerid, (result));
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "* PM from %s(ID: %d) to %s(ID: %d): %s", sendername, playerid, PlayerName(giveplayerid), giveplayerid, (result));
ABroadCast(COLOR_ORANGE, string, 1);
return 1;
}
}
else
{
format(string, sizeof(string), " %d is not an active player.", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD2, string);
}
}
return 1;
}