GTA:O Styled Scoreboard + API to add and edit columns!


#1

What is this?

this is @Vespura’s Scoreboard, with a little twist to it!

What’s different?

You can add and edit columns! (see below for an example implementation.).

screenshots?

Right here!

https://gyazo.com/6c46d6c08d3f1b797d45450c505ac467

How do i use the API?

it’s simple!

the API is composed of three exports:

  • AddColumn:
    Takes 2 arguments: one is a string, the COLUMN NAME and the second is a table, with all the values for each player, in the right order ( from player 1 to player x)

  • EditColumn:
    Takes 2 arguments: a string, the COLUMN NAME and a table, with all the values for each player, in the right order.

  • EditCell:
    Takes 3 arguments, three strings: the COLUMN NAME, the SERVER ID OF THE PLAYER(MUST BE A STRING) and the NEW VALUE!

Example:

i have made an implementation of this api, in the Drift Counter resource by @Blumlaut (thanks to @IllusiveTea for helping me with the tests btw! :heart: )
here are some snippets from it, so you can understand how the api works!

driftcounter_c.lua:

  • Adding the column on first spawn:
local FirstTime = true
AddEventHandler("playerSpawned", function()
	if FirstTime then
		print("first spawn!")
		local defaultscores = {}
		TriggerServerEvent("LoadScoreData")
		for i,player in pairs(GetPlayers()) do
			table.insert(defaultscores,"0")
		end
		print(json.encode(defaultscores))
		exports[GetCurrentResourceName()]:AddColumn("Drift Score", defaultscores)
		FirstTime = false
	end
end)
  • event to update the scoreboard!
RegisterNetEvent("UpdateScoreboard")
AddEventHandler("UpdateScoreboard", function(id, data)
	exports[GetCurrentResourceName()]:EditCell("Drift Score", id, tostring(data))
end)	

driftcounter_s.lua

  • syncing the scoreboards together!
RegisterNetEvent("SaveScore")
AddEventHandler("SaveScore", function(client, data)
	UpdatePlayerInDB(client, data)
	TriggerClientEvent("UpdateScoreboard",-1,tostring(client),tostring(data.score))
end)

DOWNLOAD!:

source:


binaries:

issues:

if you are having issues, please open a ticket on the github page!

credits

@Vespura for the initial codebase! (https://github.com/TomGrobbe/GTAoScoreboard)
@GlitchyBoi for helping with some tests!
@IllusiveTea for helping me with A LOT of tests :joy:
@Blumlaut for the DriftCounter resource!

have a suggestion? leave it below! i’ll take it in consideration!


#2

and next time, please just use the API we have instead of modifying the source code of my resource :stuck_out_tongue:


#3

>not using NUI
>therefore not supporting edgy unicode nicknames

:confused:

also the layouting is horrible


#4

:confused: this is basically the same as @Vespura’s scoreboard, i didnt touch the “drawing on the screen” code.

i know, but i’m too noob at c# to fix it :joy: maybe in the future, when i have a bit more experience lmao


#5

+1 Sexy Shit my dude



#6

+2


#7

Would you guys like to have this as a NUI scoreboard and to have much better layouting?

  • Yes
  • No

0 voters

if yes wins then tomorrow ill start working on it, and hopefully i will release the update next saturday.


#8

Reindented the example code


#9

thanks a lot :smiley: