error 090: public functions may not return arrays (symbol "InsertState") - 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: error 090: public functions may not return arrays (symbol "InsertState") (
/showthread.php?tid=504679)
error 090: public functions may not return arrays (symbol "InsertState") -
trukker1998 - 05.04.2014
Hi,
I made a function, but it returns `error 090: public functions may not return arrays (symbol "InsertState")`
My code:
Код:
public InsertState(playerid, reason)
{
new Username = GetPlayersRealId(playerid);
new usersname[MAX_PLAYER_NAME];
GetPlayerName(playerid, usersname, sizeof(usersname));
new string[900];
new realreason[255];
switch(reason)
{
case 0:
{
realreason = "Has left";
}
case 1:
{
realreason = "Has been kicked";
}
case 2:
{
realreason = "Has joined";
}
case 3:
{
realreason = "Has been banned";
}
case 4:
{
realreason = "Has been killed";
}
case 5:
{
realreason = "Has turned on the radio";
}
}
format(string, sizeof(string), "INSERT INTO `updates` (id, uid, reason, time) VALUES ('', '%s', '$s', UNIX_TIMESTAMP())", Username, realreason);
mysql_query(string);
new back[255];
format(back, sizeof(back), "StateUpdate for player %s: %s", usersname, realreason);
return back;
}
Does anyone know the problem?
Re: error 090: public functions may not return arrays (symbol "InsertState") -
Konstantinos - 05.04.2014
Public functions cannot return an array/string.
Replace
public with
stock and remove the
forward line of it.
By the way, use smaller sizes for your arrays. 900 and 255 are way too high.
Re: error 090: public functions may not return arrays (symbol "InsertState") -
Vince - 05.04.2014
If it absolutely
needs to be a public function (rarely) then you can pass the output array by reference, similarly to how GetPlayerName works.
Re: error 090: public functions may not return arrays (symbol "InsertState") -
trukker1998 - 06.04.2014
It works Thanks!