# Witchcraft

<https://randolio.tebex.io/package/6651263>

## Whitelisted Identifiers (config.lua)

```lua
Whitelist = {
    ['PUTIDHERE'] = {
        AllowRevive = true, ChangeWeather = true, SmokeColor = { r = 217, g = 9, b = 64 }, -- rgb smoke color unique for that player.
        Teleports = {
            {label = 'Cemetery', icon = 'cross', coords = vec4(-1728.95, -193.12, 58.53, 13.87)},
            {label = 'Hospital', icon = 'hospital', coords = vec4(-841.78, -1207.0, 6.45, 49.54)},
            {label = 'Legion Square', icon = 'location-dot', coords = vec4(187.63, -953.0, 30.09, 155.34)},
        }
    },
},
-- ESX: 'char1:c37f85056e3025a8515ac804d394b9d801e0f7e1' | QB/QBX: 'RT67HUI0'
```

## Spellbook

<pre class="language-lua"><code class="lang-lua"><strong>Spells = {
</strong>    fire = { label = 'Cast Fire', desc = 'Set a person on fire briefly.', icon = 'fire', },
    force = { label = 'Cast Force', desc = 'Force push a person back.', icon = 'hand-sparkles', },
    stun = { label = 'Cast Stun', desc = 'Stun a player.', icon = 'bolt', },
    trip = { label = 'Cast Clone Trip', desc = 'Send a player on a trip with clones chasing them.', icon = 'burst', },
    levitation = { label = 'Cast Levitation', desc = 'Levitate yourself and meditate.', icon = 'wand-sparkles', },
},

-- Example of adding a new spell to the table above:
example = { label = 'Cast Example', desc = 'Do something', icon = 'wand-sparkles', },

-- Your spell function can be placed in cl_open.
function exampleSpell()
    print('do something')
end

-- Adjust the event in cl_open.lua to adapt your new spell.
RegisterNetEvent('randol_witchcraft:client:castSpell', function(spell)
    if GetInvokingResource() or not hasPlyLoaded() then return end
    if spell == 'fire' then
        fireSpell()
    elseif spell == 'force' then
        forceSpell()
    elseif spell == 'stun' then
        stunSpell()
    elseif spell == 'trip' then
        cloneTrip()
    elseif spell == 'example' then -- added here using the key from the Spells table.
        exampleSpell()
    end
end)
</code></pre>

## Potions

```lua
-- Adding a new potion example to the config.lua
Potions = {
    new_potion = {
        restricted = true, -- Only a whitelist person can use it.
        event = 'randol_witchcraft:client:useNewPotion', -- client event name for using your potion that gets invoked from server. Potion name will get passed in.
        ingredients = { -- Used for crafting. You can remove the ingredients altogether or leave the table empty and it can still be crafted for free.
            { name = 'iron', amount = 1}, 
            { name = 'steel', amount = 2},
        },
    },
}

-- Event for your new potion which passes through the item name. Can be put in cl_open.
RegisterNetEvent('randol_witchcraft:client:useNewPotion', function(itemName)
    if GetInvokingResource() then return end
    print('using new potion')
end)

-- ox inventory new potion example
['new_potion'] = {
    label = 'New Potion',
    weight = 0,
    consume = 0,
    client = { image = 'new_potion.png', },
    server = { export = 'randol_witchcraft.new_potion', },
    description = 'This is a new potion.'
},

-- qb inventory new potion example
new_potion = { name = 'new_potion', label = 'New Potion', weight = 0, type = 'item', image = 'new_potion.png', unique = false, useable = true, shouldClose = true, description = 'A new potion' },
```

## Set Weather

```lua
-- Must adapt this to your weathersync in sv_open.
function setWeather(weather)
    -- insert your weather script export/event in here
    if GetResourceState('randol_weather') == 'started' then
        return exports.randol_weather:SetWeather(weather)
    end

    if GetResourceState('qb-weathersync') == 'started' then
        return exports['qb-weathersync']:setWeather(weather)
    end

    lib.print.error('No weathersync resource provided? see sv_open.lua')
end
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://randolio.gitbook.io/docs/paid-scripts/witchcraft.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
