SA-MP Forums Archive
Compiling Error - 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)
+--- Thread: Compiling Error (/showthread.php?tid=633206)



Compiling Error - NealPeteros - 27.04.2017

Is there something missing here?

PASTEBIN LINK (too large for [code])


Re: Compiling Error - Kane - 27.04.2017

What's the error?


Re: Compiling Error - NealPeteros - 27.04.2017

Ah, my mistake. Well, the compiler just stops working/crashes ("The compiler has stopped working"). It's like there's a missing bracket, return value, or anything that's causing this to happen.


Re: Compiling Error - Hansrutger - 27.04.2017

Remove parts of your code that you think is wrong until you find what it is, usually a big syntax fault.


Re: Compiling Error - NealPeteros - 27.04.2017

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
Remove parts of your code that you think is wrong until you find what it is, usually a big syntax fault.
Tried it. The error seems to be somewhere here

Код:
                       case DIALOG_CSTEAL:
			{
   				for(new i=0;i < MAX_PLAYERS;i++)
       			        {
		        	if(GetPlayerInterior(playerid) == cActor[i][Interior])
			        {
		        		if(IsPlayerInRangeOfPoint(playerid, 1.0, cActor[i][Pos][0],cActor[i][Pos][1], cActor[i][Pos][2]))
			        	{
       	    				switch(listitem)
       	    				{
       	    				    new string[360];
       	    				    case 0:
								{
								    format(string, 128, "* %s takes an item from the %s's corpse.", GetName(playerid), cActor[i][cName]);
        							ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        							GivePlayerMoney(playerid, cActor[i][cMoney]);
        							cActor[i][cMoney] = 0;
								}
								case 1:
        						{
								    format(string, 128, "* %s takes an item from %s's corpse.", GetName(playerid), cActor[i][cName]);
        							ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        							PlayerInfo[playerid][dLSD] += cActor[i][LSD];
        							cActor[i][LSD] = 0;
								}
								case 2:
								{
								    format(string, 128, "* %s takes an item from %s's corpse.", GetName(playerid), cActor[i][cName]);
        							ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        							PlayerInfo[playerid][dCocaine] += cActor[i][Cocaine];
        							cActor[i][Cocaine] = 0;
								}
       	    				    case 3:
       	    				    {
								    format(string, 128, "* %s takes an item from %s's corpse.", GetName(playerid), cActor[i][cName]);
        							ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        							PlayerInfo[playerid][dMarijuana] += cActor[i][Marijuana];
        							cActor[i][Marijuana] = 0;
								}
								case 4:
								{
								    format(string, 128, "* %s takes an item from %s's corpse.", GetName(playerid), cActor[i][cName]);
        							ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        							PlayerInfo[playerid][dMeth] += cActor[i][Meth];
        							cActor[i][Meth] = 0;
								}
								case 5:
								{
								    format(string, 128, "* %s takes an item from %s's corpse.", GetName(playerid), cActor[i][cName]);
        							ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        							PlayerInfo[playerid][Ecstasy] += cActor[i][Ecstasy];
        							cActor[i][Ecstasy] = 0;
								}
								case 6:
								{
								    format(string, 128, "* %s takes an item from %s's corpse.", GetName(playerid), cActor[i][cName]);
        							ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        							PlayerInfo[playerid][dHeroin] += cActor[i][Heroin];
        							cActor[i][Heroin] = 0;
								}
								case 7:
								{
								    format(string, 128, "* %s takes an item from %s's corpse.", GetName(playerid), cActor[i][cName]);
        							ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        							PlayerInfo[playerid][dCrack] += cActor[i][dCrack];
        							cActor[i][dCrack] = 0;
								}
							}
						}
					}
				}
			}



Re: Compiling Error - Kane - 27.04.2017

See if you're missing a return.


Re: Compiling Error - NealPeteros - 27.04.2017

Error seems to be somewhere here.

Code:
new string[360];
case 0:
{
format(string, sizeof(string), "* %s takes an item from the %s\'s corpse.", GetName(playerid), cActor[i][cName]);
ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
GivePlayerMoney(playerid, cActor[i][Money]);
cActor[i][Money] = 0
}
case 1:
        						{
format(string, sizeof(string), "* %s takes an item from %s\'s corpse.", GetName(playerid), cActor[i][cName]);
ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerInfo[playerid][dLSD] += cActor[i][LSD];
cActor[i][LSD] = 0;
}
case 2:
{
format(string, sizeof(string), "* %s takes an item from %s\'s corpse.", GetName(playerid), cActor[i][cName]);
ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerInfo[playerid][dCocaine] += cActor[i][Cocaine];
cActor[i][Cocaine] = 0;
}
case 3:
{
format(string, sizeof(string), "* %s takes an item from %s\'s corpse.", GetName(playerid), cActor[i][cName]);
ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerInfo[playerid][dMarijuana] += cActor[i][Marijuana];
cActor[i][Marijuana] = 0;
}
case 4:
{
format(string, sizeof(string), "* %s takes an item from %s\'s corpse.", GetName(playerid), cActor[i][cName]);
ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerInfo[playerid][dMeth] += cActor[i][Meth];
cActor[i][Meth] = 0;
}
case 5:
{
format(string, sizeof(string), "* %s takes an item from %s\'s corpse.", GetName(playerid), cActor[i][cName]);
ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerInfo[playerid][Ecstasy] += cActor[i][Ecstasy];
cActor[i][Ecstasy] = 0;
}
case 6:
{
format(string, sizeof(string), "* %s takes an item from %s\'s corpse.", GetName(playerid), cActor[i][cName]);
ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerInfo[playerid][dHeroin] += cActor[i][Heroin];
cActor[i][Heroin] = 0;
}
case 7:
{
format(string, sizeof(string), "* %s takes an item from %s\'s corpse.", GetName(playerid), cActor[i][cName]);
ProxDetector(8.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerInfo[playerid][dCrack] += cActor[i][dCrack];
cActor[i][dCrack] = 0;
}



Re: Compiling Error - Hansrutger - 27.04.2017

PlayerInfo[playerid][dCrack] += cActor[i][dCrack];

Should be without a d? And on anothet place it should be with a d. Not sure if this is the problem but can be since using two different enumeration declarations in the same array variable can cause these problems. Let us know.


Re: Compiling Error - NealPeteros - 27.04.2017

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
PlayerInfo[playerid][dCrack] += cActor[i][dCrack];

Should be without a d? And on anothet place it should be with a d. Not sure if this is the problem but can be since using two different enumeration declarations in the same array variable can cause these problems. Let us know.
That's a problem, but changing it didn't work


Re: Compiling Error - Hansrutger - 27.04.2017

You are using very common names for your array index placeholders (enum names) which worries me.

Delete line by line (just take one of the cases) and see which line it is. If it's to do with any enum then I suggest you rename your enum placeholder name's.


Re: Compiling Error - NealPeteros - 27.04.2017

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
You are using very common names for your array index placeholders (enum names) which worries me.

Delete line by line (just take one of the cases) and see which line it is. If it's to do with any enum then I suggest you rename your enum placeholder name's.
Tried adding 'c' in all the arrays (ie: cMoney, cInterior, cWorld), didn't work. Tried commenting a whole case statement and even came up to the point where all case statements are commented. Stil didn't work.


Re: Compiling Error - NealPeteros - 27.04.2017

This may sound confusing, I tried deleting "new string[360];" then the compiling errors stopped. An explanation would be great. Probably variables are not allowed to be created inside a \'switch\' statement?



EDIT: Yup, variables are not allowed to be created inside a \'switch\' statement. Tried moving the variable outside/before the \'switch\' statement, and it worked. +rep for you guys