HELP [/MakePolice]
#1

OK guys solved it was really simple

you have this
pawn Код:
if(strcmp(cmdtext,"/makepolice",true) == 0)
well the command only wors with cmdstext and it doesnt know that when u type the ID after /makepolice so u need to add idx
Like this
pawn Код:
if(strcmp(cmdtext,"/makepolice",true,idx) == 0)
Reply
#2

if(strcmp(cmdtext,"/makepolice",true) == 0) lol this way you can do it and its faster.
Reply
#3

Lol check this thread if you can https://sampforum.blast.hk/showthread.php?tid=158620
Reply
#4

You mean like creating a command with parameters after it?
Like /goto,/givecash etc?
In that case,yes it should be like you wrote,if that's what you meant I can make the command for you.
Reply
#5

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
You mean like creating a command with parameters after it?
Like /goto,/givecash etc?
In that case,yes it should be like you wrote,if that's what you meant I can make the command for you.
Yeah thats what i meant and can you please make to command for me Thanks
Reply
#6

Okay,there you go:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    new tmp[256],string[128],string2[128],namea[MAX_PLAYER_NAME],namep[MAX_PLAYER_NAME];
    if(strcmp(cmdtext,"/makepolice",true) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) return SendClientMessage(playerid,0xF0182DFF,"USAGE: /makepolice [playerid]");
            if(!IsNumeric(tmp)) return SendClientMessage(playerid,0xF0182DFF,"Please enter a numeric player ID.");
            if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid,0xF0182DFF,"ERROR: Player is not connected.");
            if(gTeam[strval(tmp)] == TEAM_COPS) return SendClientMessage(playerid,0xF0182DFF,"ERROR: Player is already a cop.");
            else {
                gTeam[strval(tmp)] = TEAM_COPS;
                GetPlayerName(strval(tmp),namep,MAX_PLAYER_NAME);
                GetPlayerName(playerid,namea,MAX_PLAYER_NAME);
                format(string,128,"You have successfuly made %s a cop.",namep);
                format(string2,128,"The administrator %s has made you a cop.",namea);
                SendClientMessage(playerid,0xFFFDFDFF,string);
                SendClientMessage(strval(tmp),0xFFFDFDFF,string2);}
            return 1;
        }

    }
    return 0;
}
Of course I haven't defined the team skin,the team color,spawnpoints etc,since I believe you've already made it.

Oh and btw,in order for the command to work,you're gonna need those two in your gamemode/filterscript.
Just put them in the bottom:

First,strtok:
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;
}
And IsNumeric
pawn Код:
stock IsNumeric(string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
No errors,untested though.
Reply
#7

Thanks alot man )))
Reply
#8

OK guys solved it was really simple

you have this
pawn Код:
if(strcmp(cmdtext,"/makepolice",true) == 0)
well the command only wors with cmdstext and it doesnt know that when u type the ID after /makepolice so u need to add idx
Like this
pawn Код:
if(strcmp(cmdtext,"/makepolice",true,idx) == 0)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)