Whats the problem with this /pm command?
#1

http://pastebin.com/7LCeVtfE




The problem is that it doesnt send the message
Reply
#2

Try this: http://pastebin.com/SXq7qEgK
Reply
#3

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
Reply
#4

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

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
Reply
#6

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:
Reply
#7

Sorry I PWN.


- Kar, Happy Scripting
Reply
#8

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?
Reply
#9

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
Reply
#10

I got Unknown Command when I tried to pm.


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


Forum Jump:


Users browsing this thread: 1 Guest(s)