Function to read from enum
#1

Hi, I'm trying to make a function where it fills in the enum for you, although without success.

What I mean is that for example you try:
Код:
testfunc(playerid, ShamalMissions);
As where the function is:
Код:
stock testfunc(playerid, enum)
{
    CreateDynamicCP(enum[EndMission[playerid]][LoadX], enum[EndMission[playerid]][LoadY], enum[EndMission[playerid]][LoadZ], 20.0, -1, -1, playerid, -1);
}
That it would read it from the function name.
I hope I explained this right, it's hard enough for me already for some reason.
Reply
#2

You have to also add enum structure into stock

Код:
enum a
{
	...
}
new ShamalMissions[a];

stock testfunc(playerid, enum[a])
{
    ...
}
Reply
#3

Like this?
Код:
stock randomfunc(playerid, enumator[_Mission])
{
	CreateDynamicCP(enumator[EndMission[playerid]][LoadX], enumator[EndMission[playerid]][LoadY], enumator[EndMission[playerid]][LoadZ], 20.0, -1, -1, playerid, -1); // line 445
	return 1;
}

CMD:testfunc(playerid, params[])
{
	randomfunc(playerid, ShamalMissions[_Mission]);
	return 1;
}
Because it's giving me those errors:
Код:
crp.pwn(445) : warning 213: tag mismatch
crp.pwn(445) : error 001: expected token: ",", but found "["
crp.pwn(445) : error 029: invalid expression, assumed zero
crp.pwn(445) : warning 215: expression has no effect
crp.pwn(445) : error 001: expected token: ";", but found "]"
crp.pwn(445) : fatal error 107: too many error messages on one line
Reply
#4

Only add enum structure into stock, not in command

Код:
CMD:testfunc(playerid, params[])
{
	randomfunc(playerid, ShamalMissions);
	return 1;
}
Reply
#5

Quote:
Originally Posted by ball
Посмотреть сообщение
Only add enum structure into stock, not in command

Код:
CMD:testfunc(playerid, params[])
{
	randomfunc(playerid, ShamalMissions);
	return 1;
}
Gives the same errors.
Reply
#6

Код:
crp.pwn(1526 -- 1538) : warning 236: unknown parameter in substitution (incorrect #define pattern)
crp.pwn(1526 -- 1538) : warning 236: unknown parameter in substitution (incorrect #define pattern)
crp.pwn(1526 -- 1538) : warning 236: unknown parameter in substitution (incorrect #define pattern)
crp.pwn(1526 -- 1538) : warning 236: unknown parameter in substitution (incorrect #define pattern)
Reply
#7

Oh, now I see you have two dimensional enum. There is other structure. Try this

Код:
CMD:testfunc(playerid, params[])
{
	randomfunc(playerid, ShamalMissions[EndMission[playerid]]);
	return 1;
}

stock testfunc(playerid, theEnum[_Mission])
{
    CreateDynamicCP(theEnum[LoadX], theEnum[LoadY], theEnum[LoadZ], 20.0, -1, -1, playerid);
}
Reply
#8

Quote:
Originally Posted by ball
Посмотреть сообщение
Oh, now I see you have two dimensional enum. There is other structure. Try this

Код:
CMD:testfunc(playerid, params[])
{
	randomfunc(playerid, ShamalMissions[EndMission[playerid]]);
	return 1;
}

stock testfunc(playerid, theEnum[_Mission])
{
    CreateDynamicCP(theEnum[LoadX], theEnum[LoadY], theEnum[LoadZ], 20.0, -1, -1, playerid);
}
Thanks a lot man! Appreciate it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)