Help, Please?
#1

Okay.. So; When i go in game, and type /pm <id> <message>, it disables pming for some reason, though, when i type /togglepm it enables it fine.

Help? Thanks!

Код:
#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;
}
Reply
#2

pawn Код:
public OnPlayerConnect(playerid)
{
pmon[playerid]=1;
return 1;
}
Reply
#3

Do i just place that at the bottom?
Reply
#4

Quote:
Originally Posted by Tnt12340
Do i just place that at the bottom?
You should put it under onplayerconnect.
Reply
#5

Oh, This is a filterscript. XD I forgot to mention that. So i imagine i would add a OnPlayerConnect?

Edit: I just did some thinking. If i added that under onplayerconnect, it would just make it be enabled upon them connecting; Aye?

Anyways, It would still disable it when they did /pm at all. Even if i just type /pm it disables PMing.

And, Under any command i do that is assosciated with pming (/togglepm or /pm), it says "Unknown Command" under it saying "PM's Disabled!"
Reply
#6

Quote:
Originally Posted by Tnt12340
Oh, This is a filterscript. XD I forgot to mention that. So i imagine i would add a OnPlayerConnect?
Yes.
Reply
#7

I edited my above post, read.
Reply
#8

I noticed that just now.
Dude, OnPlayerPrivMsg is disabled in SA-MP 0.3.
You should use a PM FS and edit it though.
Reply
#9

take this:
pawn Код:
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;
    }
Reply
#10

^ That's what i did. Mikes PM FS. :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)