Function data as enum
#1

Hello, it might be a sort of copy of my old topic but to prevent further problems, I'd rather create a new topic.
Is there any way to get this working?
pawn Код:
stock testfunc(playerid, enumname)
{
    new Float:closest = PlayerDistanceToPoint(playerid, enumname[0][LoadX], enumname[0][LoadY], enumname[0][LoadZ]);
    for(new i=1; i<sizeof(enumname); i++)
    {
        if(PlayerDistanceToPoint(playerid, enumname[i][LoadX], enumname[i][LoadY], enumname[i][LoadZ]) < closest)
        {
            closest = PlayerDistanceToPoint(playerid, enumname[i][LoadX], enumname[i][LoadY], enumname[i][LoadZ]);
            CurrentMission[playerid] = i;
           
            CreateDynamicCP(enumname[i][LoadX], enumname[i][LoadY], enumname[i][LoadZ], 20.0, -1, -1, playerid);
        }
    }
}
My Enum + data
pawn Код:
enum _Mission
{
    LoadName[128],
    Float:LoadX,
    Float:LoadY,
    Float:LoadZ
};

new ShamalMissions[][_Mission] =
{
    {"Los Santos Airport - Gate 1", 1643.1703, -2413.4470, 13.5547},
    {"San Fierro Airport - Gate 1", -1343.9749, -229.1865, 14.1484},
    {"Los Santos Airport - Gate 2", 1727.5576, -2411.5198, 13.5547},
    {"San Fierro Airport - Gate 2", -1232.2932, -363.1233, 14.1440},
    {"Las Venturas Airport - Gate 1", 1578.1338, 1357.4642, 10.8580},
    {"Las Venturas Airport - Gate 2", 1572.3075, 1398.5856, 10.8442},
    {"Easter Bay Airport - Gate 1", -805.7103, -805.7494, 158.3181},
    {"Las Venturas Airport - Gate 3", 1569.1445, 1504.1632, 10.8374},
    {"Bayside Airport - Gate 1", -2370.4419, 2533.1575, 26.5271},
    {"Las Venturas Airport - Gate 4", 1577.8265, 1538.7271, 10.8272},
    {"Rockshore West Airport - Gate 1", 2337.7063, 554.1091, 7.7836},
    {"Las Venturas Airport - Gate 5", 1608.7456, 1550.4012, 10.8171},
    {"Rockshore West Airport - Gate 2", 2248.8269, 554.8190, 7.7836}
};
Which could be used in a command like:
pawn Код:
CMD:testfunction(playerid, params[])
{
    testfunc(playerid, ShamalMissions);
    return 1;
}
I'm currently getting those errors unfortunately:
Код:
crp.pwn(1758) : error 028: invalid subscript (not an array or too many subscripts): "enumname"
crp.pwn(1758) : warning 215: expression has no effect
crp.pwn(1758) : error 001: expected token: ";", but found "]"
crp.pwn(1758) : error 029: invalid expression, assumed zero
crp.pwn(1758) : fatal error 107: too many error messages on one line
Whereas the errors are coming from the function itself.
Reply
#2

The stock prototype should be like this :
pawn Код:
stock testfunc(playerid, enumname[][])
And also its not enum name that you are passing its array name, so better use
Код:
stock testfunc(playerid, arrayname[][])
And make sure you always pass two dimension array.
Reply
#3

Unfortunately, I get this warning (and it doesn't go further than that after trying to debug)
Код:
 warning 224: indeterminate array size in "sizeof" expression (symbol "")
Reply
#4

pawn Код:
stock testfunc(playerid, enumname[][], s_size = sizeof(enumname))
+
for(new i=1; i<s_size; i++)
Reply
#5

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
stock testfunc(playerid, enumname[][], s_size = sizeof(enumname))
+
for(new i=1; i<s_size; i++)
Thanks, although it was solved already by someone on skype.
Reply
#6

Is there any way to assign a value (in this case (check main post): ShamalMissions) to a player variable?
e.g:
Код:
new JobEnum[MAX_PLAYERS];
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)