SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 23/07/2013, 07:38 PM   #31
Omirrow
Huge Clucker
 
Join Date: Feb 2013
Location: Turkey
Posts: 285
Reputation: 8
Default Re: formatex - Improved "format" function!

Very nice man, I like it.
Omirrow is offline   Reply With Quote
Old 24/07/2013, 01:07 PM   #32
Darnell
Gangsta
 
Darnell's Avatar
 
Join Date: Jul 2010
Posts: 824
Reputation: 35
Default Re: formatex - Improved "format" function!

Amazing!
Darnell is offline   Reply With Quote
Old 14/03/2015, 08:55 PM   #33
Ryan_Bowe
Huge Clucker
 
Join Date: Jul 2012
Location: United States
Posts: 219
Reputation: 16
Default Re: formatex - Improved "format" function!

Did the vehicle names break in 0.3.7 R2?

I've created a simple loop to test.
Code:
for (new i = 400; i < 611; i++)
    printf("%v", i);
Here is the server log.

Sscanf2 is included before formatex and is updated to the most recent version. I have not modified formatex.

I know the include works because %p works just fine.
Ryan_Bowe is offline   Reply With Quote
Old 01/04/2016, 07:17 PM   #34
Dayvison_
High-roller
 
Dayvison_'s Avatar
 
Join Date: Nov 2013
Posts: 1,317
Reputation: 200
Default Re: formatex - Improved "format" function!

How to substitute native mysql_format for formatex without lost the mysql log. I see the include, maybe this?
PHP Code:
stock mysql_formatex(connectionHandleszOutput[], iLength sizeof(szOutput), const szFormatString[], GLOBAL_TAG_TYPES:...) {
... 
Same Codes
        
// New format specifier
        #emit PUSH.C     s_szBuffer
    
        // Max length
        #emit PUSH.S     iLength
    
        // Output string
        #emit PUSH.S     szOutput
           // Handle
        #emit PUSH.S     connectionHandle
        // Argument count
        #emit LOAD.S.pri iArgCount
        #emit SHL.C.pri  2
        #emit ADD.C      16
        #emit PUSH.pri
    
        // Save the argument count for later
        #emit MOVE.alt
    
        // Call format (duh)
        #emit SYSREQ.C   mysql_format
... Same More codes 
But i not understand completely emit, and i lost others address.

Slice, your releases are awesome.
__________________


Dayvison_ is offline   Reply With Quote
Old 03/04/2016, 03:18 AM   #35
bsHoX
Little Clucker
 
bsHoX's Avatar
 
Join Date: Feb 2016
Posts: 15
Reputation: 0
Default Re: formatex - Improved "format" function!

"Yeah day, i have the same question"
bsHoX is offline   Reply With Quote
Old 02/10/2016, 10:02 AM   #36
AndySedeyn
High-roller
 
AndySedeyn's Avatar
 
Join Date: Feb 2014
Location: Belgium
Posts: 1,207
Reputation: 681
Default Re: formatex - Improved "format" function!

The %q specifier returns null when using this include:

PHP Code:
#include <a_samp>

main() {

    
printf("Straight: '%q'""AndySedeyn");

Prints:
Code:
[11:49:32] Straight: 'AndySedeyn'
And
PHP Code:
#include <a_samp>
#include <formatex>

main() {

    
printf("Straight: '%q'""AndySedeyn");

Prints:
Code:
[11:53:11] Straight: ''
EDIT:

Here's the fixed formatex function: http://pastebin.com/gvE8PqBK , altered code:
PHP Code:
// Handled by the original format function
case '*''i''d''x''h''c''s''f''b''q': { // I added 'q'
    // Get the argument address and save it for later
    #emit LCTRL        5
    #emit LOAD.S.alt  iArg
    #emit ADD
    #emit LOAD.I
    #emit STOR.S.pri  iAddress
    #emit MOVE.pri
    #emit ADD.C       4
    #emit STOR.S.pri  iArg

    
aiArgs[iArgCount++] = iAddress;

    if (
s_szBuffer[iPos] == '*')
        continue;

    break;


Last edited by AndySedeyn; 02/10/2016 at 01:01 PM.
AndySedeyn is offline   Reply With Quote
Old 20/08/2017, 02:55 PM   #37
Adiiti
Big Clucker
 
Adiiti's Avatar
 
Join Date: Apr 2017
Location: Funchal, Madeira, Portugal
Posts: 160
Reputation: 9
Default Re: formatex - Improved "format" function!

I have formatex in my server but in some messages instead of appearing the value appears the letter m

PHP Code:
FormatSpecifier<'m'>(output[], amount) {
    if (
amount) {
        new
            
18,
            
neg amount 0
        
;
        
        
// The spaces must be there, otherwise strdel below won't work
        // on lower numbers.
        
output "$                ";
        
        
// Null-out the end of it
        
output[i] = 0;
        
        if (
neg)
            
amount = -amount;
        
        
// Going right-left, add one number each time
        
while (amount) {
            
// Add a thousand separator every 3rd time
            
if (!((1) % 4))
                
output[--i] = '.';
            
            
// Now add the last digit of the number
            
output[--i] = '0' + (amount 10);
            
            
// Then divide the number by 10, so digit in the end will be gone
            
amount /= 10;
        }
        
        
// Delete the spaces between the $-sign and the first (last) number
        
strdel(output1i);
        
        
// Add a minus sign if needed
        
if (neg)
            
strins(output"-"1);
    } else {
        
output "$0";
    }

__________________


Developing Paraíso Brasileiro RPG
Developing Nova Vida Social RPG



Discord: André Freitas#5343
Adiiti is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Warning 209: function "CreateDynamicVehicle" should return a value." rati555 Scripting Help 2 06/11/2011 06:18 PM
"Warning 209: function "cmd_enter" should return a value." Urgent help needed! pEar Scripting Help 3 10/09/2011 05:55 PM
Little "format" and "dini" help blackwave Help Archive 3 28/12/2010 11:28 AM
"Run time error 19: "File or function is not found" TouR Help Archive 2 18/06/2010 10:04 AM


All times are GMT. The time now is 12:02 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.