Money Textdraw - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Money Textdraw (
/showthread.php?tid=80785)
Money Textdraw -
Doktor - 06.06.2009
To make money cheats useless i thought to use a textdraw (over the originals Moneybar) which shows the money the player has at the moment. The Textdraw is just a text (align right, color: green, as high/width as the original one, no background).
You all know that the original moneybar changes the color from green to red if you have debt (- $). My textdraw should change the color too, so i did this:
Код:
stock GiveUserMoney(playerid, amount)
{
new
string[15];
GivePlayerMoney(playerid, amount);
pScriptMoney[playerid] += amount;
if(pScriptMoney[playerid] < 0)
{
TextDrawColor(MoneyText[playerid], 0x9C1619FF);
format(string, sizeof(string), "%d", -1*pScriptMoney[playerid]);
}
else
{
TextDrawColor(MoneyText[playerid], 0x2E5725FF);
format(string, sizeof(string), "%d", pScriptMoney[playerid]);
}
TextDrawSetString(MoneyText[playerid], string);
}
It works and it changes the color, but im not sure if this is the best method to do it, because every time a player gets/loses money the color changes and a string is set. I think its to complex for the server, exspecially if many players are online. So i asked you if there is any other way to do it?
Re: Money Textdraw -
Weirdosport - 06.06.2009
It shouldn't be a problem if it's only called when the stock is used. If it was in a timer/loop it might be another matter, but I don't think it will cause any harm.
Re: Money Textdraw -
Doktor - 06.06.2009
Ok thanks for your answear. As you alreay said, its only used when the stock is called and the stock gets called where normally you use GivePlayerMoney. So everytime a player uses a special command like /pay, /deposit, /withdraw its called. Theres no need to use it in loops, but it could get called if a player uses the sprunk machine (ill just check if the player loses 1$) and then remove some health and give the Player 1$.
Код:
stock GetUserMoney(playerid)
{
return pScriptMoney[playerid];
}
But i dont think this happens so often. If the others has the same opinion, i think theres no need to change my code