SA-MP Forums Archive
Personal Message 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: Personal Message Command (/showthread.php?tid=114968)



Personal Message Command - BP13 - 21.12.2009

Код:
C:\DOCUME~1\User\Desktop\MYNEWE~1\GAMEMO~1\SU.pwn(20350) : warning 213: tag mismatch
C:\DOCUME~1\User\Desktop\MYNEWE~1\GAMEMO~1\SU.pwn(20354) : warning 213: tag mismatch
C:\DOCUME~1\User\Desktop\MYNEWE~1\GAMEMO~1\SU.pwn(20367) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new tmp[256];
    new Message[256];
    new gMessage[256];
    new pName[MAX_PLAYER_NAME+1];
    new iName[MAX_PLAYER_NAME+1];
    new idx;

    cmd = strtok(cmdtext, idx);

    if(strcmp("/pm", cmd, true) == 0)
    {
        tmp = strtok(cmdtext,idx);

        if(!strlen(tmp) || strlen(tmp) > 5)
        {
            SendClientMessage(playerid,COLOR_RED,"Usage: /pm (id) (message)");
            return 1;
        }
        new id = strval(tmp);
    gMessage = strrest(cmdtext,idx);

        if(!strlen(gMessage))
        {
            SendClientMessage(playerid,COLOR_RED,"Usage: /pm (id) (message)");
            return 1;
        }
        if(!IsPlayerConnected(id))
        {
            SendClientMessage(playerid,COLOR_RED,"/pm : Bad player ID");
            return 1;
        }
        if(playerid != id)
        {
            if(NOPM[id] == true)
            {
            SendClientMessage(playerid, COLOR_RED, "This player has disabled PM's");
            }
            if(FirstPM[playerid] == 0 && NOPM[id] == false)
            {
                GetPlayerName(id,iName,sizeof(iName));
                GetPlayerName(playerid,pName,sizeof(pName));
                format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
                SendClientMessage(playerid,COLOR_YELLOW,Message);
                format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
                SendClientMessage(id,COLOR_YELLOW,Message);
                PlayerPlaySound(id,1085,0.0,0.0,0.0);
                printf("PM: %s",Message);
              FirstPM[playerid] = 1;
                SendClientMessage(playerid, COLOR_RED, "Type /pmoff to disable PM's");
            }
            if(FirstPM[playerid] == 1 && NOPM[id] == false)
            {
                GetPlayerName(id,iName,sizeof(iName));
                GetPlayerName(playerid,pName,sizeof(pName));
                format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
                SendClientMessage(playerid,COLOR_YELLOW,Message);
                format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
                SendClientMessage(id,COLOR_YELLOW,Message);
                PlayerPlaySound(id,1085,0.0,0.0,0.0);
                printf("PM: %s",Message);
            }
        }
        else
        {
            SendClientMessage(playerid,COLOR_RED,"You cannot PM yourself");
        }
        return 1;
    }
    return 0;
}



Re: Personal Message Command - Niixie - 21.12.2009

What do you want us to do?


Re: Personal Message Command - BP13 - 21.12.2009

Quote:
Originally Posted by Niixie
What do you want us to do?
Fix the problem?


I don't get why its a tag mismatch. id is the "playerid" for the person that the PM is being sent to and its a tag mismatch what did I do wrong.


Re: Personal Message Command - dice7 - 21.12.2009

iName is an array, not integer


Re: Personal Message Command - BP13 - 21.12.2009

Quote:
Originally Posted by dice7
iName is an array, not integer
Please refresh your page I edited my post.


Re: Personal Message Command - dice7 - 21.12.2009

You're still trying to access an array index with a string


Re: Personal Message Command - BP13 - 21.12.2009

Quote:
Originally Posted by dice7
You're still trying to access an array index with a string
Sorry about that dice7. I forgot to update the code. Take a look now.


Re: Personal Message Command - Correlli - 21.12.2009

Quote:
Originally Posted by [SU
BP13 ]
Quote:
Originally Posted by dice7
You're still trying to access an array index with a string
Sorry about that dice7. I forgot to update the code. Take a look now.
Change NOPM to bool or change:
pawn Код:
if(NOPM[id] == true)
to:
pawn Код:
if(NOPM[id] == 1)
and:
pawn Код:
if(NOPM[id] == false)
to:
pawn Код:
if(NOPM[id] == 0)



Re: Personal Message Command - BP13 - 21.12.2009

Thank you Don, I forgot to bool it.


Re: Personal Message Command - BP13 - 21.12.2009

ok well it compiles. But when I try to PM anyone the command comes out as Server: Unknown Command. The full code is.


This personal message system comes out as Server: Unknown Command


pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new tmp[256];
    new Message[256];
    new gMessage[256];
    new pName[MAX_PLAYER_NAME+1];
    new iName[MAX_PLAYER_NAME+1];
    new idx;

    cmd = strtok(cmdtext, idx);

    if(strcmp("/pm", cmd, true) == 0)
    {
        tmp = strtok(cmdtext,idx);

        if(!strlen(tmp) || strlen(tmp) > 5)
        {
            SendClientMessage(playerid,COLOR_RED,"Usage: /pm (id) (message)");
            return 1;
        }
        new id = strval(tmp);
    gMessage = strrest(cmdtext,idx);

        if(!strlen(gMessage))
        {
            SendClientMessage(playerid,COLOR_RED,"Usage: /pm (id) (message)");
            return 1;
        }
        if(!IsPlayerConnected(id))
        {
            SendClientMessage(playerid,COLOR_RED,"/pm : Bad player ID");
            return 1;
        }
        if(playerid != id)
        {
            if(NOPM[id] == true)
            {
            SendClientMessage(playerid, COLOR_RED, "This player has disabled PM's");
            }
            if(FirstPM[playerid] == 0 && NOPM[id] == false)
            {
                GetPlayerName(id,iName,sizeof(iName));
                GetPlayerName(playerid,pName,sizeof(pName));
                format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
                SendClientMessage(playerid,COLOR_YELLOW,Message);
                format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
                SendClientMessage(id,COLOR_YELLOW,Message);
                PlayerPlaySound(id,1085,0.0,0.0,0.0);
                printf("PM: %s",Message);
              FirstPM[playerid] = 1;
                SendClientMessage(playerid, COLOR_RED, "Type /pmoff to disable PM's");
            }
            if(FirstPM[playerid] == 1 && NOPM[id] == false)
            {
                GetPlayerName(id,iName,sizeof(iName));
                GetPlayerName(playerid,pName,sizeof(pName));
                format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
                SendClientMessage(playerid,COLOR_YELLOW,Message);
                format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
                SendClientMessage(id,COLOR_YELLOW,Message);
                PlayerPlaySound(id,1085,0.0,0.0,0.0);
                printf("PM: %s",Message);
            }
        }
        else
        {
            SendClientMessage(playerid,COLOR_RED,"You cannot PM yourself");
        }
        return 1;
    }