15.06.2014, 23:03
I am creating a fuel system for my vehicles and I have a 3d textdraw on the vehicle that acts like a progress bar.
When the player gets into the vehicle the comde sniplet is called.
When the code sniplet is called it gets the correct fuel and max fuel ammount, but when i try to find the percentage(fuel/ maxfuel) it always reterns a 0.
please help me
When the player gets into the vehicle the comde sniplet is called.
Код:
public UpdateCarFuel(playerid) { new vehicleid = GetPlayerVehicleID(playerid); for(new idx=1; idx<MAX_CAR; idx++) { if(vehicleid == CarInfo[idx][cVID] && IsPlayerInVehicle(playerid, CarInfo[idx][cVID])) { new FuelPercent0 = CarInfo[idx][Fuel]/CarInfo[idx][MaxFuel]; new FuelPercent = FuelPercent0 * 100; new string1[32]; format(string1, sizeof(string1), "Fuel: %d || Max Fuel %d", CarInfo[idx][Fuel], CarInfo[idx][MaxFuel]); SendClientMessage(playerid,COLOR_ORANGE,string1); new string[32]; format(string, sizeof(string), "Percentage Full: %d", FuelPercent0); SendClientMessage(playerid,COLOR_BLUE,string); if(FuelPercent > -1 && FuelPercent < 11) // CarInfo[idx][Fuel]: 0 - 10 { Update3DTextLabelText(CarInfo[idx][Text3D:cTextfuel], COLOR_GREEN, "I{FF0000}IIIIIIIII"); } else if(FuelPercent > 10 && FuelPercent < 21) // CarInfo[idx][Fuel]: 11 - 20 { Update3DTextLabelText(CarInfo[idx][Text3D:cTextfuel], COLOR_GREEN, "II{FF0000}IIIIIIII"); } else if(FuelPercent > 20 && FuelPercent < 31) // CarInfo[idx][Fuel]: 21 - 30 { Update3DTextLabelText(CarInfo[idx][Text3D:cTextfuel], COLOR_GREEN, "III{FF0000}IIIIIII"); } else if(FuelPercent > 30 && FuelPercent < 41) // CarInfo[idx][Fuel]: 31 - 40 { Update3DTextLabelText(CarInfo[idx][Text3D:cTextfuel], COLOR_GREEN, "IIII{FF0000}IIIIII"); } else if(FuelPercent > 40 && FuelPercent < 51) // CarInfo[idx][Fuel]: 41 - 50 { Update3DTextLabelText(CarInfo[idx][Text3D:cTextfuel], COLOR_GREEN, "IIIII{FF0000}IIIII"); } else if(FuelPercent > 50 && FuelPercent < 61) // CarInfo[idx][Fuel]: 51 - 60 { Update3DTextLabelText(CarInfo[idx][Text3D:cTextfuel], COLOR_GREEN, "IIIIII{FF0000}IIII"); } else if(FuelPercent > 60 && FuelPercent < 71) // CarInfo[idx][Fuel]: 61 - 70 { Update3DTextLabelText(CarInfo[idx][Text3D:cTextfuel], COLOR_GREEN, "IIIIIII{FF0000}III"); } else if(FuelPercent > 70 && FuelPercent < 81) // CarInfo[idx][Fuel]: 71 - 80 { Update3DTextLabelText(CarInfo[idx][Text3D:cTextfuel], COLOR_GREEN, "IIIIIIII{FF0000}II"); } else if(FuelPercent > 80 && FuelPercent < 91) // CarInfo[idx][Fuel]: 81 - 90 { Update3DTextLabelText(CarInfo[idx][Text3D:cTextfuel], COLOR_GREEN, "IIIIIIIII{FF0000}I"); } else if(FuelPercent > 90 && FuelPercent < 101) // CarInfo[idx][Fuel]: 91 - 100 { Update3DTextLabelText(CarInfo[idx][Text3D:cTextfuel], COLOR_GREEN, "IIIIIIIIII"); } } } return 1; }
please help me