• Make givemoney command work with steamid instead of nick
    6 replies, posted
Im looking to make a donation system for my server where you can buy ingame cash, i found some moneygive commands buy they only work with ingame nicknames not with steamid. Could anyone help me out making it use steamid instead? [/code]function ulx.givemoney( calling_ply, target_ply, money ) target_ply:addMoney(money) ulx.fancyLogAdmin( calling_ply, "#A gave $#i to #T", money, target_ply) -- Change "$" to whatever currency you want to use. end local givemoney = ulx.command( CATEGORY_NAME, "ulx givemoney", ulx.givemoney, "!givemoney" ) givemoney:defaultAccess( ULib.ACCESS_SUPERADMIN ) givemoney:addParam{ type=ULib.cmds.PlayerArg } givemoney:addParam{ type=ULib.cmds.NumArg, min=0, default=1000, hint="give how much?", ULib.cmds.optional, ULib.cmds.round } givemoney:help( "Give players the chosen amount of cash" )[/code]
Im looking to make a donation system Are you using Prometheus? (it comes with inbuilt stuff). If you are fully making you're own, just create a server sided function: function GiveSteamIDMoney( steamid, amount ) for k, v in pairs( player.GetAll() ) do if tostring( v:SteamID() ) == tostring( steamid ) then v:addMoney( amount ) end end end
Im using something called Tebex that is free, however the functionallity it provides to garrys mod isnt more than executing console commands and it works fine for VIP so far. Could I use this code for that? I have no prior experiencce with any of this so its kinda confusing.
What mode of Tebex are you using? Gameserver, MySQL or RCON?
Im using the Gameserver mode.
Not too sure how Tebex works but I assume you can add a event for when a certain thing is brought. You would need the code above in a file on the server somewhere and make sure it autoruns. Then for the command to run when your package is brought, I believe you should be able to do <lua_run GiveSteamIDMoney(steamid, amount)> obviously using the Tebex variables for steamid and money to ensure the correct player and amount is given.
Your code is good but it can be improved: function GiveMoneyToId(SteamID,Amount) local ply = player.GetBySteamID( SteamID )      if ply:IsValid() and ply:IsPlayer() then    ply:addMoney( Amount )    end end
Sorry, you need to Log In to post a reply to this thread.