Returning strings in a public
#6

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?
Have you made a print what you're actually returning?
I've seen a tutorial a few days ago and a line with multiple things after return would return only the last value.
So I think you're only returning the value "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);
I understand this code, but it seems you're using alot of CallRemoteFunction for one string, especially when it's large (say 50 characters).
But it would work.

I used another approach for this:
http://forum.sa-mp.com/showpost.php?...39&postcount=5

Script A needs a string stored in script B;
Script A therefore uses CallRemoteFunction to ask script B to send the string back.
Script B uses another CallRemoteFunction to send the string in one go back to script A, which stores it in a special place.
Then script A is able to use the entire string at once.
It doesn't have to grab character per character from script B and reconstruct it again.
I don't know which one is faster.

My approach works perfectly as well but to avoid too many CallRemoteFunctions, I'm merging all my filterscripts into one big script.
Then only CallRemoteFunction must be used between this big filterscript and the gamemode.
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: 2 Guest(s)