how to make pm cmd with something
#1

how to make pm cmd i am using zcmd so like if we send one guy msg then it should show pm sent
if we receive it should show pm received
Reply
#2

pawn Код:
CMD:pm(playerid, params[])
{
    new id, msg[100];
    if(sscanf(params, "is", id, msg))
        return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /Pm <playerid> <message>");

    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid, 0xFF0000FF, "ERROR: This player is not connected!");

    if(id == playerid)
        return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot use this on yourself!");

    new name[MAX_PLAYER_NAME+1], string[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "PM from %s (ID: %i): %s", name, playerid, msg);
    SendClientMessage(id, 0x00FF00FF, string);

    GetPlayerName(id, name, sizeof(name));
    format(string, sizeof(string), "PM to %s (ID: %i): %s", name, id, msg);
    SendClientMessage(playerid, 0x00FF00FF, string);
    return 1;
}
Reply
#3

its showing error what to do?
Reply
#4

Copy-paste the errors please
Reply
#5

Make sure you add this in top
pawn Код:
#include <sscanf>
#include <zcmd>
Make sure you use the sscanf plugin too!
Reply
#6

Код:
C:\Users\aman\Desktop\Land of Paradise 0.3x\gamemodes\gamemodes\BTRTDM.pwn(51849) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Users\aman\Desktop\Land of Paradise 0.3x\gamemodes\gamemodes\BTRTDM.pwn(51850) : error 035: argument type mismatch (argument 2)
C:\Users\aman\Desktop\Land of Paradise 0.3x\gamemodes\gamemodes\BTRTDM.pwn(51850) : error 035: argument type mismatch (argument 2)
C:\Users\aman\Desktop\Land of Paradise 0.3x\gamemodes\gamemodes\BTRTDM.pwn(51854) : error 035: argument type mismatch (argument 2)
C:\Users\aman\Desktop\Land of Paradise 0.3x\gamemodes\gamemodes\BTRTDM.pwn(51854) : error 035: argument type mismatch (argument 2)
C:\Users\aman\Desktop\Land of Paradise 0.3x\gamemodes\gamemodes\BTRTDM.pwn(51849) : warning 204: symbol is assigned a value that is
lines

51849
pawn Код:
new name[MAX_PLAYER_NAME+1], string[128];
51850

pawn Код:
GetPlayerName(playerid, name, sizeof(name));
51854

pawn Код:
GetPlayerName(id, name, sizeof(name));
Reply
#7

Change all the 'name' in that command to pname.
It is showing this because name is a global variable somewhere in your gamemode / or in an include.
Reply
#8

pawn Код:
CMD:pm(playerid, params[])
{
    new id, msg[100];
    if(sscanf(params, "is", id, msg))
        return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /Pm <playerid> <message>");

    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid, 0xFF0000FF, "ERROR: This player is not connected!");

    if(id == playerid)
        return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot use this on yourself!");

    new pname[MAX_PLAYER_NAME+1], string[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "PM from %s (ID: %i): %s", pname, playerid, msg);
    SendClientMessage(id, 0x00FF00FF, string);

    GetPlayerName(id, pname, sizeof(pname));
    format(string, sizeof(string), "PM to %s (ID: %i): %s", pname, id, msg);
    SendClientMessage(playerid, 0x00FF00FF, string);
    return 1;
}
Renamed the variable used for storing names
Reply
#9

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
pawn Код:
CMD:pm(playerid, params[])
{
    new id, msg[100];
    if(sscanf(params, "is", id, msg))
        return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /Pm <playerid> <message>");

    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid, 0xFF0000FF, "ERROR: This player is not connected!");

    if(id == playerid)
        return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot use this on yourself!");

    new pname[MAX_PLAYER_NAME+1], string[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "PM from %s (ID: %i): %s", pname, playerid, msg);
    SendClientMessage(id, 0x00FF00FF, string);

    GetPlayerName(id, pname, sizeof(pname));
    format(string, sizeof(string), "PM to %s (ID: %i): %s", pname, id, msg);
    SendClientMessage(playerid, 0x00FF00FF, string);
    return 1;
}
Renamed the variable used for storing names
Wow you look a guy who like to help, Worst thing to do is give him a cmd of PM ready.
He can create by his own if he reads some tutorials.
Reply
#10

Yeah that's true and he probably will learn sooner or later. Just doing what he's asking though, it's good to learn from examples like these.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)