Command doesn't work
#1

Can anybody tell me why this not work?

When i filled everythink good in..(very bad english :P) it shows the message: USAGE: /su [playerid] [crime] [wantedlevel]

Код:
	if(strcmp(cmd, "/su", true) == 0)// naar kijken
	{
	  if (PlayerInfo[playerid][pTeam] != 2 || PlayerInfo[playerid][pRank] < 1)
	  {
	    SendClientMessage(playerid, COLOR_RED,"You are not a cop or your rank is too low");
	    return 1;
	  }
 		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_GRAD, "USAGE: /su [playerid] [crime] [wantedlevel]");
			return 1;
		}
		giveplayerid = strval(tmp);
		GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
		new length = strlen(cmdtext);
		while ((idx < length) && (cmdtext[idx] <= ' '))
		{
			idx++;
		}
		new offset = idx;
		new result[64];
		while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
		{
			result[idx - offset] = cmdtext[idx];
			idx++;
		}
		result[idx - offset] = EOS;
		if(!strlen(result))
		{
			SendClientMessage(playerid, COLOR_GRAD, "USAGE: /su [playerid] [crime] [wantedlevel]");
			return 1;
		}
		new tmp2[256];
		tmp2 = strtok(cmdtext, idx);
		if(!strlen(tmp2))
		{
			SendClientMessage(playerid, COLOR_GRAD, "USAGE: /su [playerid] [crime] [wantedlevel]");
			return 1;
		}
		new wantedlevel = strval(tmp2);
		if(IsPlayerConnected(giveplayerid))
		{
   		SendClientMessage(playerid, COLOR_RED, "That player is not connected!");
   		return 1;
   	}
   	IsPlayerSuspect[giveplayerid] = 1;
		format(string, 128, "* Cop %s has made %s suspect! (crime: %s wantedlevel: %d)",PlayerName,GivePlayerName,result,wantedlevel);
		format(SuspectCrime[giveplayerid], 128, "%s",result);
		SetPlayerWantedLevel(playerid,wantedlevel);
		for(new i; i<MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i) && PlayerInfo[i][pTeam] == 2)
			{
				SendClientMessage(i, COLOR_BLUE, string);
			}
		}
		return 1;
	}
Reply
#2

You shold change the order: /su [playerid] [wantedlevel] [crime]

And tmp2 is not needed.

pawn Код:
if(strcmp(cmd, "/su", true) == 0)// naar kijken
{
    if (PlayerInfo[playerid][pTeam] != 2 || PlayerInfo[playerid][pRank] < 1)
    {
        SendClientMessage(playerid, COLOR_RED,"You are not a cop or your rank is too low");
        return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_GRAD, "USAGE: /su [playerid] [wantedlevel] [crime]");
        return 1;
    }
    giveplayerid = strval(tmp);
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_GRAD, "USAGE: /su [playerid] [wantedlevel] [crime]");
        return 1;
    }
    new wantedlevel = strval(tmp);
    new length = strlen(cmdtext);
    while ((idx < length) && (cmdtext[idx] <= ' '))
    {
        idx++;
    }
    new offset = idx;
    new result[64];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
        result[idx - offset] = cmdtext[idx];
        idx++;
    }
    result[idx - offset] = EOS;
    if(!strlen(result))
    {
        SendClientMessage(playerid, COLOR_GRAD, "USAGE: /su [playerid] [wantedlevel] [crime]");
        return 1;
    }
    if(IsPlayerConnected(giveplayerid))
    {
        SendClientMessage(playerid, COLOR_RED, "That player is not connected!");
        return 1;
    }
    IsPlayerSuspect[giveplayerid] = 1;
    format(string, 128, "* Cop %s has made %s suspect! (crime: %s wantedlevel: %d)",PlayerName,GivePlayerName,result,wantedlevel);
    format(SuspectCrime[giveplayerid], 128, "%s",result);
    SetPlayerWantedLevel(playerid,wantedlevel);
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && PlayerInfo[i][pTeam] == 2)
        {
            SendClientMessage(i, COLOR_BLUE, string);
        }
    }
    return 1;
}
Reply
#3

Thanks,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)