ShowBell Posted July 13, 2011 Report Posted July 13, 2011 Vreau sa fac un script sa desparta banii de ex 10000 sa fie sub forma 10.000 in game.Am facut stock dar nu imi apare, ce am gresit?stock FormatMoney(Float:amount, delimiter[2]=".") { #define MAX_MONEY_STRING 16 new txt[MAX_MONEY_STRING]; format(txt, MAX_MONEY_STRING, "$%d", floatround(amount)); new l = strlen(txt); if (amount < 0) { if (l > 5) strins(txt, delimiter, l-3); if (l > 8) strins(txt, delimiter, l-6); if (l > 11) strins(txt, delimiter, l-9); } else { if (l > 4) strins(txt, delimiter, l-3); if (l > 7) strins(txt, delimiter, l-6); if (l > 10) strins(txt, delimiter, l-9); } return txt; }
IstuntmanI Posted July 13, 2011 Report Posted July 13, 2011 http://www.sa-mp.ro/forum/index.php/topic,10232.0.html => FormatNumber
ShowBell Posted July 13, 2011 Author Report Posted July 13, 2011 FormatNumber( number ){ new Str[ 15 ]; format( Str, 15, "%d", number ); if ( strlen( Str ) < sizeof( Str ) ) { if ( number >= 1000 && number < 10000 ) strins( Str, ".", 1, sizeof( Str ) ); else if ( number >= 10000 && number < 100000 ) strins( Str, ".", 2, sizeof( Str ) ); else if ( number >= 100000 && number < 1000000 ) strins( Str, ".", 3, sizeof( Str ) ); else if ( number >= 1000000 && number < 10000000 ) strins( Str, ".", 1, sizeof( Str ) ),strins( Str, ".", 5, sizeof( Str ) ); else if ( number >= 10000000 && number < 100000000) strins( Str, ".", 2, sizeof( Str ) ),strins( Str, ".", 6, sizeof( Str ) ); else if ( number >= 100000000 && number < 1000000000 ) strins( Str, ".", 3, sizeof( Str ) ),strins( Str, ".", 7, sizeof( Str ) ); else if ( number >= 1000000000 && number < 10000000000 ) strins( Str, ".", 1, sizeof( Str ) ), strins( Str, ".", 5, sizeof( Str ) ), strins( Str, ".", 9, sizeof( Str ) ); else format( Str, 10, "%d", number ); } else format( Str, 15, "<ERROR>" ); return Str;}asa il pun in script sau cum?
IstuntmanI Posted July 13, 2011 Report Posted July 13, 2011 Folosire adica:new Str[ 256 ], zMoney = GetPlayerMoney( playerid ) ; format( Str, sizeof (Str), "Ai $%s", FormatNumber( zMoney ); SendClientMessage( playerid, 0xFF00FFFF, Str );e pentru cand apelez comanda?E bine sinew Str[ 128]; format( Str, 128, "Ai $%s", FormatNumber( GetPlayerMoney( playerid ) ) ); SendClientMessage( playerid, 0xFF00FFFF, Str );
ShowBell Posted July 13, 2011 Author Report Posted July 13, 2011 FormatNumber( number ){ new Str[ 15 ]; format( Str, 15, "%d", number ); if ( strlen( Str ) < sizeof( Str ) ) { if ( number >= 1000 && number < 10000 ) strins( Str, ".", 1, sizeof( Str ) ); else if ( number >= 10000 && number < 100000 ) strins( Str, ".", 2, sizeof( Str ) ); else if ( number >= 100000 && number < 1000000 ) strins( Str, ".", 3, sizeof( Str ) ); else if ( number >= 1000000 && number < 10000000 ) strins( Str, ".", 1, sizeof( Str ) ),strins( Str, ".", 5, sizeof( Str ) ); else if ( number >= 10000000 && number < 100000000) strins( Str, ".", 2, sizeof( Str ) ),strins( Str, ".", 6, sizeof( Str ) ); else if ( number >= 100000000 && number < 1000000000 ) strins( Str, ".", 3, sizeof( Str ) ),strins( Str, ".", 7, sizeof( Str ) ); else if ( number >= 1000000000 && number < 10000000000 ) strins( Str, ".", 1, sizeof( Str ) ), strins( Str, ".", 5, sizeof( Str ) ), strins( Str, ".", 9, sizeof( Str ) ); else format( Str, 10, "%d", number ); } else format( Str, 15, "<ERROR>" ); return Str;}asa il pun in script?pun cu public FormatNumber( number )sau stock FormatNumber( number )sau cum?
IstuntmanI Posted July 13, 2011 Report Posted July 13, 2011 FormatNumber( number ){ new Str[ 15 ]; format( Str, 15, "%d", number ); if ( strlen( Str ) < sizeof( Str ) ) { if ( number >= 1000 && number < 10000 ) strins( Str, ".", 1, sizeof( Str ) ); else if ( number >= 10000 && number < 100000 ) strins( Str, ".", 2, sizeof( Str ) ); else if ( number >= 100000 && number < 1000000 ) strins( Str, ".", 3, sizeof( Str ) ); else if ( number >= 1000000 && number < 10000000 ) strins( Str, ".", 1, sizeof( Str ) ),strins( Str, ".", 5, sizeof( Str ) ); else if ( number >= 10000000 && number < 100000000) strins( Str, ".", 2, sizeof( Str ) ),strins( Str, ".", 6, sizeof( Str ) ); else if ( number >= 100000000 && number < 1000000000 ) strins( Str, ".", 3, sizeof( Str ) ),strins( Str, ".", 7, sizeof( Str ) ); else if ( number >= 1000000000 && number < 10000000000 ) strins( Str, ".", 1, sizeof( Str ) ), strins( Str, ".", 5, sizeof( Str ) ), strins( Str, ".", 9, sizeof( Str ) ); else format( Str, 10, "%d", number ); } else format( Str, 15, "<ERROR>" ); return Str;}asa il pun in script?Ala il pui undeva in script ( jos in script de preferat ), iar apoi il folosesti asa:stuntman[]! link=topic=13870.msg84786#msg84786 date=1310574669]new Str[ 128]; format( Str, 128, "Ai $%s", FormatNumber( GetPlayerMoney( playerid ) ) ); SendClientMessage( playerid, 0xFF00FFFF, Str ); Sfat: Pentru coduri foloseste [nobbc]//cod\\[/nobbc]
ShowBell Posted July 13, 2011 Author Report Posted July 13, 2011 asta las putea folosi sa imi delimiteze si suma de la /stats adica cash si bank?
IstuntmanI Posted July 13, 2011 Report Posted July 13, 2011 asta las putea folosi sa imi delimiteze si suma de la /stats adica cash si bank?Da, poti sa-l folosesti oricum, exemplu:FormatNumber( Bank[ playerid ][ Money ] ); //doar un exemplu ! FormatNumber( GetPlayerMoney( playerid ) ); //doar un exemplu ! //iar astea vin cam asa: FormatNumber( 5000000 ); //va veni 5.000.000
ShowBell Posted July 14, 2011 Author Report Posted July 14, 2011 stuntman asta nu imi e bun mie la /stats imi trebuie alta functie...
ShowBell Posted July 16, 2011 Author Report Posted July 16, 2011 scuzati de duble post dar ma poate ajuta cineva?
Question
ShowBell
Vreau sa fac un script sa desparta banii de ex 10000 sa fie sub forma 10.000 in game.
Am facut stock dar nu imi apare, ce am gresit?
9 answers to this question
Recommended Posts