14.04.2011, 06:56
Hey i was creating a PM script with a /nopm option but i cant get it work :S
This is my code:
Anyone know how to do this? :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;
}