Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local antispam = {}
- function sendVIP(plr, _, name, t)
- if (plr and exports.server:isPlayerLoggedIn(plr)) then
- if (antispam[plr]) then
- exports.NGCdxmsg:createNewDxMessage(plr, "You can only use this once every minute", 255, 0, 0)
- return false
- end
- local plrVIP = exports.server:getPlayerVIPHours(plr) / 60
- if (not plrVIP or plrVIP < 1) then
- exports.NGCdxmsg:createNewDxMessage(plr, "You must have at least 1 VIP hour in order send VIP", 255, 0, 0)
- return false
- end
- local _plr = getPlayerFromPartialName(name) -- There should be an export for this
- if (not _plr) then
- exports.NGCdxmsg:createNewDxMessage(plr, "We couldn't find a player with this name, or there are multiple players with this name", 255, 0, 0)
- end
- if (not exports.server:isPlayerLoggedIn(_plr) or plr.dead or plr == _plr) then
- return false
- end
- local _plrVIP = exports.server:getPlayerVIPHours(plr)/60 or 0
- if (t and tonumber(t)) then
- t = tonumber(t)
- if (plrVIP - t < 0) then
- exports.NGCdxmsg:createNewDxMessage(plr, "You don't have this many VIP hours", 255, 0, 0)
- return
- end
- exports.NGCVIP:givePlayerVIP(plr, (plrVIP - t) * -60) -- Remove this player's VIP we have to use a negative value
- exports.NGCVIP:givePlayerVIP(_plr, (_plrVIP + t) * 60)
- exports.NGCdxmsg:createNewDxMessage(plr, "You have given ".._plr.name.." "..t.." hours of VIP", 0, 255, 0)
- exports.NGCdxmsg:createNewDxMessage(_plr, "You have received "..t.." hours of VIP from "..plr.name, 0, 255, 0)
- antispam[plr] = true
- Timer(function () antispam[plr] = nil end, 60 * 1000, 1, plr)
- else
- exports.NGCdxmsg:createNewDxMessage(plr, "You must enter a number after the player's name", 255, 0, 0)
- end
- end
- end
- addCommandHandler("sendviphours", sendVIP)
Advertisement
Add Comment
Please, Sign In to add comment