#include <zcmd>
#include <sscanf2>
new PMEnabled=1;
forward PMLog(string[]);
public PMLog(string[])
{
new pm[128]; // Creates a new string
format(pm, sizeof(pm), "%s\n", string); // Formats the string;
new File:hFile; // Creates a new variable with type File
hFile = fopen("/LOGS/pm.log", io_append); // Opens the Log File
fwrite(hFile, pm); // Writes the log
fclose(hFile); // Closes file
}
CMD:pm(playerid, params [ ] ) // Adding the command
{
if(IsPlayerConnected(playerid)) // Checks if the Player IS connected
{
new pID, Message[60],playername[MAX_PLAYER_NAME],targetName[MAX_PLAYER_NAME],string[128],string2[128]; // Adding new's the pID Will hold the Player's ID Message will hold the message and playername will hold the name of the player that sends it and target to the target
if(sscanf(params, "us[60]", pID, Message)) return SendClientMessage(playerid, 0xAFAFAFAA, "USAGE: /pm [PlayerID/PlayerName] [Message]"); // Checks if the player has filed in both params if not it will return a error message with Color Grey
if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xAFAFAFAA, "Invalid Player"); // Checks if the player he attemps to send to is invalid if not it will send and error message
if(PMEnabled == 0) return SendClientMessage(playerid, 0xAFAFAFAA, "PM Is Disabled");
GetPlayerName(pID, targetName, sizeof(targetName)); // Gets the Name of The Target 1st param and stores it in targetName
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "Private Message from %s: %s", playername, Message); // Will format the string the first %s is the name of the guy who sent pm second %s in the Message
format(string2, sizeof(string2), "Private Message sent to %s: %s", targetName, Message); // The same as above but this time it shows the name off the player you sent it to
SendClientMessage(playerid, 0xFFFF00AA, string2); // Sends a message to the player who sent the PM
SendClientMessage(pID, 0xFFFF00AA, string); // Sends a Message to Target
PMLog(string2); // Writes to the lgo with our function
PMLog(string); // Writes to the log
}
return 1; // Returns 1
}
CMD:nopm(playerid, params [ ] )
{
if(IsPlayerConnected(playerid)) // If is player connected
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "Your not a admin"); // Checks if the player isent an Admin RCON
if(PMEnabled == 1) // If PM Is enabled it will disable it
{
SendClientMessageToAll(0xFFFF00AA, "An Admin has disabled Private Messages!"); // Sends a Client Message to all players
PMEnabled = 0; // Sets the PM Enabled to 0
}
else if(PMEnabled == 0) // If PM Is Disabled it will enable it
{
SendClientMessageToAll(0xFFFF00AA, "An Admin has enabled Private Messages!"); // Sends a Client MEssage to all playesr
PMEnabled = 1; // Sets the PM Enabled to 1
}
}
return 1;
}
[SIZE="3"]READ THIS
The Messages will be written in a log so if the owner or any admins wants to see it. The messages will be printed in a log so the owner/admins can see it if they want. Your proberlly thinking: Ahhh this is so simple. im only making this tutorial because i wonna help noobs out there. You're probably thinking: Ahhh this is so simple. I'm only making this tutorial because I want to help the noobs out there. This will just include the files so we can use anyfhing there is in there. This will just include the files so we can use anything there is in there. Better: This will make the include files available for usage in our script. (Search the forum to find them) |