SA-MP Forums Archive
Why does 1 method work and other doesen't (cache_get_field_content) - 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: Why does 1 method work and other doesen't (cache_get_field_content) (/showthread.php?tid=580928)



Why does 1 method work and other doesen't (cache_get_field_content) - Dan. - 09.07.2015

This works:
Код:
  		cache_get_field_content(0, "Name", string);
  		format(BaseInfo[baseid][bName], sizeof(string), string);
  		printf("Loaded base name, enum is now set to %s", BaseInfo[baseid][bName]);
But this doesen't:
Код:
  		cache_get_field_content(0, "Name", BaseInfo[baseid][bName]);
  		printf("Loaded base name, enum is now set to %s", BaseInfo[baseid][bName]);
My enum:
Код:
enum bInfo {
	bName[128],
The first method correctly prints out the result.. the other method doesen't print anything (blank).


Re: Why does 1 method work and other doesen't (cache_get_field_content) - Vince - 09.07.2015

Because there is a 4th, optional, parameter which is the size of the buffer.
PHP код:
sizeof(string) 
Will return the size of the string as you would expect, however
PHP код:
sizeof(BaseInfo[baseid][bName]) 
Is invalid and therefore 0.