pm command
#1

whats wrong with this PM command

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
	new idx;
	cmd = strtok(cmdtext, idx);
	if(strcmp(cmd, "/legopm", true) == 0)
	{
	new
		giveplayerid,
		msg;
	if (sscanf(cmdtext[idx], "us", giveplayerid, msg)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /pm [playerid/part of name] [message]");
	else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
	else
        {
			new Sname[MAX_PLAYER_NAME], Rname[MAX_PLAYER_NAME];
			new rstring[126],sstring[126];
			GetPlayerName(playerid, Sname, sizeof(Sname));
			GetPlayerName(giveplayerid, Rname, sizeof(Rname));
			format(rstring,sizeof(rstring),"*PM* recieved from %s(%i):%s",Sname,playerid,msg);
			format(sstring,sizeof(sstring),"*PM* sent to %s(%i):%s",Rname,giveplayerid,msg);
			SendClientMessage(playerid, COLOR_RECIEVE_PM, rstring);
        	SendClientMessage(playerid, COLOR_SEND_PM, sstring);
		}
	return 1;
	}
	return 0;
}
sscanf is stocked at bottom of my script
Reply
#2

"msg" should be a string array not an integer, you should check "cmdtext" not "cmdtext[idx]", the "giveplayerid" variable needs a seperate statement not to be stuck onto the else of the sscanf statement and it should have a connection check not just an invalid player check.

Start with that anyway, could be more/less, dunno.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)