14.03.2015, 03:13
I know this is a relaly dumb question, but how would I take a percentage off of a %d? Such as 20% off in the script? 10%?
Thanks, REP+
Thanks, REP+
Float example:
format(string, sizeof(string), "Answer: %0.2f%s!", gServerTestFloat, "%%"); Bold text = percentage symbol in-game ("%"). Remove %s from the format if you're going to remove the bold text. Is that what you mean? |
Player[playerid][Money] -= Houses[h][HousePrice] // Take 20 percent here;
Unfortunately not. I mean take 20% from HousePrice in something like this:
pawn Код:
|
1: discount <- 0.01;
2: discount <- 0.02;
3: discount <- 0.03;
4: discount <- 0.04;
5: discount <- 0.05;
6: discount <- 0.06;
7: discount <- 0.07;
8: discount <- 0.08;
9: discount <- 0.09;
10: discount <- 0.10;
11: discount <- 0.11;
12: discount <- 0.12;
13: discount <- 0.13;
14: discount <- 0.14;
15: discount <- 0.15;
16: discount <- 0.16;
17: discount <- 0.17;
18: discount <- 0.18;
19: discount <- 0.19;
20: discount <- 0.20;
21: discount <- 0.21;
22: discount <- 0.22;
23: discount <- 0.23;
24: discount <- 0.24;
25: discount <- 0.25;
26: discount <- 0.26;
27: discount <- 0.27;
28: discount <- 0.28;
29: discount <- 0.29;
30: discount <- 0.30;
31: discount <- 0.31;
32: discount <- 0.32;
33: discount <- 0.33;
34: discount <- 0.34;
35: discount <- 0.35;
36: discount <- 0.36;
37: discount <- 0.37;
38: discount <- 0.38;
39: discount <- 0.39;
40: discount <- 0.40;
41: discount <- 0.41;
42: discount <- 0.42;
43: discount <- 0.43;
44: discount <- 0.44;
45: discount <- 0.45;
46: discount <- 0.46;
47: discount <- 0.47;
48: discount <- 0.48;
49: discount <- 0.49;
50: discount <- 0.50;
51: discount <- 0.51;
52: discount <- 0.52;
53: discount <- 0.53;
54: discount <- 0.54;
55: discount <- 0.55;
56: discount <- 0.56;
57: discount <- 0.57;
58: discount <- 0.58;
59: discount <- 0.59;
60: discount <- 0.60;
61: discount <- 0.61;
62: discount <- 0.62;
63: discount <- 0.63;
64: discount <- 0.64;
65: discount <- 0.65;
66: discount <- 0.66;
67: discount <- 0.67;
68: discount <- 0.68;
69: discount <- 0.69;
70: discount <- 0.70;
71: discount <- 0.71;
72: discount <- 0.72;
73: discount <- 0.73;
74: discount <- 0.74;
75: discount <- 0.75;
76: discount <- 0.76;
77: discount <- 0.77;
78: discount <- 0.78;
79: discount <- 0.79;
80: discount <- 0.80;
81: discount <- 0.81;
82: discount <- 0.82;
83: discount <- 0.83;
84: discount <- 0.84;
85: discount <- 0.85;
86: discount <- 0.86;
87: discount <- 0.87;
88: discount <- 0.88;
89: discount <- 0.89;
90: discount <- 0.90;
91: discount <- 0.91;
92: discount <- 0.92;
93: discount <- 0.93;
94: discount <- 0.94;
95: discount <- 0.95;
96: discount <- 0.96;
97: discount <- 0.97;
98: discount <- 0.98;
99: discount <- 0.99;
100: discount <- 1;
discount = (cost * discount);
price = cost - discount;
price = cost - (discount / 100 * cost);
Oh, why didn't you just say so?
There's different ways to calculate a discount, I'll show you two of them: 1) pawn Код:
pawn Код:
Anyway, Good luck, mate! |
discount = Houses[h][HousePrice] / discountpercent;
new discount = floatmul(floatdiv(10, 100), Houses[h][HousePrice]); finalprice = Houses[h][HousePrice] - discount ;
Player[playerid][Money] -= Houses[h][HousePrice] - (10 / 100 * Houses[h][HousePrice]);
Player[playerid][Money] -= Houses[h][HousePrice] - (0.10 * Houses[h][HousePrice]);