pm cmd problem
#1

hey all , i have this cmd by me and there is a problem in it i can't fix it the cmd is

Код:
if (strcmp("/nopm", cmdtext, true, 10) == 0||strcmp("/NOPM", cmdtext, true, 10) == 0)
	{
    #pragma unused cmdtext
    if(GetPVarInt(playerid,"NoPM") == 1)
    {
    SetPVarInt(playerid,"NoPM",0);
    SendClientMessage(playerid,0xFFFF00FF,"Pm's on!");
    }
    else
    {
    SetPVarInt(playerid,"NoPM",1);
    SendClientMessage(playerid,0xFFFF00FF,"Pm's off!");
    }
    return 1;
    }
    if (strcmp("/pm", cmdtext, true, 10) == 0||strcmp("/PM", cmdtext, true, 10) == 0)
	{
    new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(cmdtext[8], "u", id, str2)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm [ID] [MESSAGE]");
    if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, COLOR_RED, "Player No Connected");
    if(playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You Cannot PM Yourself!");
    if(GetPVarInt(id,"NoPM") == 1) return SendClientMessage(playerid,0xFF0000FF,"That player isnt recieving pm's");
    GetPlayerName(playerid, Name1, sizeof(Name1));
    GetPlayerName(id, Name2, sizeof(Name2));
    format(str, sizeof(str), "PM To %s: %s", Name2, id, str2);
    SendClientMessage(playerid, 0xFF0000FF, str);
    format(str, sizeof(str), "PM From %s: %s", Name1, playerid, str2);
    SendClientMessage(id, 0xFF0000FF, str);
    return 1;
    }
and everytime i type the cmd without the id and text it show me:

Quote:

/pm [ID] [MESSAGE]

but when i try to pm my friend it show this :

Quote:

SERVER: Unknown Command

i hope you guys help me in it
Reply
#2

I think you have to update your sscanf.
Reply
#3

but i already have the new version 2.8.1 and i'm using it in other cmds
Reply
#4

Post the code in [ pawn ] tags. I can't read it very well...
Reply
#5

okay sure here you can see it in pastebin

http://pastebin.com/YTV2FRGv

Reply
#6

pawn Код:
if(sscanf(cmdtext[8], "us", id, str2))
You need to add the message string
Reply
#7

pawn Код:
if (!strcmp("/nopm", cmdtext, true, 5))
{
    if (GetPVarInt(playerid,"NoPM"))
    {
        SetPVarInt(playerid,"NoPM",0);
        SendClientMessage(playerid,0xFFFF00FF,"Pm's on!");
    }
    else
    {
        SetPVarInt(playerid,"NoPM",1);
        SendClientMessage(playerid,0xFFFF00FF,"Pm's off!");
    }
    return 1;
}
else if (!strcmp("/pm", cmdtext, true, 3))
{
    new id, msg[100];
    if (sscanf(cmdtext[4], "us[100]", id, msg)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm [ID] [MESSAGE]");
    if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Player No Connected");
    if (playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You Cannot PM Yourself!");
    if (GetPVarInt(id,"NoPM")) return SendClientMessage(playerid,0xFF0000FF,"That player isnt recieving pm's");
   
    new Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME], str[144];
    GetPlayerName(playerid, Name1, sizeof(Name1));
    GetPlayerName(id, Name2, sizeof(Name2));
    format(str, sizeof(str), "PM To %s: %s", Name2, id, msg);
    SendClientMessage(playerid, 0xFF0000FF, str);
    format(str, sizeof(str), "PM From %s: %s", Name1, playerid, msg);
    SendClientMessage(id, 0xFF0000FF, str);
    return 1;
}
It's recommended to use ZCMD since you have to use only "params" instead of "cmdtext[number]". It seems you don't know how to use it correctly, plus the case is set to true so "/nopm" and "/NOPM" is the same.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)