{RPC function for add money to user storage}
Hi ,i want to make Lua RPC function to add some value to user money that stored in storage table
I should get some value, for example 10 from client and send to RPC addSomeMoney function.
Then that function should get money from storage table and plus by 10.
Then send back (old value+10) to client to show the user .
Is this secure ? is there any better way to do these ?
Can you help me to complete the lua addSomeMoney function? please (in lua language)
I really appreciate any help , thank you all
and a very, very big thanks to whose make nakama, thank you all
You are all amazing!
- Versions: Nakama {3.13.1}, {Windows, Linux binary}, {client library (SDK) and version}
- Server Framework Runtime language {Lua}
local function addSomeMoney(context, payload)
--[[get value from client to payload json input ?]]
local user_id = context.user_id
local quary=nk.sql_query( "SELECT username FROM users WHERE id = $1", {user_id} )
--[[
.
.
.
]]
return nk.json_encode({ totalMoney = --[[.....]] })
end
nk.register_rpc(addSomeMoney, "add_Some_Money")
Media: