SA-MP Forums Archive
/pm problems - 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: /pm problems (/showthread.php?tid=108594)



/pm problems - Rhemsis - 14.11.2009

I have this as my /pm command. It compiles without error. However in game, when i try to send a /pm, it always tells me Usage: /pm (id) (message). Can someone help me out in finding what is going wrong?

pawn Код:
if(strcmp(cmd,"/pm", true)==0)
    {
        new pName[256];
        new iName[256];
        new gMessage[256];
        new Message[256];
        #define strrest

    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /PM (id) (message)");
    new id = strval(tmp);
    gMessage[5] = strrest(cmdtext,idx);
    if(!strlen(gMessage)) return SendClientMessage(playerid,0xFF0000FF,"Usage: /pm (id) (message)");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000FF,"/pm :Invalid ID");
    GetPlayerName(id,iName,sizeof(iName));
    GetPlayerName(playerid,pName,sizeof(pName));
    format(Message,sizeof(Message),">> %s(%i): %s",iName,id,gMessage);
    SendClientMessage(playerid,0xFFD720FF,Message);
    format(Message,sizeof(Message),"** %s(%i): %s",pName,playerid,gMessage);
    SendClientMessage(id,0xFFD720FF,Message);
    PlayerPlaySound(id,1085,0.0,0.0,0.0);
    return 1;
    }



Re: /pm problems - Donuts - 14.11.2009

pawn Код:
#define strrest
What? you must have the strrest function, not just define it like that.



Re: /pm problems - jamesb93 - 14.11.2009

This should work

pawn Код:
if(!strcmp(cmdtext[1],"pm",true,2))
    {
    if(!cmdtext[3]||!cmdtext[4])return SendClientMessage(playerid,0xF8DA07FF,"USAGE: /pm [playerid] [text]");
    new receiverid = strval(cmdtext[4]);
    if(!IsPlayerConnected(receiverid))return SendClientMessage(playerid,0xF8DA07FF,"Invalid Player ID!");
    new begintext = strfind(cmdtext[4]," ")+1;
    if(!strlen(cmdtext[begintext]))return SendClientMessage(playerid,0xF8DA07FF,"USAGE: /pm [playerid] [text]");
    OnPlayerPrivmsg(playerid, receiverid, cmdtext[begintext]);
    return 1;
    }



Re: /pm problems - cristab - 14.11.2009

Код:
stock strrest(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}
	new offset = index;
	new result[128];
	while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}



Re: /pm problems - Rhemsis - 14.11.2009

Quote:
Originally Posted by jamesb93
This should work

pawn Код:
if(!strcmp(cmdtext[1],"pm",true,2))
    {
    if(!cmdtext[3]||!cmdtext[4])return SendClientMessage(playerid,0xF8DA07FF,"USAGE: /pm [playerid] [text]");
    new receiverid = strval(cmdtext[4]);
    if(!IsPlayerConnected(receiverid))return SendClientMessage(playerid,0xF8DA07FF,"Invalid Player ID!");
    new begintext = strfind(cmdtext[4]," ")+1;
    if(!strlen(cmdtext[begintext]))return SendClientMessage(playerid,0xF8DA07FF,"USAGE: /pm [playerid] [text]");
    OnPlayerPrivmsg(playerid, receiverid, cmdtext[begintext]);
    return 1;
    }
error 017: undefined symbol "OnPlayerPrivmsg"

0.3a doesn't have the OnPlayerPrivmsg Callback.




Re: /pm problems - jamesb93 - 14.11.2009

pawn Код:
forward OnPlayerPrivmsg( playerid, recieverid, text[] );
:P


Re: /pm problems - Rhemsis - 14.11.2009

Ah lol, didn't think of that.

Is there anything I need to add under the:

pawn Код:
public OnPlayerPrivmsg(playerid, recieverid, text[])



Re: /pm problems - jamesb93 - 14.11.2009

Not unless you want it to do anything else.


Re: /pm problems - Rhemsis - 14.11.2009

Okay, I have it set to also let the receiver know that they can turn off pms with a command. However, when I pm myself on a test server, I only receive that message, not the pm that I initially typed. Any thoughts?


Re: /pm problems - Rhemsis - 16.11.2009

Sorry for the Double Post, Just bumping for an answer.