nokizorque

Untitled

Apr 7th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. local antispam = {}
  2.  
  3. function sendVIP(plr, _, name, t)
  4.     if (plr and exports.server:isPlayerLoggedIn(plr)) then
  5.         if (antispam[plr]) then
  6.             exports.NGCdxmsg:createNewDxMessage(plr, "You can only use this once every minute", 255, 0, 0)
  7.             return false
  8.         end
  9.         local plrVIP = exports.server:getPlayerVIPHours(plr) / 60
  10.         if (not plrVIP or plrVIP < 1) then
  11.             exports.NGCdxmsg:createNewDxMessage(plr, "You must have at least 1 VIP hour in order send VIP", 255, 0, 0)
  12.             return false
  13.         end
  14.         local _plr = getPlayerFromPartialName(name) -- There should be an export for this  
  15.         if (not _plr) then
  16.             exports.NGCdxmsg:createNewDxMessage(plr, "We couldn't find a player with this name, or there are multiple players with this name", 255, 0, 0)
  17.         end
  18.         if (not exports.server:isPlayerLoggedIn(_plr) or plr.dead or plr == _plr) then
  19.             return false
  20.         end
  21.         local _plrVIP = exports.server:getPlayerVIPHours(plr)/60 or 0
  22.         if (t and tonumber(t)) then
  23.             t = tonumber(t)
  24.             if (plrVIP - t < 0) then
  25.                 exports.NGCdxmsg:createNewDxMessage(plr, "You don't have this many VIP hours", 255, 0, 0)
  26.                 return
  27.             end
  28.             exports.NGCVIP:givePlayerVIP(plr, (plrVIP - t) * -60) -- Remove this player's VIP we have to use a negative value
  29.             exports.NGCVIP:givePlayerVIP(_plr, (_plrVIP + t) * 60)
  30.          
  31.             exports.NGCdxmsg:createNewDxMessage(plr, "You have given ".._plr.name.." "..t.." hours of VIP", 0, 255, 0)
  32.             exports.NGCdxmsg:createNewDxMessage(_plr, "You have received "..t.." hours of VIP from "..plr.name, 0, 255, 0)
  33.            
  34.             antispam[plr] = true
  35.             Timer(function () antispam[plr] = nil end, 60 * 1000, 1, plr)
  36.         else
  37.             exports.NGCdxmsg:createNewDxMessage(plr, "You must enter a number after the player's name", 255, 0, 0)
  38.         end
  39.     end
  40. end
  41. addCommandHandler("sendviphours", sendVIP)
Advertisement
Add Comment
Please, Sign In to add comment