/rebel-promocodes

Primary LanguageLuaGNU General Public License v3.0GPL-3.0

rebel-promocodes

image

Store: Rebel Scripts

Discord: Discord Link

About:

This script gives admins and owners power to create promo codes with ease. You can create promo codes for items, vehicles and money.

When a code is created a discord webhook will be sent with the new codes information. It will also send a discord webhook when a player redeems a code.

Features:

  • | Create promo codes for items, vehicles and money

  • | Set item quantity, example 5x joints

  • | Set item uses, example 5 uses

  • | Nice promo code creator menu built with qb-input

  • | Discord webhook messages for when a code is created and redeemed.

Resmon: In use (0.00) | Idle (0.00)

Dependencies

Other Resources

Rebel Trucking [QB/ESX]

Rebel Impound Job [QB]

Installation

  1. Put the rebel-promocodes folder in your resources directory
  2. Add ensure rebel-promocodes in your server.cfg
  3. Insert insert.sql to your sql database
  4. Add this to your qb-core/shared.lua
['governmentcode'] 			 	 	 = {['name'] = 'governmentcode', 			  		['label'] = 'Government Code', 				['weight'] = 0, 		['type'] = 'item', 		['image'] = 'receipt.png', 			['unique'] = true, 		['useable'] = false, 	['shouldClose'] = false,   ['combinable'] = nil,   ['description'] = 'A code which can be redeemed somewhere... Cough cough /redeemp {code}'},
  1. Add this to your qb-inventory/html/js/app.js under the function FormatItemInfo
} else if (itemData.name == "governmentcode") {
    $(".item-info-title").html("<p>" + itemData.label + "</p>");
    $(".item-info-description").html("<p>" + itemData.info.label + "</p>");

How to integrate this script in other resources

You can integrate this script into other resources very easily. Here is an example:

Garbage Job, when the player picks up a trash bag he/she has a 10% chance to get a government code(promo code) for $1000 Cash

function GiveGarbageTreasure(source)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)

    local chance = math.random (0,100)
    local code = "Government:"..math.random(100,999).."qbcore"..math.random(100,999)

    if chance >= 90 then
        TriggerEvent('rebel-promocodes:server:giveitemwithcode', Player.PlayerData.citizenid, "money", "cash", 1000, 1, "Garbage Treasure", code)
    end
end

This will give the player a government code item which looks like this:

image

Server:

TriggerEvent('rebel-promocodes:server:giveitemwithcode', citizenid, type, item, amount, uses, wherefrom, code)

Client:

TriggerServerEvent('rebel-promocodes:server:giveitemwithcode', citizenid, type, item, amount, uses, wherefrom, code)

citizenid = The players citizenid, for example Player.PlayerData.citizenid

type = Item type, can be either "Item", "Vehicle" or "Money"

item = Which Item the code should give, for example "Joint" for Item, "Adder" for vehicle, "Cash" for money. You get it.

amount = Amount is how much of the item the code should give, for example 10

uses = How many uses the code should have, for example 10. A player can only use a code once.

wherefrom = Where the code was created from, for example "Bank Robbery"

code = What the code should be, for example "codegen:"..math.random(100,999)