PM script help
#1

Hey i was creating a PM script with a /nopm option but i cant get it work :S
This is my code:
pawn Код:
COMMAND:pm(playerid, params[])
{
    new OtherPlayer, Message[128], Msg1[128], Msg2[128], YourName[24], OtherPlayerName[24];
   
    // Setup local variables


    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/pm", params);
    // Check if the player has logged in
    if(GetPVarInt(OtherPlayer, "NoPM") == 0)
    {
            if (sscanf(params, "us[128]", OtherPlayer, Message)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/pm <OtherPlayer> <Message>\"");
            else
            {
                // Check if that other player is online
                if (IsPlayerConnected(OtherPlayer))
                {
                    // Check if the player isn't muted
                    if (APlayerData[playerid][Muted] == false)
                    {
                        // Get both names
                        GetPlayerName(playerid, YourName, sizeof(YourName));
                        GetPlayerName(OtherPlayer, OtherPlayerName, sizeof(OtherPlayerName));
                        // Construct the message that is sent to yourself
                        format(Msg1, 128, "{808080}PM to %s{FFFFFF}: %s", OtherPlayerName, Message);
                        // Construct the message that is sent to the other player
                        format(Msg2, 128, "{A0A0A0}PM by %s{FFFFFF}: %s", YourName, Message);
                        // Send the messages
                        SendClientMessage(playerid, 0xFFFFFFFF, Msg1);
                        SendClientMessage(OtherPlayer, 0xFFFFFFFF, Msg2);
                    }
                    else
                        SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You are still muted");
                }
                else
                    SendClientMessage(playerid, 0xFF0000FF, "Player is not online");
            }

    }
    else
     return 0;

    // Let the server know that this was a valid command
    return 1;
}
COMMAND:nopm(playerid, params[])
{
    #pragma unused params
    switch(GetPVarInt(playerid, "NoPM"))
    {
        case 1:
        {
            SetPVarInt(playerid, "NoPM", 0);
            SendClientMessage(playerid, 0xFFFFFFFF, "You Have {FF0000}Enabled {FFFF2A}Incomming PMs. Use {33CCCC}/nopm {FFFF2A}To Disable PMs.");
        }
        case 0:
        {
            SetPVarInt(playerid, "NoPM", 1);
            SendClientMessage(playerid, 0xFFFFFFFF, "You Have {FF0000}Disabled {FFFF2A}Incomming PMs. Use {33CCCC}/nopm {FFFF2A}To Enable PMs.");
        }
    }
    return 1;
}
Anyone know how to do this? :S
Reply
#2

I would make an function to process Pm's.

pawn Код:
stock OnPlayerGetPm(playerid, senderid, Text[])
{
     if(APlayerData[senderid][Muted] == true) return SendClientMessage(senderid, 0x0, "You are muted, and cannot send any message..");
     if(GetPVarInt(playerid, "NoPM") == 1) return SendClientMessage(senderid, 0x0, "This player has disabled pm's.");
     new string[128]; format(string, sizeof(string), "Pm from : %s ( %d ) : %s", GetPlayerNameEx(senderid), senderid, Text);
     SendClientMessage(playerid, 0x0, string);
     format(string, sizeof(string), "Pm  to : %s ( %d ) : %s", GetPlayerNameEx(playerid), playerid, Text);
     SendClientMessage(playerid, 0x0, string);
     return 1;
}
GetPlayerNameEx :

pawn Код:
stock GetPlayerNameEx(playerid)
{
     new pName[25];
     GetPlayerName(playerid, pName, sizeof(pName));
     return pName;
}
pawn Код:
command(pm, playerid, params[])
{
     new pID, tText[90];
     if(sscanf(params, "us[90]",  pID, tText)) return SendClientMessage(playerid, 0x0, "Usage /pm [playerid/Name & Text]");
     if(!IsPlayerConnected(pID))  return SendClientMessage(playerid, 0x0, "This player is not connected.");
     OnPlayerGetPm(pID, playerid, tText)
     return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)