Issue with using switch.
#1

After the little bit of help I got last night, I decided to make this stock function to speed up the development process, and this is the issue I am running into with it.

Error the compiler outputs:
Код:
C:\Users\mace\Desktop\Code Related Folders\Untitled Trucking Server\gamemodes\MTruck.pwn(1878) : error 029: invalid expression, assumed zero
The stock function:
Код:
stock ChooseMissionRewardOffJobNumber(playerid)
{
	new string[144], string2[144], reward;
	switch(aTMInfo[][mission_number]) // This is the issue.
	{
		case 0:
		{
			reward = randomEx(950, 1250);
			GivePlayerMoney(playerid, reward);
			format(string, sizeof(string), "%s: Thanks for moving that freight. Good job.", aTMInfo[0][mission_actor_name], reward);
			format(string2, sizeof(string2), "%s(%d) Has moved some frieght for Steve earning a grand total of $%d.", PlayerName(playerid), playerid, reward);
			SendMessage(playerid, -1, string);
			SendMessageToAll(-1, string2);
		}
		case 1:
		{
			reward = randomEx(1000, 1500);
			GivePlayerMoney(playerid, reward);
			format(string, sizeof(string), "%s: You finished just in time. Good job!", aTMInfo[0][mission_actor_name], reward);
			format(string2, sizeof(string2), "%s(%d) has finished working for Ian in Doherty earning a cool $%d.", PlayerName(playerid), playerid, reward);
			SendMessage(playerid, -1, string);
			SendMessageToAll(-1, string2);
		}
	}
	return 1;
}
Reply
#2

You can't leave that empty. It has to access an index for it to be able to switch through a value.

EDIT: 'that' as in the first dimension of the array.
Reply
#3

What would I put in it to use it with switch?
Reply
#4

A reward is given after completing a mission, so I would store the player's missionid in a player variable when the player starts the mission and then use that variable to switch through the different cases.
Reply
#5

Alright. Thank you very much!
Reply
#6

Have a look here: https://sampforum.blast.hk/showthread.php?tid=570635
You made a function, not a "stock function".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)