DakiLLa Posted June 8, 2008 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]
Clooak Posted June 8, 2008 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)
Simbad de Zeeman Posted June 9, 2008 Posted June 9, 2008 viewtopic.php?f=91&t=21257&p=268125&hilit=snippet+givecash#p268125
DakiLLa Posted June 9, 2008 Author 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 ?
DakiLLa Posted June 10, 2008 Author 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 ?
robhol Posted June 10, 2008 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.
50p Posted June 10, 2008 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.
DakiLLa Posted June 10, 2008 Author Posted June 10, 2008 huh..nice..but i need to save progress in gamemode . Any ways to solve this problem?
eAi Posted June 12, 2008 Posted June 12, 2008 setAccountData is fixed in DP3. Not that that helps you now...
Max3D Posted July 20, 2008 Posted July 20, 2008 setAccountData is fixed in DP3. Not that that helps you now... haha owned ^^
robhol Posted July 21, 2008 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..
icedsun Posted July 21, 2008 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.
Deddalt Posted August 1, 2008 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.
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