Introduction

Hello, a while in the past I created an occasion script for a home system and determined to share it as I believe it’s very helpful. The utility of the script is to separate the gamers into totally different “dimensions” recognized by names, thus making it simpler for gamers to be grouped in several cases. The commonest factor for cases is to make use of them inside interiors, with the intention to use the identical inside a number of instances without delay.


The way it works

To isolate gamers from different gamers, fivem’s routing bucket system is used. Merely coming into an empty occasion assigns a bucket quantity to this occasion, and reserves it in order that it isn’t utilized by every other. each time a brand new participant enters, they put it within the routing bucket of the dimension. As soon as the occasion is emptied the bucket quantity is launched, in order that it may be utilized by a brand new occasion.


The participant’s occasion is ready utilizing the statebag occasion. when setting the occasion to a participant it’s created, a routing bucket is assigned and the participant is put in it. if you wish to go away the present occasion the statebag have to be set to nil

Examples

server-side

RegisterCommand("join_instance", perform(supply, args)
    native instance_name = args[1]

    Participant(supply).state.occasion = instance_name
finish)

RegisterCommand("leave_instance", perform(supply, args)
    Participant(supply).state.occasion = nil
finish)

client-side

RegisterCommand("join_instance", perform(supply, args)
    native instance_name = args[1]

    LocalPlayer.state:set("occasion", instance_name, true) 
finish)

RegisterCommand("leave_instance", perform(supply, args)
    LocalPlayer.state:set("occasion", nil, true) 
finish)

Final launch: Release v1.0.0 · popo8720/p_instance · GitHub
repository: GitHub – popo8720/p_instance: Fivem instance system



Looking for paid scripts? Click here