Server side Money Crash
#1

Hello guys, i have a major problem on my server. I am using server side money for my server. I have a stock named TDConvertPrice which converts the price inserting a comma to make it look neater.
For example if i have a x=1000 i do TDConvertPrice(x) and will print on my textdraw $1,000

I would like to point out that if i sum 100k 10 times it works correctly .
I do not know if it is strins or valstr bug or something else
Me and a friend have tried almost everything. Any possible idea?
However whenever i use values >= 1mil it crashes server.
Here is the code:
Код:
stock TDConvertPrice(price)
{
    new pricestring[12];
    new j = valstr(pricestring,price);
    while(j >= 4) { j -= 3; strins(pricestring,"~y~,~w~",j); }
    strins(pricestring,"~g~$~w~",0);
    return pricestring;
}
My setplayermoney function
Код:
SetPlayerMoney(playerid, value)
{
	new query[67], str[67];
	pinfo[playerid][Money] = value;
	format(str, sizeof(str), "Cash:_%s", TDConvertPrice(pinfo[playerid][Money]));
	PlayerTextDrawSetString(playerid, PlayerGUIPTD[4][playerid], str);
	UpdatePlayerTextDraw(playerid, PlayerGUIPTD[4][playerid]);
	mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Money` = %d WHERE `ID`=%d", pinfo[playerid][Money], pinfo[playerid][ID]);
	mysql_pquery(mysql, query, "","");
	return 1;
}
Reply
#2

Here you go:

PHP код:
stock TDConvertPrice(price)
{
    new 
pricestring[50], valstr(pricestringprice);
    while(
0)
    {
        if(
== && pricestring[j] != '\0')
            
strins(pricestring"~y~,~w~", (strlen(pricestring) - j));
        
j--;
    }
    
strins(pricestring"~g~$~w~"0);
    return 
pricestring;

I'd suggest using custom specifiers for this kind of formatting,
refer to this thread for more information: https://sampforum.blast.hk/showthread.php?tid=313488
Reply
#3

[QUOTE=Eoussama;3948841]Here you go:

PHP код:
stock TDConvertPrice(price)
{
    new 
pricestring[50], valstr(pricestringprice);
    while(
0)
    {
        if(
== && pricestring[j] != '\0')
            
strins(pricestring"~y~,~w~", (strlen(pricestring) - j));
        
j--;
    }
    
strins(pricestring"~g~$~w~"0);
    return 
pricestring;

Still crashes..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)