Just a lil help
#1

Ok well before I pull my hair out... what is going wrong?

pawn Код:
if(strcmp(cmd, "/ac", true) == 0)
            {
                tmp = strtok(cmdtext, idx);
               
                new name[maxplayername];
               GetPlayerName(playerid, name, sizeof(name));
               
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[128];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
               
                if(!strlen(result))
                {
                  PlayerMessage(playerid, yellow1, "/ac [admin chat]");
                    return 1;
                }
               
                format(str, sizeof(str), "%s says: %s", name, result);
                if(Player[playerid][admin] > 0)
                {
                    PlayerMessage(playerid, ppurple3, str);
                }
              return 1;
            }
no, im not getting things compiling wrong, but the thing is the variable "result" is not returning anything... I feel like an idiot for getting to the point where I had to post this, but it saves me from ripping out more hair. Thanks for the help


EDIT: Alright, im an idiot... there is no need for the tmp = strtok(cmdtext, idx); at the beginning
Reply
#2

CMD and CMDTEXT.. 2 different stuff change strcmp(cmd.. to cmdtext or the cmdtext to cmd
Reply
#3

the thing is, I made a /w command to do whispers just like this, and it works fine. I take out the fact of the playerid being in there and it doesnt work...

pawn Код:
if(strcmp(cmd, "/w", true) == 0)
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
              PlayerMessage(playerid, pgreen5, "/w [playerid] [whisper text]");
              return 1;
            }
             new name[maxplayername];
             new targetname[maxplayername];
             new targetid = ReturnUser(tmp);

             GetPlayerName(playerid, name, sizeof(name));
            GetPlayerName(targetid, targetname, sizeof(targetname));
            if (IsPlayerConnected(targetid))
            {
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[128];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                  format(str, sizeof(str), "/w [%s] [whisper text]", targetname);
                    PlayerMessage(playerid, pgreen5, str);
                    return 1;
                }
              format(str, sizeof(str), "%s(%d) whispers : %s", name, playerid, result);
              PlayerMessage(targetid, pblue3, str);
              format(str, sizeof(str), "You whisper to %s : %s", targetname, result);
              PlayerMessage(playerid, pblue3, str);
              return 1;
            }
            return 1;
        }
Reply
#4

pawn Код:
if(strcmp(cmd, "/ac", true) == 0)
{      
    new name[maxplayername];
    GetPlayerName(playerid, name, sizeof(name));
       
    new length = strlen(cmdtext);
    while ((idx < length) && (cmdtext[idx] <= ' '))
    {
        idx++;
    }
    new offset = idx;
    new result[128];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
        result[idx - offset] = cmdtext[idx];
        idx++;
    }
    result[idx - offset] = EOS;
               
    if(!strlen(result))
    {
        PlayerMessage(playerid, yellow1, "/ac [admin chat]");
        return 1;
    }
               
    if(Player[playerid][admin] > 0)
    {
        format(str, sizeof(str), "%s says: %s", name, result);
        PlayerMessage(playerid, ppurple3, str);
    }
    return 1;
}
Reply
#5

Haha, thanks, I just solved it as well... I guess thats what I get for coding at 3am haha.
Reply
#6

Quote:
Originally Posted by Kinetic
Haha, thanks, I just solved it as well... I guess thats what I get for coding at 3am haha.
hehe I'm just about to go to school xD Here is noon xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)