Command Help
#1

hey im trying to make a block/unblock cmd but i cant pls someone help me

Pm codes

PHP код:
COMMAND:pm(playeridparams[])
{
    if(
GetPVarInt(playerid"togPM") == 1) return SendClientError(playerid"You have private mesasges disables. Use /togpm to re-enable.");
    new 
iPlayeriText128 ];
    if( 
sscanf params"us"iPlayeriText))  return SCP(playerid"[PlayerID/PartOfName] [message]");
    if(
PlayerTemp[playerid][muted]) return SendClientError(playerid"You are muted!");
    if(
FindIP(iText))
    {
       
KickReas("[SERVER]",playerid,"Attempting to advertise IP's!");
       return 
1;
    }
    if(
GetPVarInt(iPlayer"togPM") == && !GetAdminLevel(playerid)) return SendClientError(playerid"That player has blocked incoming private messages.");
    
format(iStrsizeof(iStr), "(( %s(%d): %s ))"RPName(playerid), playeridiText);
    
SendClientMessage(iPlayer0xFF66FFAAiStr);
    if(
PlayerTemp[iPlayer][lastpm] == 666SendClientMessage(iPlayer, -1"{d9d9d5} You can use {b4b4b1}\"/re [message]\"{d9d9d5}to send a quick reply.");
    
format(iStrsizeof(iStr), "(( PM sent %s(%d): %s ))"RPName(iPlayer), iPlayeriText);
    
SendClientMessage(playerid0xFF66FFAAiStr);
    
formatiStrsizeof(iStr), "13[PM] (( %s(%d) to %s(%d): %s ))",PlayerName(playerid), playeridPlayerName(iPlayer), iPlayeriText);
    
iEchoiStr );
    
PlayerLoop(i)
    {
        if(
PlayerTemp[i][adminspy] == 1)
        {
            
format(iStrsizeof(iStr), "(/pm) %s to %s: %s"PlayerName(playerid), PlayerName(iPlayer), iText);
            
SendClientMessage(iCOLOR_LIGHTGREYiStr);
        }
    }
    
PlayerTemp[iPlayer][lastpm] = playerid;
    if(
iAFKp[iPlayer] > 3)
    {
        
format(iStrsizeof(iStr),"%s is currently AFK",RPName(iPlayer));
        
SendClientMessage(playeridCOLOR_GREYiStr);
    }
    return 
1;

Reply
#2

Show command /togpm
Reply
#3

here is but i mean /blockpm [playerid]
PHP код:
COMMAND:togpm(playeridparams[])
{
    if(
GetPVarInt(playerid"togPM") == 1)
    {
        
SetPVarInt(playerid"togPM"0);
        
SendClientInfo(playerid"You have enabled private messaging.");
    }
    else
    {
        
SetPVarInt(playerid"togPM"1);
        
SendClientInfo(playerid"You have disabled private messaging. You cannot use /pm anymore.");
    }
    return 
1;

Reply
#4

Very easy just make a bool
PHP код:
new bool:pm[MAX_PLAYERS]; 
And at the pm command
PHP код:
if(pm[iPlayer]== false) return SendClientMessage(playerid, -1"This player blocked private messages"): 
And for the command
PHP код:
CMD:pms(playeridparams[])
{
    if(
pm[playerid] == false)
    {
        
pm[playerid] = true;
        
SendClientMessage(playerid,0xEE128960,"Private Messages unblocked! You can receive messages from other players");
    }
    else
    {
        
pm[playerid] = false;
        
SendClientMessage(playerid0xEE128960,"Private Messages blocked! You will no longer receive messages from other players");
    }
    return 
1;

Reply
#5

is this /blockpm [playerid] ?
Reply
#6

Hi Here is an example of one of of my pm systems , however i would say this is just for you to get some ideas and how to use the code , for yourself, so its up to you but i hope it helps dude..

Код:
// You will need to use enums in your player info but this is just an example of what you can do...

enum PlayerInfo
{
//====== Pm system -==/
    Last,
    PM,
    NoPM,
//==================//
}


CMD:pm(playerid, params[])
{
	new pID, text[256], string[256];
    if(sscanf(params, "us[256]", pID, text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm (nick/id) (message) - Enter a valid Nick / ID");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
    if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
    format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
    if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
    format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
    SendClientMessage(playerid, COLOR_YELLOW, string);
  	format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
   	SendClientMessage(pID, COLOR_YELLOW, string);
   	pInfo[pID][Last] = playerid;
    for (new i = 0; i < MAX_PLAYERS; i++)
    if(pInfo[i][pLevel] >= 6) // Here use your Admin system Enum's
    {
		format(string, sizeof(string), "PM: %s(%d) to %s(%d): %s", PlayerName(playerid), playerid, PlayerName(pID), pID, text);
		{
			if(pInfo[i][pLevel] >= 6)
			SendClientMessage(i, COLOR_GREY, string);
		}
	}
    return 1;
}

CMD:reply(playerid, params[])
{
    new text[256], string[256];
    if(sscanf(params, "s[256]", text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /reply (message) - Enter your message");
    new pID = pInfo[playerid][Last];
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
    if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
    format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
    if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
    format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
    SendClientMessage(pID, COLOR_YELLOW, string);
    pInfo[pID][Last] = playerid;
    for (new i = 0; i < MAX_PLAYERS; i++)
    if(pInfo[i][pLevel] >= 6)
    {
		format(string, sizeof(string), "PM: %s(%d) to %s(%d): %s", PlayerName(playerid), playerid, PlayerName(pID), pID, text);
		{
  			if(pInfo[i][pLevel] >= 6)
     		SendClientMessage(i, COLOR_GREY, string);
   		}
	}
    return 1;
}
CMD:r(playerid, params[]) return cmd_reply(playerid, params);


CMD:toggpm(playerid, params[])
{
	PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
    if(pInfo[playerid][NoPM] == 1)
    {
        SendClientMessage(playerid, COLOR_DARK_GREEN, "You Enabled your Private Messages!");
        pInfo[playerid][NoPM] = 0;
    }
    else if(pInfo[playerid][NoPM] == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "You've already Enabled your Private Messages!");
    }
    return 1;
}
CMD:nopm(playerid, params[])
{
	PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
 	if(pInfo[playerid][NoPM] == 0)
  	{
   		SendClientMessage(playerid, COLOR_DARK_GREEN, "You Disabled your Private Message!");
     	pInfo[playerid][NoPM] = 1;
	}
 	else if(pInfo[playerid][NoPM] == 1)
  	{
   		SendClientMessage(playerid, COLOR_RED, "You've already Disabled your Private Message!");
	}
 	return 1;
}
Reply
#7

Quote:
Originally Posted by Diti1
Посмотреть сообщение
is this /blockpm [playerid] ?
This is a switch between the two if you used it it will block your pm if you used it again it will unblock.
Reply
#8

But i need other not like that blockpm playerid
Reply
#9

And your code doesn't work? I think it should, I didn't test but looks good. Try use normal variables instead of PVars.
Reply
#10

Try as i said to use bool not PVars as ball said.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)