DakiLLa Posted June 8, 2008 Share Posted June 8, 2008 Hi! I need script of giving money to players, but in Lua i'm full noob . Can you write this script for me please? Something of this: /givemoney [Player name] [the sum] Link to comment
Clooak Posted June 8, 2008 Share Posted June 8, 2008 Sure! there u go If you take a look at the wiki of mtasa You will learn alot http://development.mtasa.com/index.php? ... layerMoney Here is how u wanted it(try to learn something from it) function GiveCash ( thePlayer, command, targetmoney, amount ) local nick = getPlayerFromNick(targetmoney) givePlayerMoney ( nick, amount ) end addCommandHandler("givemoney",GiveCash) Link to comment
DakiLLa Posted June 9, 2008 Author Share Posted June 9, 2008 wow! Great! Thanks for help!! Link to comment
Simbad de Zeeman Posted June 9, 2008 Share Posted June 9, 2008 viewtopic.php?f=91&t=21257&p=268125&hilit=snippet+givecash#p268125 Link to comment
DakiLLa Posted June 9, 2008 Author Share Posted June 9, 2008 i dont want to create a new topic and i ask here: how can i save my money when i log-out and return money when i log-in ? can you help me with script ? Link to comment
DakiLLa Posted June 10, 2008 Author Share Posted June 10, 2008 in example what is "piraterpg.money" in setaccountdata and getaccountdata ? it's current file in which saves information of players or not ? Link to comment
robhol Posted June 10, 2008 Share Posted June 10, 2008 in example what is "piraterpg.money" in setaccountdata and getaccountdata ? it's current file in which saves information of players or not ? ExampleFor a pirate roleplaying gametype, the amount of money a player has is made persistent by storing it in his account. Note the code uses "piraterpg.money" as key instead of just "money", as the player may be participating in other gametypes that also save his money amount to his account. If both gametypes would use "money" as the account key, they'd overwrite each other's data. Link to comment
capitanazop Posted June 10, 2008 Share Posted June 10, 2008 save but dont load the money Link to comment
50p Posted June 10, 2008 Share Posted June 10, 2008 Function setAccountData doesn't work as it should. Some people say it does work but I've never managed to make it work (even the way they said). setAccountData removes all the accounts from accounts.xml file when server stops. Link to comment
DakiLLa Posted June 10, 2008 Author Share Posted June 10, 2008 huh..nice..but i need to save progress in gamemode . Any ways to solve this problem? Link to comment
eAi Posted June 12, 2008 Share Posted June 12, 2008 setAccountData is fixed in DP3. Not that that helps you now... Link to comment
Max3D Posted July 20, 2008 Share Posted July 20, 2008 setAccountData is fixed in DP3. Not that that helps you now... haha owned ^^ Link to comment
robhol Posted July 21, 2008 Share Posted July 21, 2008 setAccountData is fixed in DP3. Not that that helps you now... haha owned ^^ haha spam ^^ But to stick on topic, i kinda wonder how this bug wasn't discovered during testing.. Link to comment
icedsun Posted July 21, 2008 Share Posted July 21, 2008 Just in case you didn't already notice - the script provided above will make that command available on the server - and unless you restrict it in the ACL, it'll be available to all players. So anybody could give themselves money, thus defeating the purpose of having money on most servers. We could all be chairmen of the Federal Reserve. Link to comment
Deddalt Posted August 1, 2008 Share Posted August 1, 2008 function onJoin(thePlayer) local account = getClientAccount(thePlayer) local money = getAccountData(account, "players/Player.money") setPlayerMoney(thePlayer, money) end function giveCash(thePlayer, commandName, amount) local account = getClientAccount(source) local admin = getAccountData(account, "players/Player.admin") if(admin >= 1) local name1 = getClientName(source) local name2 = getClientName(thePlayer) givePlayerMoney(thePlayer, amount) outputChatBox("Admin "..name1.." has given you $"..amount, thePlayer,0,255,255) outputChatBox("You have given "..name2.." $"..amount, thePlayer,0,255,255) end addCommandHandler("givecash", giveCash) Of course you still need to use setAccountData when the player joins. So, that script doesn't entirely work yet. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now