Returning a string - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Returning a string (
/showthread.php?tid=248577)
Returning a string -
maramizo - 14.04.2011
I would like to know how to return a string a function, I tried "Char*" but it didn't work.
Thanks!
Re: Returning a string -
Kyle - 14.04.2011
Example:
pawn Code:
stock ExampleStock(auto)
{
new stringer[56];
if(auto == 1) { stringer = "Testing No.1"; }
if(auto == 2) { stringer = "Testing No.2"; }
if(auto == 3) { stringer = "Testing No.3"; }
if(auto == 4) { stringer = "Testing No.4"; }
return stringer;
}
If you was to do ExampleStock(2); - It would return the string "Testing No.2"
Re: Returning a string -
maramizo - 14.04.2011
And how do I use stringer?
Re: Returning a string -
~Yoshi - 14.04.2011
stringer is the name of the string in this example..
Re: Returning a string -
Kyle - 14.04.2011
stringer is a string, it contains the string when formatted.
e.g
format(string,sizeof(string),"examplestock = %s",ExampleStock(2));
SendClientMessage(playerid,COLOR_RED,string);
Re: Returning a string -
maramizo - 14.04.2011
Precisely what I was looking for. Thanks!