Issue with pulling information from an enum.
#1

Since I have no idea what I did wrong. I'm not gonna bother attempting to explain the issue. Here's the code of everything that has to do with the issue at hand.

The Enum, and array:
Код:
enum eTMInfo
{
	mission_actor_name[128],
	mission_task_one[128],
	mission_task_two[128],
	Float:mission_load_cp_x,
	Float:mission_load_cp_y,
	Float:mission_load_cp_z,
	Float:mission_unload_cp_x,
	Float:mission_unload_cp_y,
	Float:mission_unload_cp_z,
	mission_number,
};

new aTMInfo[][eTMInfo] =
{
	{"Steve", "I need you to move some freight for me. You can find in that warehouse over there.", "Good, you got it loaded. Now head over to the 24/7 in Juniper Hill and unload it.", 1706.398559, 1040.169921, 10.820312, -2471.517822, 787.875549, 35.171875, 0}
};
Where it says I have an issue:
Код:
if(IsTrailerAttachedToVehicle(plr_veh_id))
{
	DestroyDynamicRaceCP(tmMissionCheckpoint[playerid]);
        tmMissionCheckpoint[playerid] = CreateDynamicRaceCP(2, mission_unload_cp_x[0], mission_unload_cp_y[0], mission_unload_cp_z[0], 0.0, 0.0, 0.0, 10, -1, -1, playerid, 9000.0);
	FreezePlayerFor5Seconds(playerid);
	tmMissionStatus[playerid] = 2;
}
The warnings the compiler outputs:
Код:
C:\Users\mace\Desktop\Code Related Folders\Untitled Trucking Server\gamemodes\MTruck.pwn(815) : error 028: invalid subscript (not an array or too many subscripts): "mission_unload_cp_x"
C:\Users\mace\Desktop\Code Related Folders\Untitled Trucking Server\gamemodes\MTruck.pwn(815) : warning 215: expression has no effect
C:\Users\mace\Desktop\Code Related Folders\Untitled Trucking Server\gamemodes\MTruck.pwn(815) : error 001: expected token: ";", but found "]"
C:\Users\mace\Desktop\Code Related Folders\Untitled Trucking Server\gamemodes\MTruck.pwn(815) : error 029: invalid expression, assumed zero
C:\Users\mace\Desktop\Code Related Folders\Untitled Trucking Server\gamemodes\MTruck.pwn(815) : fatal error 107: too many error messages on one line
I'm pretty sure the issue lies within the "[0]" and me only having 1 line in the array currently, but I could be very wrong.


EDIT: Never mind. I had a major brain fart. Basically. What I did, was used the variables from the enum, but never specified what array I wanted to pull information from.
Reply
#2

You declared aTMInfo to be a two dimensional array. Instead of explicitly using literal numbers to indicate the index of the second dimension, you use an enum to 'wordify' the indices.

The correct way to access it:
PHP код:
aTMInfo[0][mission_unload_cp_x
And so forth for the rest.
Reply
#3

You can't retrieve the information directly from the enum.

PHP код:
aTMInfo[0][mission_unload_cp_x
.. instead of:

PHP код:
mission_unload_cp_x 
Edit: As the guy before me said, a bigger explanation given though.
Reply
#4

Thank you very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)