returnf.inc BETA -
iPLEOMAX - 05.03.2012
returnf
For the above image, the code looks like:
pawn Код:
RET:time()
{
new hr, mn, sc;
gettime(hr, mn, sc);
RETF("%i:%i", hr, mn);
}
RET:myscore(playerid)
{
RETF("%i", GetPlayerScore(playerid));
}
RET:randomcar() RETF("%s", aVehicleNames[random(sizeof aVehicleNames)]);
RET:dice() RETF("%i", random(6)+1);
RET:toss() RETF("%s", (random(2)) ? ("Head") : ("Tail"));
public OnPlayerText(playerid, text[])
{
returnf(text, playerid);
//There could be a bug due to the string lengths..
//If you type a text that is 30 characters,
//and the format returns something bigger than 30,
//The returned result will get trimmed.
//Best would be to format it into a longer string (create a new one).
return true;
}
Download:
Pastebin - RAW
Mediafire
Changelog:
Код:
* 5/Mar/2012: Initial Release.
* 6/Mar/2012: Minor Fix + Removed useless debug part of the code.
Modified the RETF function, you can use floats/ints/strings etc.
How to Use:
pawn Код:
//Create a new return function:
RET:developer()
{
RETF("%s", "Kalcor");
}
//Now, use
returnf("Haha, this is something cool. Creator of SA-MP: #developer#");
This will replace the string's #developer# to "Kalcor".
If you use it in Commands/Text, same thing will happen.
Legal:
Mozilla Public License 2.0
Don't release any other version without my permission.
Bugs:
Report if you find any.
Re: returnf.inc BETA -
Konstantinos - 05.03.2012
Hmm. It seems interesting!
Re: returnf.inc BETA - T0pAz - 05.03.2012
Does it supports integer?
Re: returnf.inc BETA -
Michael@Belgium - 05.03.2012
Good work ipleo !
Re: returnf.inc BETA -
Hiddos - 05.03.2012
Quote:
Originally Posted by T0pAz
Does it supports integer?
|
I don't think it does, looking at the code. Only strings.
Nevertheless, this sure looks pretty interesting. Good job
Re: returnf.inc BETA -
s3rious - 05.03.2012
I don't know how i can i use it in my develope way. Anyway very nice. Interesting code
rep+
Re: returnf.inc BETA -
wups - 05.03.2012
Woah, this is pretty usefull!
Re: returnf.inc BETA -
RyDeR` - 05.03.2012
Can be optimized, but I like the idea. Good job on that.
Re: returnf.inc BETA -
iPLEOMAX - 05.03.2012
Thanks everyone!
About int, float supports, for now, you can format it into a string and RETF it...
I'll add more args and tag support in next version.
Quote:
Originally Posted by RyDeR`
Can be optimized, but I like the idea. Good job on that.
|
Thanks and I'm sure you can optimize it the best.
I'll try it too.
Re: returnf.inc BETA -
Shadow_ - 05.03.2012
Nice idea
Re: returnf.inc BETA -
vyper - 05.03.2012
Looks great
good job
Re: returnf.inc BETA -
Ballu Miaa - 06.03.2012
Not a bad idea at all! We can return strings with it anywhere. Pretty useful!
Re: returnf.inc BETA -
Niko_boy - 06.03.2012
Peace.
This thing rocks , very nice idea pleo
<3 it
Re: returnf.inc BETA -
iPLEOMAX - 06.03.2012
Thanks guys.
- Released an updated version. See changelogs.