Create Blocking System [PM]
#1

hi , i want to add a command to block a player from sending mssg to me for exp : /block [playerid] , and when that player tried to pm me get this mssg: This Player Blocked You , You Cant Send Him Any Mssg , and on player disconnect this blocking will get disable [both of them, if the blocker left the game all of the black list will remove and can send mssg to me when i connected and if someone who i blocked him left the game and rejoin can send mssgs again)

can you help me with that?please show me some codes not just some explains i am a little newbie! thnx and srry for my bad english
Reply
#2

Try to do something like this:
PHP код:
#include <sscanf2>
#include <zcmd>
new pBlockedID[MAX_PLAYERS];
CMD:blockplayer(playeridparams[])
{
      new 
id;
      if(
sscanf(params"u"id) return SendClientMessage(playerid, -1"Syntax: /blockplayer <id/playername>");
      
pBlockedID[playerid] = id;
      
SendClientMessage(playerid, -1"You blocked succesfully the player!");
}
public 
OnPlayerText(playeridtext[])
{
     foreach(new 
iPlayer)
     {
           if(
i==pBlockedID[playerid])// checks if the player who send message is blocked
           
{
               return 
1;
           }
           else 
SendClientMessage(iCOLORtext);
     }
     return 
0;

hope I helped you!
Reply
#3

thnx , but i think with this code i cant have a multi blocking right? i mean when you blocked someone and use this again it will replace the new one with older , i guess! i dont want to its be like this!
Reply
#4

Quote:
Originally Posted by PoniStar
Посмотреть сообщение
thnx , but i think with this code i cant have a multi blocking right? i mean when you blocked someone and use this again it will replace the new one with older , i guess! i dont want to its be like this!
What do you mean?
Anyway, I updated my code, it has some errors.
Reply
#5

i mean can i block 2 players at the same time ? and how to remove a player from block list when he disconnect ( if he was in a players black list
Reply
#6

Quote:
Originally Posted by PoniStar
Посмотреть сообщение
i mean can i block 2 players at the same time ?
Yes, of course!
So , lets edit the code I wrote up a lil bit:
PHP код:
#include <sscanf2> 
#include <zcmd> 
#define MAX_BLOCKED_USERS 2
new pBlockedID[MAX_PLAYERS][2]; 
public 
OnPlayerConnect(playerid)
{
     
pBlockedID[playerid][0] = -1// Reset the variables when player connect to the server
     
pBlockedID[playerid][1] = -1;
     return 
1;
}
CMD:blockplayer(playeridparams[]) 

      new 
id
      if(
sscanf(params"u"id) return SendClientMessage(playerid, -1"Syntax: /blockplayer <id/playername>");
      if(
pBlockedID[playerid][0] == -1)
      {
            
pBlockedID[playerid][0] = id
      }
      else if(
pBlockedID[playerid][1] == -1)
      {
            
pBlockedID[playerid][0] = id
      }
      else return 
SCM(playerid, -1"You used all slots for blocked players.");
      
SendClientMessage(playerid, -1"You blocked successfully the player!"); 

public 
OnPlayerText(playeridtext[]) 

     foreach(new 
iPlayer
     { 
           if(
i==pBlockedID[playerid][0] || pBlockedID[playerid][1])// checks if the player who send message is blocked 
           

               return 
1
           } 
           else 
SendClientMessage(iCOLORtext); 
     } 
     return 
0

Reply
#7

Thnx ! Now its ok
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)