Author Topic: Formatted Strings  (Read 154 times)

Offline Lordz

  • Beta Tester
  • Sr. Member
  • ****
  • Posts: 1238
  • Location: Earth
    • RBTDM
Formatted Strings
« on: May 03, 2013, 08:54:19 pm »
Hello all,
I've been working on a new low-level coding library "L_coding" AKA "L_scripting" and it's been a while since I've working into it. Though, it's not yet completely done as I gotta create more functions; and callbacks - if necessary. This formatting method if idea was inspired by 'Double-O-Seven' so thanks to him too for the idea of formatting. So, I thought of releasing some of the parts right now, which will be good for coders or scripters to script more easily without formatting any string.

Normal formatting string method

This is how we format a string normally:
Code: [Select]
//To message player's name:
new Lname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Lname, sizeof(Lname));
new string[128];
format(string, sizeof(string), "Your name is : %s", Lname); //We are creating another extra string and formatting it..
SendClientMessage(playerid, -1, string);

Where as after including this function:

Code: [Select]
new Lname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Lname, sizeof(Lname));
SendClientMessageFormatted(playerid, -1, "Your name is : %s", Lname);

Functions included:


SendClientMessageFormatted(playerid, color, message[], {_Float;...});
SendClientMessageToAllFormatted(color, message[], {_Float;...});
GameTextForPlayerFormatted(playerid, message[], time, style, {_Float;...});
GameTextForAllFormatted(message[], time, style, {_Float;...});
TextDrawSetStringFormatted(textdrawid, message[], {_Float;...});
PlayerTextDrawSetStringFormatted(playerid, playertext:textdrawid, message[], {_Float;...});
TextDrawCreateFormatted(Float:X, Float:Y, message[], {_Float;...});


{_Float;...}
means the formatting stuff.

By download this you must agree that you're not gonna release this anywhere without my permission. Try to do so, and you will see yourself getting fuc*ed.

Download: http://pastebin.com/ADg6rkMw


I'm providing download as there's some scripters here in this server and it will be useful for them to create anything for YG and also for personal usage. I've used macro type of coding as it's more easier to create it in a 'do' loop rather than creating big stock functions. If you've doubts or bugs relating this, please mention it


Add this below a_samp, include to get executed.

Next version is there on BETA:
Working on 3DText labels and other string functions.


Regards,
Lordz.
« Last Edit: May 16, 2013, 11:07:31 pm by Lordz »

Share on Bluesky Share on Facebook