error issues
#1

pawn Код:
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(256) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(257) : error 033: array must be indexed (variable "tmp2")
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(555) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(556) : error 033: array must be indexed (variable "tmp2")
can anyone help

this is a command using it
pawn Код:
CMD:setrank(playerid,params[])
{
    if((gTeam[playerid] == 8) || (IsPlayerAdmin(playerid)))
    {
        if((CopDuty[playerid] == 1) || (IsPlayerAdmin(playerid)))
        {
            new tmp [256];
            new tmp2[256];
            new Index;
            tmp  = strtok(params,Index);
            tmp2 = strtok(params,Index);
            if(!strlen(params))
            {
                return SendClientMessage(playerid,RED,"Usage: /setrank [Player Id][Rank 1-8]");
            }
            new player1, rank, playername[MAX_PLAYER_NAME], copname[MAX_PLAYER_NAME], string[128];
            player1 = strval(tmp);
            if(!strlen(tmp2)) return SendClientMessage(playerid,RED,"Usage: /setrank [Player Id][Rank 1-8]");
            rank = strval(tmp2);
            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
            {
                if((gTeam[player1] <= 8) && (gTeam[player1] > 0))
                {
                    if(rank > 8 || rank < 1)
                    return SendClientMessage(playerid,RED,"ERROR: Invalid rank [1-8]");
                    if(rank == gTeam[player1]) return SendClientMessage(playerid,RED,"ERROR: Player is already this rank");
                    GetPlayerName(player1, playername, sizeof(playername));
                    GetPlayerName(playerid, copname, sizeof(copname));
                    gTeam[player1] = rank;
                    new Rank[64];
                    if(gTeam[player1] == 1) { Rank = "Police Officer"; }
                    else if(gTeam[player1] == 2) { Rank = "Investigator"; }
                    else if(gTeam[player1] == 3) { Rank = "Sergeant"; }
                    else if(gTeam[player1] == 4) { Rank = "Lieutenant"; }
                    else if(gTeam[player1] == 5) { Rank = "Major"; }
                    else if(gTeam[player1] == 6) { Rank = "Captain"; }
                    else if(gTeam[player1] == 7) { Rank = "Commander"; }
                    else if(gTeam[player1] == 8) { Rank = "Commissioner"; }
                    if(rank > 0 && rank < 9)
                    format(string,sizeof(string),"Police Radio: Commissioner %s has set %s's rank to %i [%s]",copname, playername, rank, Rank);
                    TeamChat(string);
                    return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
                }
                else return SendClientMessage(playerid, RED, "ERROR: This player is not in the Police Team!");
            }
            else return SendClientMessage(playerid, RED, "ERROR: Player not found!");
        }
        else return SendClientMessage(playerid, RED, "ERROR: You have to be on cop duty!");
    }
    else return SendClientMessage(playerid, RED, "ERROR: You need to be a Police Commissioner to use this command");
}
Reply
#2

pawn Код:
CMD:setrank(playerid,params[])
{
    if((gTeam[playerid] == 8) || (IsPlayerAdmin(playerid)))
    {
        if((CopDuty[playerid] == 1) || (IsPlayerAdmin(playerid)))
        {
            new tmp [128];
            new tmp2[128];
            new Index;
            tmp  = strtok(params,Index);
            tmp2 = strtok(params,Index);
            if(!strlen(params))
            {
                return SendClientMessage(playerid,RED,"Usage: /setrank [Player Id][Rank 1-8]");
            }
            new player1, rank, playername[MAX_PLAYER_NAME], copname[MAX_PLAYER_NAME], string[128];
            player1 = strval(tmp);
            if(!strlen(tmp2)) return SendClientMessage(playerid,RED,"Usage: /setrank [Player Id][Rank 1-8]");
            rank = strval(tmp2);
            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
            {
                if((gTeam[player1] <= 8) && (gTeam[player1] > 0))
                {
                    if(rank > 8 || rank < 1)
                    return SendClientMessage(playerid,RED,"ERROR: Invalid rank [1-8]");
                    if(rank == gTeam[player1]) return SendClientMessage(playerid,RED,"ERROR: Player is already this rank");
                    GetPlayerName(player1, playername, sizeof(playername));
                    GetPlayerName(playerid, copname, sizeof(copname));
                    gTeam[player1] = rank;
                    new Rank[64];
                    if(gTeam[player1] == 1) { Rank = "Police Officer"; }
                    else if(gTeam[player1] == 2) { Rank = "Investigator"; }
                    else if(gTeam[player1] == 3) { Rank = "Sergeant"; }
                    else if(gTeam[player1] == 4) { Rank = "Lieutenant"; }
                    else if(gTeam[player1] == 5) { Rank = "Major"; }
                    else if(gTeam[player1] == 6) { Rank = "Captain"; }
                    else if(gTeam[player1] == 7) { Rank = "Commander"; }
                    else if(gTeam[player1] == 8) { Rank = "Commissioner"; }
                    if(rank > 0 && rank < 9)
                    format(string,sizeof(string),"Police Radio: Commissioner %s has set %s's rank to %i [%s]",copname, playername, rank, Rank);
                    TeamChat(string);
                    return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
                }
                else return SendClientMessage(playerid, RED, "ERROR: This player is not in the Police Team!");
            }
            else return SendClientMessage(playerid, RED, "ERROR: Player not found!");
        }
        else return SendClientMessage(playerid, RED, "ERROR: You have to be on cop duty!");
    }
    else return SendClientMessage(playerid, RED, "ERROR: You need to be a Police Commissioner to use this command");
}
try this
Reply
#3

still the same
Reply
#4

Put this on top of your script:
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
#5

pawno crashes when i add that
Reply
#6

Replace pawno to the new one and try compile again.....
Reply
#7

Change

new tmp [256];
new tmp2[256];

to this:

new tmp;
new tmp2;

Your using an number value not a string.
Reply
#8

pawn Код:
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(264) : error 035: argument type mismatch (argument 1)
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(265) : error 035: argument type mismatch (argument 1)
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(266) : error 035: argument type mismatch (argument 1)
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(258) : warning 204: symbol is assigned a value that is never used: "tmp2"
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(257) : warning 204: symbol is assigned a value that is never used: "tmp"
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(556) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(557) : error 033: array must be indexed (variable "tmp2")
i get these now
Reply
#9

Quote:
Originally Posted by semaj
Посмотреть сообщение
pawn Код:
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(264) : error 035: argument type mismatch (argument 1)
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(265) : error 035: argument type mismatch (argument 1)
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(266) : error 035: argument type mismatch (argument 1)
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(258) : warning 204: symbol is assigned a value that is never used: "tmp2"
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(257) : warning 204: symbol is assigned a value that is never used: "tmp"
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(556) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\james\Desktop\Police System\Police System\filterscripts\Cop.pwn(557) : error 033: array must be indexed (variable "tmp2")
i get these now
I'm guessing it's these lines now?

Код:
            player1 = strval(tmp);
            if(!strlen(tmp2)) return SendClientMessage(playerid,RED,"Usage: /setrank [Player Id][Rank 1-8]");
            rank = strval(tmp2);
the old error you first posted have been sorted, is this the lines 264, 265, 266?
Reply
#10

yeah
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)