# New Player & Anti troll

{% hint style="info" %}
Available Frameworks: RSG and VORP
{% endhint %}

## About Script

With our New Player Limit Script, fresh players will have restrictions preventing them from shooting or taking hostile actions against others until they’ve spent enough time in the game. This ensures a fair and safe environment for everyone, especially newcomers.

## 📄 VORP Core Integration Instructions

To integrate with `vorp_core`, you need to **modify** the `vorp_core/client/spawnplayer.lua` file.

Specifically, you must **extend** the existing `vorp:initCharacter` event to include the custom character initialization.

Here’s how to do it properly:

### ✏️ Steps

1. Locate the `vorp:initCharacter` event handler inside `vorp_core/client/spawnplayer.lua`.
2. **At the very end** of the `vorp:initCharacter` function, **add the following trigger:**

```lua
TriggerEvent("vorp:initCharCustom", coords, heading, isdead)
```

> This ensures your custom initialization runs after the player has fully loaded.

***

### 🛠️ Example: Full Modified `vorp:initCharacter`

```lua
RegisterNetEvent('vorp:initCharacter')
AddEventHandler('vorp:initCharacter', function(coords, heading, isdead)
    CoreAction.Player.TeleportToCoords(coords, heading)

    if isdead then
        if not Config.CombatLogDeath then
            if Config.Loadinscreen then
                Citizen.InvokeNative(0x1E5B70E53DB661E5, 0, 0, 0, T.forcedrespawn, T.forced, T.Almost)
            end
            SetEntityCanBeDamaged(PlayerPedId(), true)
            CoreAction.Player.RespawnPlayer()
            Wait(Config.LoadinScreenTimer)
            Wait(1000)
            ShutdownLoadingScreen()
            Wait(5000)
        else
            if Config.Loadinscreen then
                Citizen.InvokeNative(0x1E5B70E53DB661E5, 0, 0, 0, T.Holddead, T.Loaddead, T.Almost)
            end
            Wait(10000)
            TriggerEvent("vorp_inventory:CloseInv")
            Wait(4000)
            SetEntityCanBeDamaged(PlayerPedId(), true)
            SetEntityHealth(PlayerPedId(), 0, 0)
            Citizen.InvokeNative(0xC6258F41D86676E0, PlayerPedId(), 0, -1)
            ShutdownLoadingScreen()
        end
    else
        local PlayerId = PlayerId()

        if Config.Loadinscreen then
            if Config.LoadingScreenPlayerInfo then
                Citizen.InvokeNative(0x1E5B70E53DB661E5, 0, 0, 0, LocalPlayer.state.Character.FirstName .. " " .. LocalPlayer.state.Character.LastName, "Job: " .. LocalPlayer.state.Character.JobLabel)
            else
                Citizen.InvokeNative(0x1E5B70E53DB661E5, 0, 0, 0, T.Hold, T.Load, T.Almost)
            end
            Wait(Config.LoadinScreenTimer)
            Wait(1000)
            ShutdownLoadingScreen()
        end

        if not Config.HealthRecharge.enable then
            Citizen.InvokeNative(0x8899C244EBCF70DE, PlayerId, 0.0)
        else
            Citizen.InvokeNative(0x8899C244EBCF70DE, PlayerId, Config.HealthRecharge.multiplier)
            multiplierHealth = Citizen.InvokeNative(0x22CD23BB0C45E0CD, PlayerId)
        end

        if not Config.StaminaRecharge.enable then
            Citizen.InvokeNative(0xFECA17CF3343694B, PlayerId, 0.0)
        else
            Citizen.InvokeNative(0xFECA17CF3343694B, PlayerId, Config.StaminaRecharge.multiplier)
            multiplierStamina = Citizen.InvokeNative(0x617D3494AD58200F, PlayerId)
        end

        SetEntityCanBeDamaged(PlayerPedId(), true)

        if Config.SavePlayersStatus then
            TriggerServerEvent("vorp:GetValues")
            Wait(200)
            if HealthData then
                local player = PlayerPedId()
                Citizen.InvokeNative(0xC6258F41D86676E0, player, 0, HealthData.hInner or 600)
                SetEntityHealth(player, (HealthData.hOuter and HealthData.hOuter > 0 and HealthData.hOuter or 600) + (HealthData.hInner and HealthData.hInner > 0 and HealthData.hInner or 600), 0)
                Citizen.InvokeNative(0xC6258F41D86676E0, player, 1, HealthData.sInner or 600)
                Citizen.InvokeNative(0x675680D089BFA21F, player, (HealthData.sOuter or (1065353215 * 100)) / 1065353215 * 100)
            end
            HealthData = {}
        else
            CoreAction.Admin.HealPlayer()
        end
    end

    SetTimeout(2000, function()
        DoScreenFadeIn(4000)
        repeat Wait(500) until IsScreenFadedIn()
    end)

    -- 🧩 ADD THIS LINE AT THE END
    TriggerEvent("vorp:initCharCustom", coords, heading, isdead)
end)
```

***

### 📌 Important Notes

* Do **not** replace the existing `vorp:initCharacter` logic.
* Only **add** `TriggerEvent("vorp:initCharCustom", coords, heading, isdead)` **at the very end** of the handler.
* This ensures compatibility with VORP Core and adds your custom handling without breaking the default flow.

## Installation

Plug & play

## Configuration

<figure><img src="/files/42RW4FO49BU7pXNhj1or" alt=""><figcaption></figcaption></figure>


---

# 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://code-after-sex.gitbook.io/script-documentation/about-paid-scripts/redm-script-documentation/new-player-and-anti-troll.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.
