Symbol already defined
#1

here I don't get any errors:
Код:
		if(!strcmp(cmdtext,"/blabla", true, 8))
		{
			new teststring[11] = "somestring";
			print(teststring);
		  return 1;
		}

		if(!strcmp(cmdtext,"/oblabla", true, 8))
		{
			new teststring[11] = "somestring";
			print(teststring);
		  return 1;
		}
and here I get error 021: symbol already defined: "file"
Код:
		if(!strcmp(cmdtext,"/read", true, 5))
		{
			new file[14] = "ScoreList.ini";
			if(!xini_exist(file))
			{
				xini_create(file);
			}

			new Kills[10][256], KillsName[10][256], KillsValue[10], tmpp[256], vstring[2];
		  for(new v=0; v<10; v++)
		  {
		    valstr(vstring, v);
				Kills[v] = xini_get(file,"Kills",vstring,true); //full string
				KillsName[v] = extract(Kills[v], 0); //name (1st part)
				tmpp = extract(Kills[v], 1); KillsValue[v] = strval(tmpp); //value (2nd part)

				format(String, sizeof String, "%s %i", KillsName[v], KillsValue[v]);
				SendClientMessage(20, COLOR_BASIC, String);
			}
	  	return 1;
		}

		if(!strcmp(cmdtext,"/oread", true, 6))
		{
			new file[14] = "ScoreList.ini";
			if(xini_exist(file))
			{
				new Kills[10][256], KillsName[10][256], KillsValue[10], tmpp[256], vstring[2];
			  for(new v=0; v<10; v++)
			  {
			    valstr(vstring, v);
					Kills[v] = xini_get(file,"Kills",vstring,true); //full string
					KillsName[v] = extract(Kills[v], 0); //name (1st part)
					tmpp = extract(Kills[v], 1); KillsValue[v] = strval(tmpp); //value (2nd part)

					format(String, sizeof String, "%s %i", KillsName[v], KillsValue[v]);
					SendClientMessage(20, COLOR_BASIC, String);
				}
				format(String, sizeof String, "~b~ScoreList Kills:~n~~n~~w~1: %24s %i~n~2: %24s %i~n~3: %24s %i~n~4: %24s %i~n~5: %24s %i~n~6: %24s %i~n~7: %24s %i~n~8: %24s %i~n~9: %24s %i~n~10: %24s %i~n~",
				KillsName[0], KillsValue[0], KillsName[1], KillsValue[1], KillsName[2], KillsValue[2], KillsName[3], KillsValue[3], KillsName[4], KillsValue[4], KillsName[5],
				KillsValue[5], KillsName[6], KillsValue[6], KillsName[7], KillsValue[7], KillsName[8], KillsValue[8], KillsName[9], KillsValue[9]);
	      SendInfoText(playerid, 0, 200, String);
				PlayerPlaySound(playerid, CheckSound, 0.0, 0.0, 0.0);
			}
			else
			{
		    PlayerPlaySound(playerid, ErrorSound, 0.0, 0.0, 0.0);
				SendInfoText(playerid, 1200, 103, "~r~Error_o.O");
			}
	  	return 1;
		}
wtf?
Reply
#2

Just put
new file[14] = "ScoreList.ini";
on top of the callback
Reply
#3

What was wrong with your old topic where i pointed your mistake?
Reply
#4

Quote:
Originally Posted by 0rb
What was wrong with your old topic where i pointed your mistake?
I still couldn't fix it, and I didn't want to double-post in the old topic :l

Quote:
Originally Posted by dice7
Just put
new file[14] = "ScoreList.ini";
on top of the callback
that's just a work-around... I want to fix this :l
pawno shouldn't give me this error, it Isn't defined twice so there shouldn't be a problem using the same variable name twice
Reply
#5

First you have to know that the compiler can't be perfect and will never show you the exact problem of your script. In your case the compiler give this warning because something went wrong probably when allocating the memory for your variables in that function.

By default, only (but that is more than enough) around 4000 cells can be allocated in a function. You function exceed this limit by almost 3 times. I bet if you change those [10][256] by for exemple [10][25], that warning will disappear.

As i said in your previous topic, if you need big variables that will use more than 4000 cells, place them at the top of your script. I personally place most of variables, big or not, at the top of my scripts.
Reply
#6

Quote:
Originally Posted by 0rb
First you have to know that the compiler can't be perfect and will never show you the exact problem of your script. In your case the compiler give this warning because something went wrong probably when allocating the memory for your variables in that function.

By default, only (but that is more than enough) around 4000 cells can be allocated in a function. You function exceed this limit by almost 3 times. I bet if you change those [10][256] by for exemple [10][25], that warning will disappear.

As i said in your previous topic, if you need big variables that will use more than 4000 cells, place them at the top of your script. I personally place most of variables, big or not, at the top of my scripts.
I can't change it to [10][25] because I'll get the error Array sizes do not match (strtok minimum size = 256) I could change it to 128 perhaps but that's still to high right?

Quote:

I personally place most of variables, big or not, at the top of my scripts.

variables in functions, are created in the function and deleted at the end of the function, and global variables won't get deleted
so isn't that bad to place most variables at the top, since they're never erased from the memory?
Reply
#7

Then use something updated, faster and better then strtok omg
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)