adrianoswatt

TransferPremiumPoints

Oct 26th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.83 KB | None | 0 0
  1. function onSay(cid, words, param, channel)
  2.     local t = string.explode(param, ",")
  3.     if(param == '') then
  4.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Exemplo de como usar o comando:\nTransferir 50 points para o player 'Amigo'\n!transferpoints, Amigo, 50")
  5.         return true
  6.     end
  7.     local playerReceb = getPlayerByNameWildcard(tostring(t[1]))
  8.     if(not isPlayer(playerReceb)) then
  9.         doPlayerSendCancel(cid, "Esse jogador nao existe ou nao esta online.")
  10.         return true
  11.     end
  12.     if not t[2] or not isNumber(t[2]) then
  13.         doPlayerSendCancel(cid, "Exemplo de como usar o comando: !transferpoints, Amigo, 50")
  14.     return true
  15.     end
  16.     local points = tonumber(t[2])
  17.     local getMyAcc = getPlayerAccountId(cid)
  18.     local ownGet = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = '".. getMyAcc.."';")
  19.         local ownPoints = tonumber(ownGet:getDataString('premium_points')) 
  20.     local getTargetAcc = getPlayerAccountId(playerReceb)
  21.     local targGet = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = '".. getTargetAcc.."';")
  22.         local targPoints = tonumber(targGet:getDataString('premium_points'))
  23.     if ownPoints <= points then
  24.         doPlayerSendCancel(cid, "Voce não tem points suficientes")
  25.     return true
  26.     end
  27.     db.executeQuery("UPDATE `accounts` SET `premium_points` = ".. (ownPoints-points) .." WHERE `id` = " .. getMyAcc .. ";")
  28.     db.executeQuery("UPDATE `accounts` SET `premium_points` = ".. (targPoints+points) .." WHERE `id` = " .. getTargetAcc .. ";")
  29.     doPlayerSendTextMessage(playerReceb, MESSAGE_STATUS_CONSOLE_BLUE, "".. getPlayerName(cid) .." te deu ".. points .." Premium Points que podem ser utilizados para comprar itens em nosso site!")
  30.     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "".. t[1] .." recebeu seus ".. points .." Premium Points com sucesso!")
  31. return true
  32. end
Add Comment
Please, Sign In to add comment