Commands don't work !
#1

Well when I write a commad i have it doesn't appear(if it is a text) and doesn't do anything , I trayd to write a cmd I don't have and it didn't shown me the "SERVER:Unknown command!" message , why is that ?
Reply
#2

well check do you have return 0 at end of OnPlayerCommand text

if you dont find anything show us command
Reply
#3

Show code plz
Reply
#4

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/spraycan", cmdtext, true, 10) == 0){
        GivePlayerWeapon(playerid, 41, 70);
        return 1;
    }
    return 0;
}
Reply
#5

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/spraycan", cmdtext, true, 10) == 0){
        GivePlayerWeapon(playerid, 41, 70);
    }
    return 0;
}
Try that
Reply
#6

Nop , didn't work
Reply
#7

edit wrong
Reply
#8

pawn Код:
warning 213: tag mismatch
Reply
#9

Here, try this:

(( NOTE: You must place the STRTOK at the END of your script. ))

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{  
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);  
    if (strcmp(cmd,"/spraycan", true) == 0)
    {        
        GivePlayerWeapon(playerid, 41, 70);    
        return 1;
    }    
    return 0;
}
pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply
#10

Should I also add
pawn Код:
new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);
to this command :
pawn Код:
if (strcmp("/kill", cmdtext, true, 10) == 0)
    {
        SetPlayerHealth(playerid, 0);
    }
or it should be diffrent ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)