SA-MP Forums Archive
how to make pm cmd with something - 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)
+--- Thread: how to make pm cmd with something (/showthread.php?tid=522272)



how to make pm cmd with something - ReD_DeVi - 26.06.2014

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


Re: how to make pm cmd with something - RedFusion - 26.06.2014

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;
}



Re: how to make pm cmd with something - ReD_DeVi - 26.06.2014

its showing error what to do?


Re: how to make pm cmd with something - RedFusion - 26.06.2014

Copy-paste the errors please


Re: how to make pm cmd with something - Guest4390857394857 - 26.06.2014

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


Re: how to make pm cmd with something - ReD_DeVi - 26.06.2014

Код:
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));



Re: how to make pm cmd with something - Stinged - 26.06.2014

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.


Re: how to make pm cmd with something - RedFusion - 26.06.2014

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


Re : Re: how to make pm cmd with something - Clad - 26.06.2014

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.


Re: how to make pm cmd with something - RedFusion - 26.06.2014

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.