Returning strings in a public
#8

Due to the architecture of the public functions, it's only possible to return one-cell values (integers, characters, float values) since they were specifically designed to do so. You'll have to stick to using properties, for now.

I was actually writing a script that modifies the return address of a function to return a string, but it only returned the first character, which made me believe that you can't return strings with them at all, sorry to say (perhaps, I can work something out).

Quote:
Originally Posted by LeLeTe
Посмотреть сообщение
I did and got no errors.

Here's how i've done it (gotta say i kinda borrowed the idea while reading one of ******'s posts)

Код:
public Anypublic(playerid)
{
new string[24];
GetPlayerName(playerid, string, 24);
return string, 1;
}
Is it only for me the code's working?
That won't work. You can't return multiple values in PAWN. That will just return "1".

Quote:
Originally Posted by Djole1337
Посмотреть сообщение
or something like this...?
pawn Код:
// Some FS
new
    somestr[8] = "abcd123";
forward GetSomeStr(idx);
public GetSomeStr(idx)
{
     return somestr[idx];
}
// GM
new
    str[8];
for (new idx = 0; idx != 8; ++ idx)
{
    str[idx] = CallRemoteFunction("GetSomeStr", "i", idx);
    if (str[idx] == '\0') break;
}
printf("%s", str);
That will keep calling the function until the string has reached it's end. It's horribly inefficient, especially if you want to return strings with 100+ characters.
Reply


Messages In This Thread
Returning strings in a public - by LeLeTe - 20.12.2013, 23:22
Re: Returning strings in a public - by PowerPC603 - 20.12.2013, 23:32
Re: Returning strings in a public - by LeLeTe - 20.12.2013, 23:40
Re: Returning strings in a public - by Jefff - 21.12.2013, 00:08
Re: Returning strings in a public - by Djole1337 - 21.12.2013, 00:17
Re: Returning strings in a public - by PowerPC603 - 21.12.2013, 18:40
Re: Returning strings in a public - by Konstantinos - 21.12.2013, 18:42
Re: Returning strings in a public - by Emmet_ - 21.12.2013, 19:10
Re: Returning strings in a public - by Djole1337 - 21.12.2013, 20:58
Re: Returning strings in a public - by Emmet_ - 21.12.2013, 21:18

Forum Jump:


Users browsing this thread: 1 Guest(s)