PM problem
#1

I really cant figure out what is wrong with this code, it doesent compile any errors, but when i type ingame /pm 0 text it says server unknown command, please help.

pawn Код:
dcmd_pm(playerid, params[])
{
    new id, text[128], iName[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME], str[128];
    if(sscanf(params, "us", id, text)) SendClientMessage(playerid, LIGHTBLUE, "USAGE: {FFFFFF}/pm [playerid] [text]");
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, ORANGERED, "ERROR: {FFFFFF}Invalid PlayerID");
    {
        GetPlayerName(id,iName,sizeof(iName));
        GetPlayerName(playerid, name,sizeof(name));
        format(str,sizeof(str),"PM sent %s (ID: %d): %s",iName,id,text);
        SendClientMessage(playerid,YELLOW,str);
        format(str,sizeof(str),"PM From %s (ID: %d): %s",name,playerid,text);
        SendClientMessage(id,ORANGE,str);
        PlayerPlaySound(id,1085,0.0,0.0,0.0);
        printf("PM Logger: %s (From: %s) (To: %s)",str, iName, name);
    }
    return 1;
}
Reply
#2

pawn Код:
dcmd_pm(playerid, params[])
{
    new id, text[128], iName[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME], str[128];
    if(sscanf(params, "us", id, text)) return SendClientMessage(playerid, LIGHTBLUE, "USAGE: {FFFFFF}/pm [playerid] [text]");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, ORANGERED, "ERROR: {FFFFFF}Invalid PlayerID");
    GetPlayerName(id,iName,sizeof(iName));
    GetPlayerName(playerid, name,sizeof(name));
    format(str,sizeof(str),"PM sent %s (ID: %d): %s",iName,id,text);
    SendClientMessage(playerid,YELLOW,str);
    format(str,sizeof(str),"PM From %s (ID: %d): %s",name,playerid,text);
    SendClientMessage(id,ORANGE,str);
    PlayerPlaySound(id,1085,0.0,0.0,0.0);
    printf("PM Logger: %s (From: %s) (To: %s)",str, iName, name);
    return 1;
}
?
Reply
#3

pawn Код:
dcmd_pm(playerid, params[])
{
    new id, text[128], iName[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME], str[128];
    if(sscanf(params, "us", id, text)) SendClientMessage(playerid, LIGHTBLUE, "USAGE: {FFFFFF}/pm [playerid] [text]");
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, ORANGERED, "ERROR: {FFFFFF}Invalid PlayerID");
    else
    {
        GetPlayerName(id,iName,sizeof(iName));
        GetPlayerName(playerid,name,sizeof(name));
        format(str,sizeof(str),"PM sent %s (ID: %d): %s",iName,id,text);
        SendClientMessage(playerid,YELLOW,str);
        format(str,sizeof(str),"PM From %s (ID: %d): %s",name,playerid,text);
        SendClientMessage(id,ORANGE,str);
        PlayerPlaySound(id,1085,0.0,0.0,0.0);
        printf("PM Logger: %s (From: %s) (To: %s)",str, iName, name);
        return 1;
    }
}
Check if it works with the return in the else clause and make sure that you add an else clause after an if and else if clause.
Reply
#4

When i type it, nothing happens, its just blank, and when i do /pm 0 it says Pm (id: 4
Reply
#5

Quote:

dcmd_pm(playerid, params[])
{
new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
if(sscanf(params, "us", id, str2))
{
SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm <id> <message>");
return 1;
}
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected");
if(playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot pm yourself!")
{
GetPlayerName(playerid, Name1, sizeof(Name1));
GetPlayerName(id, Name2, sizeof(Name2));
format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
SendClientMessage(playerid, 0xFF0000FF, str);
format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
SendClientMessage(id, 0xFF0000FF, str);
}
return 1;
}

try this...
Reply
#6

This sends the message, but for some reason to playerid 42 i type /pm 0 text ti sends it to id 42
Reply
#7

Try this

pawn Код:
dcmd_pm(playerid, params[])
{
    new id, text[128], iName[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME], str[128];
    if(sscanf(params, "us", id, text)) SendClientMessage(playerid, LIGHTBLUE, "USAGE: {FFFFFF}/pm [playerid] [text]");
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, ORANGERED, "ERROR: {FFFFFF}Invalid PlayerID");
{
GetPlayerName(id,iName,sizeof(iName));
GetPlayerName(playerid, name,sizeof(name));
format(str,sizeof(str),"PM sent %s (ID: %d): %s",iName,id,text);
SendClientMessage(playerid,YELLOW,str);
format(str,sizeof(str),"PM From %s (ID: %d): %s",name,playerid,text);
SendClientMessage(id,ORANGE,str);
PlayerPlaySound(id,1085,0.0,0.0,0.0);
printf("PM Logger: %s (From: %s) (To: %s)",str, iName, name);
return 1;
}
return 0;
}
Reply
#8

Quote:
Originally Posted by Chris'
Посмотреть сообщение
This sends the message, but for some reason to playerid 42 i type /pm 0 text ti sends it to id 42
In my gamemode it works fine :S
Reply
#9

Switch to ZCMD.
Reply
#10

Under OnPlayerCommandText
pawn Код:
dcmd(pm, 2, cmdtext);
This happens mainly due to the size of the command specified under the OnPlayerCommandText does not match the actual size of the command. ( size means the length of the command )
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)