Skip to content

Commit 064e3e6

Browse files
authored
Add a max value parameter when creating the circle
1 parent b7887c1 commit 064e3e6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

circleProgress.inc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static enum CIRCLE_ENUM {
3737
Float:E_CIRCLEDRAW_SIZE,
3838
Float:E_CIRCLEDRAW_VALUE,
3939
Float:E_CIRCLEDRAW_POLYGONS,
40+
Float:E_CIRCLEDRAW_MAX_VALUE,
4041
4142
// Colors
4243
E_CIRCLEDRAW_COLOR,
@@ -118,7 +119,7 @@ stock DestroyPlayerCircleProgress(playerid, id) {
118119
return true;
119120
}
120121
121-
stock CreatePlayerCircleProgress(playerid, Float:pos_x, Float:pos_y, color = 0xFF0000FF, background_COLOR = 0x000000FF, Float:size = 10.0, Float:thickness = 0.2, Float:polygons = DEFAULT_CIRCLE_POLYGONS) {
122+
stock CreatePlayerCircleProgress(playerid, Float:pos_x, Float:pos_y, max_value = 100, color = 0xFF0000FF, background_COLOR = 0x000000FF, Float:size = 10.0, Float:thickness = 0.2, Float:polygons = DEFAULT_CIRCLE_POLYGONS) {
122123
123124
new index = Iter_Free(Circles[playerid]);
124125
if(index == -1) return -1;
@@ -132,6 +133,7 @@ stock CreatePlayerCircleProgress(playerid, Float:pos_x, Float:pos_y, color = 0xF
132133
e_CircleDraw[playerid][index][E_CIRCLEDRAW_POSITION][1] = pos_y;
133134
e_CircleDraw[playerid][index][E_CIRCLEDRAW_VALUE] = -1.0; // Prevent Bugs
134135
e_CircleDraw[playerid][index][E_CIRCLEDRAW_POLYGONS] = polygons;
136+
e_CircleDraw[playerid][index][E_CIRCLEDRAW_MAX_VALUE] = max_value;
135137
136138
Iter_Add(Circles[playerid], index);
137139
UpdatePlayerCircleProgress(playerid, index, 100);
@@ -147,6 +149,7 @@ stock UpdatePlayerCircleProgress(playerid, id, value) {
147149
Float:preValue = e_CircleDraw[playerid][id][E_CIRCLEDRAW_POLYGONS],
148150
Float:x,
149151
Float:y,
152+
maxvalue = e_CircleDraw[playerid][index][E_CIRCLEDRAW_MAX_VALUE],
150153
preDraws,
151154
percent,
152155
index;
@@ -156,10 +159,10 @@ stock UpdatePlayerCircleProgress(playerid, id, value) {
156159
157160
/* Prevent and Fix Values */
158161
value = value < 0 ? 0 : value;
159-
value = value > 100 ? 100 : value;
162+
value = value > maxvalue ? maxvalue : value;
160163
161164
/* Color Fade? */
162-
percent = (preDraws * value) / 100;
165+
percent = (preDraws * value) / maxvalue;
163166
164167
/* Update and Create Points */
165168
for(new Float:v = 0.0; v < 360.0; v += preValue) {

0 commit comments

Comments
 (0)