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=272356)
Help Please -
ZachZ - 28.07.2011
These 2 PM commands
Код:
// This commands allows the player to send a private message to another player
COMMAND:pm(playerid, params[])
{
// Setup local variables
new OtherPlayer, Message[128], Msg1[128], Msg2[128], YourName[24], OtherPlayerName[24];
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
if (sscanf(params, "us[128]", OtherPlayer, Message)) SendClientMessage(playerid, 0xFF0000AA, "The command is: \"/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 from %s{FFFFFF}: %s", YourName, Message);
// Send the messages
SendClientMessage(playerid, 0xFFFFFFFF, Msg1);
SendClientMessage(OtherPlayer, 0xFFFFFFFF, Msg2);
PlayerPlaySound(OtherPlayer,1085,0.0,0.0,0.0);
}
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:apm(playerid, params[])
{
if (APlayerData[playerid][PlayerLevel] >= 1)
{
// Setup local variables
new OtherPlayer, Message[128], Msg1[128], Msg2[128], YourName[24], OtherPlayerName[24];
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
if (sscanf(params, "us[128]", OtherPlayer, Message)) SendClientMessage(playerid, 0xFF0000AA, "The command is: \"/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, "Admin PM sent to %s: %s", OtherPlayerName, Message);
// Construct the message that is sent to the other player
format(Msg2, 128, "Admin PM from %s: %s", YourName, Message);
// Send the messages
SendClientMessage(playerid, COLOR_GREEN, Msg1);
SendClientMessage(OtherPlayer, COLOR_GREEN, Msg2);
PlayerPlaySound(OtherPlayer,1085,0.0,0.0,0.0);
}
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;
}
well if you try to pm someone over id 3 it sends it to id 0
EDIT: NeverMind