Floatround problem
#1

Hi all.
I have a problem with floatround function.
I'm trying to script a command where when you type /fix (/ripara in the code) it fixes your vehicle substracting 1 $ per damage, but when you try to execute it the price is like -129837297$
pawn Код:
if(InRangeOfIcon(playerid, 11) == 1)
    {
        if(GetPlayerVehicleID(playerid) > 0)
        {
            new vid = GetPlayerVehicleID(playerid);
            if(meccanicionline > 0) return SendErrorMessage(playerid, "Ci sono dei meccanici online.");
            new soldi;
            new Float:danno;
            new str[128];
            GetVehicleHealth(vid, danno);
            new danno1 = floatround(danno1, floatround_tozero);
            soldi = 1000-danno1;
            if(Character[playerid][Cash] >= soldi)
            {
                GivePlayerMoneyEx(playerid, -soldi);
                RepairVehicle(vid);
                Vehicles[vid][Broken] = 0;
                if(IsPlayerVehicle(vid)) MYSQL_Update_Interger(Vehicles[vid][SQLID], "PlayerVehicles", "Broken", 0);
                format(str, sizeof(str), "Hai riparato il tuo veicolo per $%d", soldi);
                SendInfoMessage(playerid, str);
                return 1;
            }
            else
            {
                SendErrorMessage(playerid, ERROR_MONEY);
            }

        }
    }
Thank you in advance for your help
Reply
#2

Shouldn't new danno1 be a float aswel?
Reply
#3

Floatround converts the float to integrer
Reply
#4

Bump
Reply
#5

PHP код:
        if(InRangeOfIcon(playerid11) == 1)
    {
        if(
GetPlayerVehicleID(playerid) > 0)
        {
            new 
vid GetPlayerVehicleID(playerid);
            if(
meccanicionline 0) return SendErrorMessage(playerid"Ci sono dei meccanici online.");
            new 
soldi;
            new 
Float:danno;
            new 
str[128];
            
GetVehicleHealth(viddanno);
            new 
danno1 floatround(danno1floatround_tozero); // is danno1 here intentional? or should it be danno
            
soldi 1000-danno1;
            if(
Character[playerid][Cash] >= soldi)
            {
                
GivePlayerMoneyEx(playerid, -soldi);
                
RepairVehicle(vid);
                
Vehicles[vid][Broken] = 0;
                if(
IsPlayerVehicle(vid)) MYSQL_Update_Interger(Vehicles[vid][SQLID], "PlayerVehicles""Broken"0);
                
format(strsizeof(str), "Hai riparato il tuo veicolo per $%d"soldi);
                
SendInfoMessage(playeridstr);
                return 
1;
            }
            else
            {
                
SendErrorMessage(playeridERROR_MONEY);
            }

        }
    } 
Reply
#6

It should be danno! A little negligence that ruined the entire code, thank you!
Reply
#7

Quote:
Originally Posted by alanhutch
Посмотреть сообщение
It should be danno! A little negligence that ruined the entire code, thank you!
As a side note though, Sometimes a calm thorough check with a calm mind and calm spirit can solve the problem. Glad to help in any way.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)