error 090: public functions may not return arrays (symbol "InsertState")
#1

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?
Reply
#2

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.
Reply
#3

If it absolutely needs to be a public function (rarely) then you can pass the output array by reference, similarly to how GetPlayerName works.
Reply
#4

It works Thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)