SA-MP Forums Archive
Money calculation doesn't work properly - 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: Money calculation doesn't work properly (/showthread.php?tid=416602)



Money calculation doesn't work properly - Gladium - 17.02.2013

This is the part I use to calculate how much he stole, but it gives me huge ass numbers or numbers like -974372912

pidy=Targets id.
Код:
 	new targetsmoney = GetPlayerMoney(pidy);
 	new int:moneystolen = targetsmoney*0.02;
 	new randomchance[][7] = {1,2,3,4,5,6,7};
 	new rand = random(sizeof(randomchance));
 	if(randomchance[rand][0] == 0 || randomchance[rand][0] == 3 || randomchance[rand][0] ==  7)
 	{
 	SetTimerEx("robwait",30000,false,"i",playerid);
 	return SendClientMessage(playerid, 0xFF0000FF, "Robbery failed.");
 	}
 	
 	if(targetsmoney == 0)
 	{
 	    new string[128];
 	    format(string, sizeof(string), "%s does not have any money.", pName);
 	    SetTimerEx("robwait",30000,false,"i",playerid);
 	    return SendClientMessage(playerid, 0xFF0000FF,string);
 	}
 	

      if(moneystolen > 250000)
 	{
	  GivePlayerMoney(pidy, -250000);
	  GivePlayerMoney(playerid, 250000);
	  new string[128];
          format(string, sizeof(string), "You have stolen 250000$ from  %s.",pName);
          SendClientMessage(playerid, COLOR_GREEN,string);
          format(string, sizeof(string), "%s stole 2500000 from you.",ppName);
          SendClientMessage(pidy, 0xFF0000FF,string);
          SetTimerEx("robwait",30000,false,"i",playerid);
	  return 1;
 	}
 	new string[128];
	GivePlayerMoney(pidy, -moneystolen);
	GivePlayerMoney(playerid, moneystolen);
 	format(string, sizeof(string), "You have stolen %i$ from %s.", moneystolen, pName);
  	SendClientMessage(playerid, COLOR_GREEN,string);
   	format(string, sizeof(string), "%s stole %i$ from you.",ppName,moneystolen);
   	SendClientMessage(pidy, 0xFF0000FF,string);
   	SetTimerEx("robwait",30000,false,"i",playerid);
	return 1;
}



Re: Money calculation doesn't work properly - HB - 17.02.2013

Try this:

pawn Код:
new moneystolen = floatround(targetsmoney*0.02);



Re: Money calculation doesn't work properly - Gladium - 17.02.2013

Quote:
Originally Posted by Neozftw
Посмотреть сообщение
Try this:

pawn Код:
new moneystolen = floatround(targetsmoney*0.02);
Yes, that fixed it. Thank you.