石器里用LUA来写增加货币的GM命令非常方便,虽说老的GM命令里也有,但用LUA来写却可以增加各种货币,就不需要在服务端源码里添加了。
代码如下:
function addpoint(charaindex, data) --货币类型,对应pointname里的货币名称 local type = other.getString(data, " ", 1) --增加的货币数额 local value = other.atoi(other.getString(data, " ", 2)) --增加货币的账号 local cdkey = other.getString(data, " ", 3) --当不填写账号的时候是给自己增加 if cdkey == "" then if type == pointname[1] then char.setInt(charaindex, pointname[1], char.getInt(charaindex, pointname[1]) + value) char.Updata(charaindex, pointname[1]) char.TalkToCli(charaindex, -1, "成功添加"..pointname[1]..":["..value.."],当前拥有"..pointname[1]..":["..char.getInt(charaindex, pointname[1]).."]", "黄色") elseif type == pointname[2] then char.setInt(charaindex, pointname[2], char.getInt(charaindex, pointname[2]) + value) char.TalkToCli(charaindex, -1, "成功添加"..pointname[2]..":["..value.."],当前拥有"..pointname[2]..":["..char.getInt(charaindex, pointname[2]).."]", "黄色") elseif type == pointname[3] then char.setInt(charaindex, pointname[3], char.getInt(charaindex, pointname[3]) + value) char.TalkToCli(charaindex, -1, "成功添加"..pointname[3]..":["..value.."],当前拥有"..pointname[3]..":["..char.getInt(charaindex, pointname[3]).."]", "黄色") elseif type == pointname[4] then sasql.setVipPoint(charaindex, sasql.getVipPoint(charaindex) + value) char.TalkToCli(charaindex, -1, "成功添加"..pointname[4]..":["..value.."],当前拥有"..pointname[4]..":["..sasql.getVipPoint(charaindex).."]", "黄色") elseif type == pointname[5] then sasql.setPayPoint(charaindex, sasql.getPayPoint(charaindex) + value) char.TalkToCli(charaindex, -1, "成功添加"..pointname[5]..":["..value.."],当前拥有"..pointname[5]..":["..sasql.getPayPoint(charaindex).."]", "黄色") end else --如果填写了账号则搜索在线玩家 for i=0, char.getPlayerMaxNum() - 1 do if char.check(i) == 1 then --在线玩家有匹配所输入的账号时 if char.getChar(i, "账号") == cdkey then if type == pointname[1] then char.setInt(i, pointname[1], char.getInt(i, pointname[1]) + value) char.Updata(i, pointname[1]) char.TalkToCli(charaindex, -1, "成功给["..char.getChar(i, "名字").."]添加"..pointname[1]..":["..value.."],当前该账号拥有"..pointname[1]..":["..char.getInt(i, pointname[1]).."]", "黄色") char.TalkToCli(i, -1, "GM[" .. char.getChar(charaindex, "名字") .. "]给你添加"..pointname[1]..":["..value.."],当前拥有"..pointname[1]..":["..char.getInt(i, pointname[1]).."]", "青色") elseif type == pointname[2] then char.setInt(i, pointname[2], char.getInt(i, pointname[2]) + value) char.TalkToCli(charaindex, -1, "成功给["..char.getChar(i, "名字").."]添加"..pointname[2]..":["..value.."],当前该账号拥有"..pointname[2]..":["..char.getInt(i, pointname[2]).."]", "黄色") char.TalkToCli(i, -1, "GM[" .. char.getChar(charaindex, "名字") .. "]给你添加"..pointname[2]..":["..value.."],当前拥有"..pointname[2]..":["..char.getInt(i, pointname[2]).."]", "青色") elseif type == pointname[3] then char.setInt(i, pointname[3], char.getInt(i, pointname[3]) + value) char.TalkToCli(charaindex, -1, "成功给["..char.getChar(i, "名字").."]添加"..pointname[3]..":["..value.."],当前该账号拥有"..pointname[3]..":["..char.getInt(i, pointname[3]).."]", "黄色") char.TalkToCli(i, -1, "GM[" .. char.getChar(charaindex, "名字") .. "]给你添加"..pointname[3]..":["..value.."],当前拥有"..pointname[3]..":["..char.getInt(i, pointname[3]).."]", "青色") elseif type == pointname[4] then sasql.setVipPoint(i, sasql.getVipPoint(i) + value) char.TalkToCli(charaindex, -1, "成功给["..char.getChar(i, "名字").."]添加"..pointname[4]..":["..value.."],当前该账号拥有"..pointname[4]..":["..sasql.getVipPoint(i).."]", "黄色") char.TalkToCli(i, -1, "GM[" .. char.getChar(charaindex, "名字") .. "]给你添加"..pointname[4]..":["..value.."],当前拥有"..pointname[4]..":["..sasql.getVipPoint(i).."]", "青色") elseif type == pointname[5] then sasql.setPayPoint(i, sasql.getPayPoint(i) + value) char.TalkToCli(charaindex, -1, "成功给["..char.getChar(i, "名字").."]添加"..pointname[5]..":["..value.."],当前该账号拥有"..pointname[5]..":["..sasql.getPayPoint(i).."]", "黄色") char.TalkToCli(i, -1, "GM[" .. char.getChar(charaindex, "名字") .. "]给你添加"..pointname[5]..":["..value.."],当前拥有"..pointname[5]..":["..sasql.getPayPoint(i).."]", "青色") end return end end end char.TalkToCli(charaindex, -1, "抱歉,无法找到该玩家", "黄色") end end function data() --货币名称,其中会员点和充值积分为SQL货币 pointname = {"石币", "声望", "活力", "会员点", "充值积分"} end function main() data() magic.addLUAListFunction("货币", "addpoint", "", 3, "[gm 货币 类型 数额 账号]") end
用法:[gm 货币 石币/声望/活力/会员点/充值积分 数额 账号]
如果需要增加新的货币,按照顺序对应的增加即可。
发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。