Personal Message Command
#1

Код:
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;
}
Reply
#2

What do you want us to do?
Reply
#3

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

iName is an array, not integer
Reply
#5

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

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

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.
Reply
#8

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

Thank you Don, I forgot to bool it.
Reply
#10

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;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)