Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if !defined _samp_included
- #include <a_samp>
- #endif
- #if defined _roundfloat_included
- #endinput
- #endif
- #define _roundfloat_included
- stock RoundFloat(Float:input)
- {
- new tmpstr[50],
- split[2][25],
- tmp[3]
- ;
- format(tmpstr, 50, "%.02f", input);
- for(new i = 0, l = strlen(tmpstr); i < l; i++)
- {
- if(tmpstr[i] == '.')
- {
- strins(split[0], tmpstr, 0, i-1);
- strins(split[1], tmpstr[i+1], 0);
- }
- }
- tmp[0] = strval(split[0]);
- tmp[1] = strval(split[1]);
- if(tmp[1] >= 0 && tmp[1] < 10){
- if(tmp[1] >= 0 && tmp[1] < 5) tmp[1] = 0;
- if(tmp[1] >= 5) tmp[1] = 10;
- }
- else if(tmp[1] >= 10 && tmp[1] < 20){
- if(tmp[1] >= 10 && tmp[1] < 15) tmp[1] = 10;
- if(tmp[1] >= 15) tmp[1] = 20;
- }
- else if(tmp[1] >= 20 && tmp[1] < 30){
- if(tmp[1] >= 20 && tmp[1] < 25) tmp[1] = 20;
- if(tmp[1] >= 25) tmp[1] = 30;
- }
- else if(tmp[1] >= 30 && tmp[1] < 40){
- if(tmp[1] >= 30 && tmp[1] < 35) tmp[1] = 30;
- if(tmp[1] >= 35) tmp[1] = 40;
- }
- else if(tmp[1] >= 40 && tmp[1] < 50){
- if(tmp[1] >= 40 && tmp[1] < 45) tmp[1] = 40;
- if(tmp[1] >= 45) tmp[1] = 50;
- }
- else if(tmp[1] >= 50 && tmp[1] < 60){
- if(tmp[1] >= 50 && tmp[1] < 55) tmp[1] = 50;
- if(tmp[1] >= 55) tmp[1] = 60;
- }
- else if(tmp[1] >= 60 && tmp[1] < 70){
- if(tmp[1] >= 60 && tmp[1] < 65) tmp[1] = 60;
- if(tmp[1] >= 65) tmp[1] = 70;
- }
- else if(tmp[1] >= 70 && tmp[1] < 80){
- if(tmp[1] >= 80 && tmp[1] < 85) tmp[1] = 80;
- if(tmp[1] >= 85) tmp[1] = 90;
- }
- else if(tmp[1] >= 80 && tmp[1] < 90){
- if(tmp[1] >= 80 && tmp[1] < 95) tmp[1] = 80;
- if(tmp[1] >= 95) tmp[1] = 90;
- }
- else if(tmp[1] >= 90 && tmp[1] < 100){
- if(tmp[1] >= 90 && tmp[1] < 95) tmp[1] = 90;
- if(tmp[1] >= 95){
- tmp[1] = 0;
- tmp[0] = tmp[0] + 1;
- }
- }
- else if(tmp[1] >= 100){
- tmp[1] = 0;
- tmp[0] = tmp[0] + 1;
- }
- format(tmpstr, 50, "%d.%d", tmp[0], tmp[1]);
- return tmpstr;
- }
Add Comment
Please, Sign In to add comment