[Include] returnf.inc BETA
#1

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.
Reply
#2

Hmm. It seems interesting!
Reply
#3

Does it supports integer?
Reply
#4

Good work ipleo !
Reply
#5

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
Reply
#6

I don't know how i can i use it in my develope way. Anyway very nice. Interesting code rep+
Reply
#7

Woah, this is pretty usefull!
Reply
#8

Can be optimized, but I like the idea. Good job on that.
Reply
#9

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.
Reply
#10

Nice idea
Reply
#11

Looks great good job
Reply
#12

Not a bad idea at all! We can return strings with it anywhere. Pretty useful!
Reply
#13

Peace.
This thing rocks , very nice idea pleo <3 it
Reply
#14

Thanks guys.

- Released an updated version. See changelogs.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)