Multiplying to a Decimal Number
#1

pawn Код:
new SellPrice;
SellPrice = AHouseData[HouseID][HousePrice] * 0.1;
It's giving me tag mismatch errors. But when I do subtraction or addition it doesn't return that error?
Help
Reply
#2

If you need to, make it a float number.

new Float:SellPrice;
SellPrice = AHouseData[HouseID][HousePrice] * 0.1;
GivePlayerMoney(playerid, (floatround(SellPrice)));
Reply
#3

Quote:
Originally Posted by admantis
Посмотреть сообщение
If you need to, make it a float number.

new Float:SellPrice;
SellPrice = AHouseData[HouseID][HousePrice] * 0.1;
GivePlayerMoney(playerid, (floatround(SellPrice)));
Is the float conversion necessary? Tried that still, compiles with a tag mismatch error
Reply
#4

I guess you could try this

pawn Код:
new double SellPrice;
Reply
#5

Quote:
Originally Posted by Sasoft
Посмотреть сообщение
I guess you could try this

pawn Код:
new double SellPrice;
That wouldn't work at all
Reply
#6

Create a new float variable and assign the value as 0.1, then keep SellPrice as a float and do the equation that way.
Reply
#7

Quote:
Originally Posted by admantis
Посмотреть сообщение
If you need to, make it a float number.

new Float:SellPrice;
SellPrice = AHouseData[HouseID][HousePrice] * 0.1;
GivePlayerMoney(playerid, (floatround(SellPrice)));
Do it this way and make sure, AHouseData[HouseID][HousePrice] its a float.
Reply
#8

As mentioned above, you could try to use a variable/define which is set to 0.1, and then attempt to try again.

like:

pawn Код:
#define value 0.1
and keep the number as a Float - ; And it should work.
Reply
#9

Quote:
Originally Posted by vIBIENNYx
Посмотреть сообщение
Create a new float variable and assign the value as 0.1, then keep SellPrice as a float and do the equation that way.
A bit of noobish here, but would I do it like this?
pawn Код:
new Float:multi;
    multi = 0.1;
    new Float:SellPrice = AHouseData[HouseID][HousePrice] * multi;
    return floatround(SellPrice);
Reply
#10

It returns a tag mismatch because HousePrice isn't a float either.

pawn Код:
new Float:SellPrice;
SellPrice = float(AHouseData[HouseID][HousePrice]) * 0.1;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)