[Solved] Function with returning strings - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Solved] Function with returning strings (
/showthread.php?tid=162056)
[Solved] Function with returning strings -
Manuel1948 - 22.07.2010
Hi people!
First sry for my bad English.
I wanted to create a function in which strings are getting "returned" like in split-func, look at my function:
Code:
forward ListGoods(checkpointid,bool:tanktrailer,Field[][],goods);
public ListGoods(checkpointid,bool:tanktrailer,Field[][],goods)
{
new exports,data[30];
MySQLCheckConnection();
exports=CompanyInfo[checkpointid][companyexports];
if(tanktrailer==false)
{
new count=0;
for(new i=1;i<=exports;i++)
{
switch(i)
{
case 1: {strcat(data,CompanyInfo[checkpointid][name_export1]);}
case 2: {strcat(data,CompanyInfo[checkpointid][name_export2]);}
case 3: {strcat(data,CompanyInfo[checkpointid][name_export3]);}
case 4: {strcat(data,CompanyInfo[checkpointid][name_export4]);}
}
if(strcmp(data,"Benzin",true) and strcmp(data,"Motorцl",true))
{
count++;
strcat(Field[count],data); // 1262
print(Field[count]);
print(data);
}
}
goods=count;
}
else
{
new count=0;
for(new i=1;i<=exports;i++)
{
switch(i)
{
case 1: {strcat(data,CompanyInfo[checkpointid][name_export1]);}
case 2: {strcat(data,CompanyInfo[checkpointid][name_export2]);}
case 3: {strcat(data,CompanyInfo[checkpointid][name_export3]);}
case 4: {strcat(data,CompanyInfo[checkpointid][name_export4]);}
}
if(strcmp(data,"Benzin",true) and strcmp(data,"Motorцl",true))
{
count++;
strcat(Field[count],data); // 1284
print(Field[count]);
print(data);
}
}
goods=count;
}
}
and this function should be used somewhere in the script:
Code:
new ladung[6][30],ladungen,string[256];
ListGoods(checkpointid,false,ladung,ladungen);
but on compiling they are these errors:
Code:
(1262) : warning 224: indeterminate array size in "sizeof" expression (symbol "maxlength")
(1284) : warning 224: indeterminate array size in "sizeof" expression (symbol "maxlength")
I don't know what I do wrong, I have looked 1000 times at the split function, but I didn't found an error
Edit: I wrote the third argument in error lines as 30 (strcat(arg1,arg2,30)). But I don't know how to delete my own post, only can edit it?!
Re: [Solved] Function with returning strings -
snoob - 22.07.2010
what ever you do, ... a public function can not return an array.
AW: [Solved] Function with returning strings -
Manuel1948 - 22.07.2010
this is false public function can return integers, and indirectly all this is why i wrote "returned" and not returned
Re: [Solved] Function with returning strings -
Joe_ - 22.07.2010
Didn't see [solved] tag, sorry just woken up lol, please forgive me :P