SA-MP Forums Archive
Help, Please? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help, Please? (/showthread.php?tid=149236)



Help, Please? - Tnt12340 - 21.05.2010

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;
}



Re: Help, Please? - [MWR]Blood - 21.05.2010

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



Re: Help, Please? - Tnt12340 - 21.05.2010

Do i just place that at the bottom?


Re: Help, Please? - [MWR]Blood - 21.05.2010

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


Re: Help, Please? - Tnt12340 - 21.05.2010

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!"


Re: Help, Please? - [MWR]Blood - 21.05.2010

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.


Re: Help, Please? - Tnt12340 - 21.05.2010

I edited my above post, read.


Re: Help, Please? - [MWR]Blood - 21.05.2010

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


Re: Help, Please? - Mr L - 21.05.2010

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;
    }



Re: Help, Please? - Tnt12340 - 21.05.2010

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