/PM help? +REP
#1

Can someone make me a /pm that will accept the ID or the name when PM'ing someone? I also DON'T want it to be a pop up box. I just want it to be in the chat text box. I want the incoming messages and the outgoing messages to be yellow. Here's something I have already but it won't let me use the username. If I type in a username, it automatically counts it as ID 0 and it says I can't PM myself.
Reply
#2

First off, should of posted this in script request thread #5, although I will still help you (just a tip, use that instead).

This is it:

pawn Код:
CMD:pm(playerid, params[])
{
    new message[128], targetid, string[128], string2[128];
    if (sscanf(params, "us", targetid, message)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pm <playerid> <message>");
    new pName[MAX_PLAYER_NAME], targetName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(targetid, targetName, sizeof(targetName));
    format(string, sizeof(string), "*Incoming: %s [%i]: %s*", pName, playerid, message);
    format(string2, sizeof(string2), "*Sent: %s [%i]: %s*",targetName, targetid, message);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    SendClientMessage(targetid, COLOR_YELLOW, string2);
    return 1;
}
Compiled fine, never tested it. Tell me if you have problems (notice: could have a simpler way to doing this, but I did it the way I taught myself to do it)

Made with ZCMD and sscanf, need those to do this. Please specify the command processor and such before making this so you can get people to provide correct commands other then making it with their own preferred command processor (in my case).

PS: Please, stop creating threads. Make one thread for everything you need help on. Several threads are a waste of the board.
Reply
#3

Quote:
Originally Posted by KurtBag
Посмотреть сообщение
First off, should of posted this in script request thread #5, although I will still help you (just a tip, use that instead).

This is it:

pawn Код:
CMD:pm(playerid, params[])
{
    new message[128], targetid, string[128], string2[128];
    if (sscanf(params, "us", targetid, message)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pm <playerid> <message>");
    new pName[MAX_PLAYER_NAME], targetName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(targetid, targetName, sizeof(targetName));
    format(string, sizeof(string), "*Incoming: %s [%i]: %s*", pName, playerid, message);
    format(string2, sizeof(string2), "*Sent: %s [%i]: %s*",targetName, targetid, message);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    SendClientMessage(targetid, COLOR_YELLOW, string2);
    return 1;
}
Compiled fine, never tested it. Tell me if you have problems (notice: could have a simpler way to doing this, but I did it the way I taught myself to do it)

Made with ZCMD and sscanf, need those to do this. Please specify the command processor and such before making this so you can get people to provide correct commands other then making it with their own preferred command processor (in my case).

PS: Please, stop creating threads. Make one thread for everything you need help on. Several threads are a waste of the board.
Nope doesn't work. It compiles but when in-game I type in /pm 1 (i'm ID 0) it just PM's myself and when I type in /pm alex , it still goes to myself.
Reply
#4

^^

Then it's a plugin issue. His code is fine. You could have at least said thank you. Make sure your server is running all the latest plugins.
Reply
#5

Does this happen to all commands using a parameter of [playerid]. I encountered a problem before where my script wasn't updated or something and it caused my servers commands to go straight towards myself.

Plus, do you see both sendclientmessages, or just one.

Plus, I messed up on one little spot, it should show incoming to the target, and sent to the playerid, I switched the two here.

pawn Код:
CMD:pm(playerid, params[])
{
    new message[128], targetid, string[128], string2[128];
    if (sscanf(params, "us", targetid, message)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pm <playerid> <message>");
    new pName[MAX_PLAYER_NAME], targetName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(targetid, targetName, sizeof(targetName));
    format(string, sizeof(string), "*Incoming: %s [%i]: %s*", pName, playerid, message);
    format(string2, sizeof(string2), "*Sent: %s [%i]: %s*",targetName, targetid, message);
    SendClientMessage(targetid, COLOR_YELLOW, string);
    SendClientMessage(playerid, COLOR_YELLOW, string2);
    return 1;
}
And does the other player receive the message or not?
Reply
#6

Confirm you have the latest SSCANF.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)