SA-MP Forums Archive
A whole new set of errors,what a joy! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: A whole new set of errors,what a joy! (/showthread.php?tid=258787)



A whole new set of errors,what a joy! - nuriel8833 - 01.06.2011

Hello guys.
Today I was trying to improve a system (its more like changing it).But I have the following errors set:
pawn Код:
(95) : error 033: array must be indexed (variable "tmp")
(96) : error 033: array must be indexed (variable "tmp")
(97) : error 033: array must be indexed (variable "tmp")
(98) : error 033: array must be indexed (variable "tmp")
(99) : error 033: array must be indexed (variable "tmp")
(100) : error 033: array must be indexed (variable "tmp")
(101) : error 033: array must be indexed (variable "tmp")
(101) : warning 213: tag mismatch
(102) : error 033: array must be indexed (variable "tmp")
(104) : error 033: array must be indexed (variable "tmp")
(106) : error 029: invalid expression, assumed zero
(106) : error 033: array must be indexed (variable "tmp")
(106) : error 029: invalid expression, assumed zero
(106) : fatal error 107: too many error messages on one line
Lines:
pawn Код:
if(strcmp(cmd, "/createlocation", true)==0 || strcmp(cmd, "/createloc", true)==0) //example: /createloc 2
    {
        new str[128],tmp[256];
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_USAGE,"USAGE: /createlocation [Location ID]");
        new Float:X,Float:Y,Float:Z,Float:A,Interior;
        new pName[MAX_PLAYER_NAME];
        GetPlayerPos(playerid,X,Y,Z);
        GetPlayerFacingAngle(playerid,A);
        Interior = GetPlayerInterior(playerid);
        GetPlayerName(playerid, pName, sizeof(pName));
        LocInfo[tmp][LocX] = X; // Float
        LocInfo[tmp][LocY] = Y; // Float
        LocInfo[tmp][LocZ] = Z; // Float
        LocInfo[tmp][LocA] = A; // Float
        LocInfo[tmp][LocInterior] = Interior;
        LocInfo[tmp][LocCreator] = pName;
        LocInfo[tmp][AvailableTeleport] = 1; // Bool
        format(str, 128, "You have succesfully set saved location %d to the following settings:",LocInfo[tmp][LocNumber]);
        SendClientMessage(playerid, COLOR_BPINK, str);
        format(str, 128, "Coordinations: %.2f,%.2f,%.2f",LocInfo[tmp][LocX],LocInfo[tmp][LocY],LocInfo[tmp][LocZ]);
        SendClientMessage(playerid, COLOR_BPINK, str);
        format(str, 128, "Angle: %.1f",,LocInfo[tmp][LocA]);
        SendClientMessage(playerid, COLOR_BPINK, str);
        format(str, 128, "Interior: %d",LocInfo[tmp][LocInterior]);
        SendClientMessage(playerid, COLOR_BPINK, str);
        PlayerPlaySound(playerid,1138,X,Y,Z);
        return 1;
    }
I know the errors are because of the brackets after the tmp (tmp[256]),but I don't know what to do in order to fix it.
Please help guys


Re: A whole new set of errors,what a joy! - nuriel8833 - 02.06.2011

Bump
Please help


Re: A whole new set of errors,what a joy! - nuriel8833 - 02.06.2011

Quote:
Originally Posted by ******
Посмотреть сообщение
"tmp" is a string, you can't use it to index an array, only numbers can be used for that. I would strongly recommend using sscanf for this to extract the data out of the strings.
So there is no possible way to solve that issue?
Damet
Edit: Can it work? This is the only solution I could possibly think of:
pawn Код:
if(strcmp(cmd, "/createlocation", true)==0 || strcmp(cmd, "/createloc", true)==0)
    {
        new str[128],tmp[256],location;
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_USAGE,"USAGE: /createlocation [Location ID]");
        if(tmp < 1 || tmp > 100) return SendClientMessage(playerid,COLOR_WARNING,"Warning: The location number must be between 1 to 100!");
        new Float:X,Float:Y,Float:Z,Float:A,Interior;
        new pName[MAX_PLAYER_NAME];
        GetPlayerPos(playerid,X,Y,Z);
        GetPlayerFacingAngle(playerid,A);
        Interior = GetPlayerInterior(playerid);
        GetPlayerName(playerid, pName, sizeof(pName));
        location = tmp;
        LocInfo[location][LocX] = X;
        LocInfo[location][LocY] = Y;
        LocInfo[location][LocZ] = Z;
        LocInfo[location][LocA] = A;
        LocInfo[location][LocInterior] = Interior;
        LocInfo[location][LocCreator] = pName;
        format(str, 128, "You have succesfully set saved location %d to the following settings:",LocInfo[location][LocNumber]);
        SendClientMessage(playerid, COLOR_BPINK, str);
        format(str, 128, "Coordinations: %.2f,%.2f,%.2f",LocInfo[location][LocX],LocInfo[location][LocY],LocInfo[location][LocZ]);
        SendClientMessage(playerid, COLOR_BPINK, str);
        format(str, 128, "Angle: %.1f",LocInfo[location][LocA]);
        SendClientMessage(playerid, COLOR_BPINK, str);
        format(str, 128, "Interior: %d",LocInfo[location][LocInterior]);
        SendClientMessage(playerid, COLOR_BPINK, str);
        format(str, 128, "From now on people can teleport to this location by typing: /gotoloc [%d]",LocInfo[location][LocNumber]);
        SendClientMessage(playerid, COLOR_BPINK, str);
        PlayerPlaySound(playerid,1138,X,Y,Z);
        SaveLocations();
        return 1;
    }
Edit 2: FIXED.Used something else instead of the above ^^
Thanks anyway ******