SA-MP Forums Archive
Multiplying to a Decimal Number - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Multiplying to a Decimal Number (/showthread.php?tid=414960)



Multiplying to a Decimal Number - Neil. - 11.02.2013

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


Respuesta: Multiplying to a Decimal Number - admantis - 11.02.2013

If you need to, make it a float number.

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


Re: Respuesta: Multiplying to a Decimal Number - Neil. - 11.02.2013

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


Re: Multiplying to a Decimal Number - Sasoft - 11.02.2013

I guess you could try this

pawn Код:
new double SellPrice;



Re: Multiplying to a Decimal Number - Neil. - 11.02.2013

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

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


Re: Multiplying to a Decimal Number - vIBIENNYx - 11.02.2013

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


Respuesta: Multiplying to a Decimal Number - kirk - 11.02.2013

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.


Re: Multiplying to a Decimal Number - denNorske - 11.02.2013

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.


Re: Multiplying to a Decimal Number - Neil. - 11.02.2013

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);



Re: Multiplying to a Decimal Number - Sinner - 11.02.2013

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

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