Unknown Command
#1

When I type the command which is under here, it says: "Use /setplayertg [playerid/name]" , which it should say. So when I try to add an ID to that, for example my own, like /setplayertg 0 , it says unknown command.. How can I fix this?

Код:
if (strcmp(cmdtext, "/setplayertg", true ) == 0)
	{
 		new tmp[256];
		tmp = strtok(cmdtext, idx);
	    new otherplayerid;
	    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Use /setplayertg [playerid/name]");
	    else if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "This player is not connected");
	    else
	    {
	        SendClientMessage(otherplayerid,COLOR_LIGHTRED,"You've been set to [Team 2] by an [Admin].");
			setTG[otherplayerid] = 1;
	    }
	    return 1;
	}
Reply
#2

Код:
if (strcmp(cmdtext, "/setplayertg", true ) == 0)
	{
 		new tmp[256];
		tmp = strtok(cmdtext, idx);
	    new otherplayerid;
	    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Use /setplayertg [playerid/name]");
	    else if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "This player is not connected");
	        SendClientMessage(otherplayerid,COLOR_LIGHTRED,"You've been set to [Team 2] by an [Admin].");
			setTG[otherplayerid] = 1;
	    return 1;
	}
maybe so, but i dont know.
Reply
#3

Still the same problem. "Unknown Command"
Reply
#4

pawn Код:
if(!strcmp(cmd, "/setplayertg", true))
    {
        new tmp[256];
        tmp = strtok(cmdtext, idx);
        new otherplayerid;
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Use /setplayertg [playerid/name]");
        else if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "This player is not connected");
            SendClientMessage(otherplayerid,COLOR_LIGHTRED,"You've been set to [Team 2] by an [Admin].");
            setTG[otherplayerid] = 1;
        return 1;
    }
Reply
#5

Thanks man! It works great!
Reply
#6

You welcome
Reply
#7

oooh, one thing.. It only works for id 0.. even if I set /setplayertg 1 it sets id 0 tg..
Reply
#8

try

pawn Код:
new otherplayerid(tmp);
Reply
#9

Errors..

Код:
C:\Users\daniel\Desktop\FOLDERS\0.3x\2013 scripts\driftrevolution.pwn(1608) : error 001: expected token: ";", but found "("
C:\Users\daniel\Desktop\FOLDERS\0.3x\2013 scripts\driftrevolution.pwn(1608) : warning 215: expression has no effect
Reply
#10

pawn Код:
if(!strcmp(cmd, "/setplayertg", true))
    {
        new tmp[256];
        tmp = strtok(cmdtext, idx);
        new otherplayerid = ReturnUser(tmp);
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Use /setplayertg [playerid/name]");
        else if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "This player is not connected");
            SendClientMessage(otherplayerid,COLOR_LIGHTRED,"You've been set to [Team 2] by an [Admin].");
            setTG[otherplayerid] = 1;
        return 1;
    }

pawn Код:
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21)
    {
        if (text[pos] == 0) return INVALID_PLAYER_ID;
        pos++;
    }
    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos]))
    {
        userid = strval(text[pos]);
        if (userid >=0 && userid < MAX_PLAYERS)
        {
            if(!IsPlayerConnected(userid))
                userid = INVALID_PLAYER_ID;
            else return userid;
        }
    }
    new len = strlen(text[pos]);
    new count = 0;
    new pname[MAX_PLAYER_NAME];
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, pname, sizeof (pname));
            if (strcmp(pname, text[pos], true, len) == 0)
            {
                if (len == strlen(pname)) return i;
                else
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count) SendClientMessage(playerid, red, "ERROR: There are multiple users, enter full playername.");
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)