Giter Club home page Giter Club logo

arenaapi's Introduction

#Arena library for Fivem

ArenaAPI functions


#####Once a new arena is created, it can be acces with command: /minigame join [identifier]


###Functions (server side)


About creating arena and others


  • CreateArena(string identifier) returns module of the arena

  • GetArenaInstance(string identifier) will return an instance of arena

  • GetArenaList() will return an array of arenas

  • DoesArenaExists(string identifier) true/false


  • IsArenaBusy(string identifier) return true / false

  • IsArenaActive(string identifier) return true / false

  • IsArenaInactive(string identifier) return true / false

  • GetArenaState(string identifier) return state of arena

ArenaInactive -- no one is in a lobby or arena
ArenaActive -- people are in lobby
ArenaBusy -- people playing already

  • IsPlayerInArena(int source, string name)

  • IsPlayerInAnyArena(int source)

  • GetPlayerArena(int source) returns name of the arena, if he isnt anywhere it will return "none"


Events


  • OnPlayerJoinLobby(cb)
    Will be called whenever someone join arena

  • OnPlayerExitLobby(cb)
    Will be called whenever player leave arena The array data returns

  • OnArenaStart(cb)

  • OnArenaEnd(cb)

  • OnArenaRoundEnd(cb)

  • On(cb)
    if the event is join/leave there is first argument source, second is arena instance
    for others such a like end,start etc, there is only one argument, and thats the arena instance.

{
    MaximumRoundSaved,
    CurrentRound,
    ArenaIdentifier,
    ArenaLabel,
    MaximumCapacity,
    MinimumCapacity,
    CurrentCapacity,
}

Usage of these events

local arenaBuilder = exports.ArenaAPI

local arena = arenaBuilder:GetArenaInstance("MyArena")

arena.PlayerJoinArena(function(data)
    TriggerClientEvent("showNotification", data.source, "Welcome to the arena: " .. data.ArenaLabel)
end)

Second example of events

local arenaBuilder = exports.ArenaAPI

local arena = arenaBuilder:GetArenaInstance("MyArena")

arena.On("join",function(source, data)
    TriggerClientEvent("showNotification", source, "Welcome to the arena: " .. data.ArenaLabel)
end)

#All functions bellow are from module, so use it like this

local arenaBuilder = exports.ArenaAPI
local arena = arenaBuilder:CreateArena("gungame_1")

arena.SetMaximumCapacity(10) -- maximum player
arena.SetMinimumCapacity(2) -- minimum to start
arena.SetArenaLabel("Gungame arena #1")

Setting info about arena


  • SetMaximumCapacity(int number)
    Will set how many people can join to the arena

  • SetMinimumCapacity(int number)
    Will set how many players need to join to start game

  • SetArenaMaxRounds(int number)
    How many rounds this arena will have ?

  • SetArenaLabel(string name)

  • SetOwnWorld(boolean result) when players join to the arena it will create their own world with other players

  • SetMaximumArenaTime(int second)
    This will set for how long the arena can go, if the value isnt set the arena will be there forever

  • SetMaximumLobbyTime(int second)
    How long player have to wait in lobby before letting him into the game, if player leave the lobby the timer will reset to this value.

  • SetArenaPublic(boolean value)
    if true player will be able to acces arena from command /arena join [name]
    if false that means you will have to use somewhere else this function "AddPlayer(int source)"

  • RemoveWorldAfterWin(boolean result) if you have something like winner cutscene, set this on false, but you have to send player into world 0 by your code.


Getting info about arena


  • GetMaximumCapacity()

  • GetMinimumCapacity()

  • GetMaximumRounds()

  • GetCurrentRound()

  • GetPlayerCount()

  • GetArenaIdentifier()

  • GetArenaLabel()

  • GetPlayerList()

  • GetOwnWorld() return boolean, id of world

  • IsArenaPublic()
    true/false (means if you can acces the arena with command /minigame)


Player manipulation


  • AddPlayer(int source)

  • RemovePlayer(int source)


  • Reset()

  • Destroy()
    will destroy arena and new one has to be created


  • SetPlayerScore(int source, string key, object value)

  • GetPlayerScore(int source, string key)

  • GivePlayerScore(int source, string key, object value)

  • RemovePlayerScore(int source, string key, object value)

  • PlayerScoreExists(int source, string key)

  • DeleteScore(int source, string key)


###Functions (client side)


  • IsPlayerInAnyArena() true/false

  • IsPlayerInArena(string arena)

  • GetArenaIdentifier()

  • GetArenaLabel()

  • GetArenaMaximumSize()

  • GetArenaMinimumSize()

  • GetArenaCurrentSize()

  • GetCurrentArenaData() returns array

  • GetCurrentArenaData() returns array

{
    MaximumRoundSaved,
    CurrentRound,
    ArenaIdentifier,
    ArenaLabel,
    MaximumCapacity,
    MinimumCapacity,
    CurrentCapacity,
}

Events


  • OnPlayerJoinLobby(string arena, cb)
    Will be called whenever someone join arena

  • OnPlayerExitLobby(string arena, cb)
    Will be called whenever player leave arena

  • OnArenaStart(string arena, cb)
    Will be called whenever arena started game

  • OnArenaEnd(string arena, cb)
    Will be called after arena runs out of time or player achieve enough points

  • OnArenaRoundEnd(string arena, cb)

  • On(string arena, string eventName, cb)

The array data returns

{
    MaximumRoundSaved,
    CurrentRound,
    ArenaIdentifier,
    ArenaLabel,
    MaximumCapacity,
    MinimumCapacity,
    CurrentCapacity,
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.