Skip to content

popo8720/p_instance

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

p_instance

Standalone instance system for FiveM.

Usage

The player's instance is set using the statebag instance. when setting the instance to a player it is created, a routing bucket is assigned and the player is put in it. if you want to leave the current instance the statebag must be setear to nil

Examples

server-side
RegisterCommand("join_instance", function(source, args)
    local instance_name = args[1]

    Player(source).state.instance = instance_name
end)

RegisterCommand("leave_instance", function(source, args)
    Player(source).state.instance = nil
end)
client-side
RegisterCommand("join_instance", function(source, args)
    local instance_name = args[1]

    LocalPlayer.state:set("instance", instance_name, true) 
end)

RegisterCommand("leave_instance", function(source, args)
    LocalPlayer.state:set("instance", nil, true) 
end)