SA-MP Forums Archive
Whats the problem with this /pm command? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Whats the problem with this /pm command? (/showthread.php?tid=166700)



Whats the problem with this /pm command? - Dolph - 09.08.2010

http://pastebin.com/7LCeVtfE




The problem is that it doesnt send the message


Re: Whats the problem with this /pm command? - Hiddos - 09.08.2010

Try this: http://pastebin.com/SXq7qEgK


Re: Whats the problem with this /pm command? - Kar - 09.08.2010

pawn Код:
dcmd_pm(playerid,params[])
{
    new target, string[128],string2[128], message,pname{MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
    if(sscanf(params,"us",target, message)) return SendClientMessage(playerid,red,"USAGE: /pm [Name / ID] [Message]");
    if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid,red,"Invalid Name / ID");
    GetPlayerName(target,pname,sizeof(pname);
    GetPlayerName(playerid,bname,sizeof(bname);
    format(string,sizeof(string),"* From %s(%d) - PM: %s",bname,playerid,message);
    SendClientMessage(target,YELLOW,string);
    format(string2,sizeof(string2),"* To %s(%d) - PM: %s",pname,target,message);
    SendClientMessage(playerid,YELLOW,string2);
    return true;
}
works perfect. short.

wow hiddos beat me

mine will work. you guys didnt put your sscanf right


Re: Whats the problem with this /pm command? - Dolph - 09.08.2010

I really dont want a new command. I just wanna know what I did wrong.


Re: Whats the problem with this /pm command? - Kar - 09.08.2010

you misses sscanf you needed "us" or "is"

s for string aka the message u for userand playerid

i for playerid only

so here in the message

if(sscanf(params,"i",pid,message))

notice you only put I that would call pid only so change that to us or is

happy coding


Re: Whats the problem with this /pm command? - Bessensap - 09.08.2010

pawn Код:
if(sscanf(params,"i",pid,message)) return SendClientMessage(playerid, 0xF60000AA, "USAGE: /pm [playerid] [message]");
pawn Код:
if(sscanf(params,"us",pid,message)) return SendClientMessage(playerid, 0xF60000AA, "USAGE: /pm [playerid] [message]");
mind the " ", u put in "i", which stands for integer, if u put "u", it also uses usernames/parts of usernames which is better, and u forgot the "s" meaning the message.


edit; wtf u beat me? D:


Re: Whats the problem with this /pm command? - Kar - 09.08.2010

Sorry I PWN.


- Kar, Happy Scripting


Re: Whats the problem with this /pm command? - Dolph - 09.08.2010

I kind saw it after.. Thanks



Edit:

pawn Код:
dcmd_pm(playerid, params[])
{
    new pid,message;
    if(sscanf(params,"us",pid,message)) return SendClientMessage(playerid, 0xF60000AA, "USAGE: /pm [playerid] [message]");
    else if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOUR_BROWN, "There is no player online with that id");
    {
    new string[128],string2[128],name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    GetPlayerName(pid,name2,sizeof(name2));
    format(string,sizeof(string),"PM sent to %s: %s",name2,message);
    SendClientMessage(playerid,COLOUR_ORANGE,string2);
    format(string,sizeof(string),"PM from %s: %s",name,message);
    SendClientMessage(pid,COLOUR_ORANGE,string);
    return 1;
    }
}

When I /pm someone, I only get: There is no player online with that id. What is wrong now?


Re: Whats the problem with this /pm command? - Bessensap - 09.08.2010

remove the else and the { and 1 } at the end...


edit; *sigh*
pawn Код:
dcmd_pm(playerid, params[])
{
    new pid,message;
    if(sscanf(params,"us",pid,message)) return SendClientMessage(playerid, 0xF60000AA, "USAGE: /pm [playerid] [message]");
    if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOUR_BROWN, "There is no player online with that id");
    new string[128],string2[128],name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    GetPlayerName(pid,name2,sizeof(name2));
    format(string,sizeof(string),"PM sent to %s: %s",name2,message);
    SendClientMessage(playerid,COLOUR_ORANGE,string2);
    format(string,sizeof(string),"PM from %s: %s",name,message);
    SendClientMessage(pid,COLOUR_ORANGE,string);
    return 1;
}
should do the trick


Re: Whats the problem with this /pm command? - Dolph - 10.08.2010

I got Unknown Command when I tried to pm.


Oh wait, tried yours.. I got: There is no player online with that id