High interger crash server!
#1

I make this function:
PHP код:
stock GiveMoney(playeridmoney)
{
    new 
str[128];
    if(
money 0)
    {
        
format(strsizeof(str), "~g~+%s$"AddCommas(money));
        
GameTextForPlayer(playeridstr30001);
    }
    else if(
money 0)
    {
        
format(strsizeof(str), "~r~%s$"AddCommas(money));
        
GameTextForPlayer(playeridstr30001);
    }
    
PInfo[playerid][Cash] += money;
    
ResetPlayerMoney(playerid);
    
GivePlayerMoney(playeridPInfo[playerid][money]);
    return 
0;

I try to use it in my cmd:

PHP код:
CMD:givemoney(playeridparams[])
{
    new 
str[128], playermoney;
    if(
sscanf(params"ud"playermoney)) return SendMessage(playeridCOLOR_LENH"/givemoney [ID] [Money]"SMLENH);
    
GiveMoney(playermoney);
    return 
1;

When i use this cmd with high negative value (ex: -100.000.000), it cause a crash -_- ! Someone help me pls, tks!

P/s: Sr for my bad English
Reply
#2

Server logs? Use crashdetect if you don't have.
Reply
#3

Here:
PHP код:
[01:51:08] [debugAMX backtrace:
[
01:51:08] [debug#0 native format () from samp03svr
[01:51:08] [debug#1 000ea124 in public cmd_givemoney () from OCP.amx
[01:51:08] [debug#2 native CallLocalFunction () from samp03svr
[01:51:08] [debug#3 00000d74 in public OnPlayerCommandText (0x00000000, 0x022c2cf8) from OCP.amx 
Reply
#4

Compile script with debug mode -d3. Then you will get error line.
Reply
#5

How can i complier with debug mode?!?
Reply
#6

Ok, i find it:
PHP код:
[02:12:27] [debugAMX backtrace:
[
02:12:27] [debug#0 native format () from samp03svr
[02:12:27] [debug#1 0011f4e0 in public cmd_givemoney () at OCP.pwn:17082
[02:12:27] [debug#2 native CallLocalFunction () from samp03svr
[02:12:27] [debug#3 00001064 in public OnPlayerCommandText (playerid=0, cmdtext[]=@0x022c2cec "/givemoney 0 -100000000") at E:\Game\Pawn Code\include\zcmd.inc:109 
Reply
#7

Line 17082 is:
PHP код:
stock GiveMoney(playeridmoney

    new 
str[128]; 
    if(
money 0
    { 
        
format(strsizeof(str), "~g~+%s$"AddCommas(money));
        
GameTextForPlayer(playeridstr30001); 
    } 
    else if(
money 0
    { 
        
format(strsizeof(str), "~r~%s$"AddCommas(money));  //HERE 17082
        
GameTextForPlayer(playeridstr30001); 
    } 
    
PInfo[playerid][Cash] += money
    
ResetPlayerMoney(playerid); 
    
GivePlayerMoney(playeridPInfo[playerid][money]); 
    return 
0
}
stock AddCommas(number)
{
    new
        
tStr[13]; // Up to 9,999,999,999,999
 
    
format(tStr,sizeof(tStr),"%d",number);
 
    if(
strlen(tStr) < 4)
     return 
tStr;
 
    new
        
//rNumber = floatround((number+(number/3)),floatround_floor),
        
iPos strlen(tStr),
        
iCount 1;
 
    while(
iPos 0)
    {
        if(
iCount == 4)
        {
            
iCount 0;
            
strins(tStr,",",iPos,1);
            
iPos ++;
        }
        
iCount ++;
        
iPos --;
    }
    return 
tStr;

Reply
#8

Line 17082?

//EDIT

Give one line 17082, not full function.
Reply
#9

Line 17082! It doesn't seem have any problem, so i think you'll need full code
PHP код:
format(strsizeof(str), "~r~%s$"AddCommas(money));  //HERE 17082 
Reply
#10

Try without function AddCommas

Код:
format(str, sizeof(str), "~r~%d$", money);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)