[Release] Rookie4DEXP , Experience and Level Bar for user store in database

This is my first release
i’m just a beginner
help test this for me :] thank you
it’s working on my server

When player reach 100 percent the Level will increase 1 and the percent bar will drop back to 0

You’re free to make an edition and a new release just put the credit :slight_smile:

usage

–add experience from server ----================================

_source = source
TriggerClientEvent('rookie4dexp:addexp', _source, 4)

–4 is the experience amount like a percentages
–add experience from client

TriggerEvent('rookie4dexp:addexp', source, 4)

**Install Sql File first **
Download Here

Screenshot

Screenshot Here

4 Likes

Information/ screenshots/videos
We need more.

ok i’ll upload it right away

Hey this is pretty cool, thanks, will check it out.

how earn point? with kill player? or automatic time

I added
TriggerEvent(‘rookie4dexp:addexp’, _source, 4)
to some scripts, but when want to use it, no EXP is added

where I add what
TriggerEvent (‘rookie4dexp: addexp’, _source, 4)???

try this
TriggerEvent(‘rookie4dexp:addexp’, _source, “4”)

You can add it like this
when player achieve something like a reward
this is from a server side
we use TriggerClientEvent

Screenshot_13

like #dutchplayers said
you need to put this in somewhere when player achieve something
a reward point

yes but in what file is it put?

server.lua
TriggerClientEvent(‘rookie4dexp:addexp’, _source, 4)
or
client.lua
TriggerEvent(‘rookie4dexp:addexp’, _source, 4)

Hi man!

I tried your new line of code.

I get this error in my client console: Rookie4DEXP client.lua:44: attempt to perform arithmetic on a nil value (local ‘upexp’)

I used the client triggerevent

Any idea?

And if i think straight, your original line is correctly used this way: TriggerEvent(‘rookie4dexp:addexp’, _source, 4)

Using “4” on the end is unknown

If i read line 44 of the client.lua i see: local totalexp = currentpercent + upexp

I start with 0 EXP. Zero is NIL, right?

Maybe changing this line.

I’ll try to add some exp in database. Maybe it’s just the 0 value

First of all, thanks for this. Ive been looking at doing something similar myself.
Excuse my ignorance if so but isn’t fetching results every 4 seconds a bad thing?

At the moment for testing ive removed the loop that gets level, ive disabled the ui and just added a /checklevel command that displays level and % in chat. What i noticed with this is, if you trigger addexp or addlevel more than once before checking level, itll only rank you up for the first trigger.

So for example, if i sell drugs to 3 people for 1% each. If i dont check my level for 3 sales, it’ll only give me exp for 1 sale. I’ve yet to understand why, but maybe you have an idea.

op sorry , that “4” was used before i update the code now it 4

after installed the sql file , you got identifier, level and percent
i added the code when player fetch information from database if they didn’t find their identifier id , the server lua will create one for them with their steam id as identifier and level to 0 also the percent to 0 automatically . after that they found their steamid . mysql will fetch it’s level and percent to player and then send to client nui

yes a loop 4 second fetching database is a bad thing. i don’t know if this idea gonna work ( i plan to fetch player exp and percent only once when they are spawning , and when they achieve more exp it only update the value of exp and percent in their local , and when they disconnect the server will fetch their local exp and percent update it back to database )

as you can see , addlevel addpercent uses the current exp and percent + extra level and percent that you store in local update back to database , so you example if you use /checklevel once and it store 2 level and 30% in local . let’s name it
local currentlvl= 0 and then you fetch the data by /checklevel so now currentexp = 2 . so you add 2 morelevel and now the level in database is 4 but the local currentlvl is still 2 because you didn’t update the currentlvl by fetching it . the second time you add 2 more level it just gonna use the currentlvl= 2 , plus the extra 2 and it still 4 , even if you plus it many more time it still gonna be the same without update the current lvl

1 Like

did you check
_source = source