Return an array in public
#1

Hello. I'm working on a function for my server, however I always get an error, telling me I can't return a string in a public function. I tried to put the string into strlen(), which showed no result at all, so I'm asking for a help here.
Thanks!

Код:
public OnPlayerText(playerid, text[])
{
	new string[160], pName[32];
	GetPlayerName(playerid, pName, sizeof(pName));
	if(GetPVarInt(playerid, "Infected") == 1)
	{
		format(string, sizeof(string), "[Person %d]: %s", GetNumber(pName), text);
		return string;
	}
	else return 1;
}
The errors are:
Код:
C:\Users\Viktor\Desktop\lol.pwn(18) : error 090: public functions may not return arrays (symbol "OnPlayerText")
C:\Users\Viktor\Desktop\lol.pwn(20) : error 079: inconsistent return types (array & non-array)
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[160], pName[32];
    GetPlayerName(playerid, pName, sizeof(pName));
    if(GetPVarInt(playerid, "Infected") == 1)
    {
        format(string, sizeof(string), "[Person %d]: %s", GetNumber(pName), text);
            SendClientMessageToAll(0xFFFFFFFF,string);
        return 0;
    }
    else return 1;
}
Try this.
Reply
#3

I don't want a SendClientMessage there, I want to return that value.
You know, somebody might be using ProxDetector or his own SendClientMessage in OnPlayerText, so he will need to change it, I just want the public to return THAT format I have.
Reply
#4

public function cannot return a string, you need a stock.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)