Jump to content

1 Screenshot

About This File

ooPXk9n.jpg

Installing

  • Put the files you downloaded in their respective places
  • Add require('levels') to client_packages/index.js
  • Open packages/levels/database.js and put your MySQL config
  • All done

 

API

/*
    Player level and XP is accessed through currentLevel and currentXP shared data keys.
    You should not change the value of these shared data keys, just use them to get data and use the API to set data.
*/
player.data.currentLevel OR player.getVariable("currentLevel") // returns level of the player
player.data.currentXP OR player.getVariable("currentXP") // returns XP of the player

/*
    setLevel(newLevel)
    Sets the player's level to newLevel. (will also change player's XP to level XP)
*/
player.setLevel(newLevel)

/*
    setXP(newXP)
    Sets the player's experience to newXP. (will update player's level)
*/
player.setXP(newXP)

/*
    changeXP(xpAmount)
    Changes the player's experience by xpAmount. (will update player's level)
*/
player.changeXP(xpAmount)

/*
    hasReachedMaxLevel()
    Returns whether the player has reached max level or not.
*/
player.hasReachedMaxLevel()

/*
    saveLevelAndXP()
    Saves the player's level and XP data. Automatically called a player disconnects.
*/
player.saveLevelAndXP()

 

Events

These events are called on serverside when a player's level or XP changes.

/*
    playerXPChange
    This event is called when a player's XP changes.
*/
mp.events.add("playerXPChange", (player, oldXP, newXP, difference) => {
    // code
});

/*
    playerLevelChange
    This event is called when a player's level changes.
*/
mp.events.add("playerLevelChange", (player, oldLevel, newLevel) => {
    // code
});

 

Example Script

Here's a script that lets you change your level/XP and writes it to console:

mp.events.addCommand("setlevel", (player, newLevel) => {
    newLevel = Number(newLevel);

    if (!isNaN(newLevel)) {
        player.setLevel(newLevel);
    } else {
        player.outputChatBox("SYNTAX: /setlevel [new level]");
    }
});

mp.events.addCommand("changexp", (player, amount) => {
    amount = Number(amount);

    if (!isNaN(amount)) {
        player.changeXP(amount);
    } else {
        player.outputChatBox("SYNTAX: /changexp [amount]");
    }
});

mp.events.addCommand("setxp", (player, amount) => {
    amount = Number(amount);

    if (!isNaN(amount)) {
        player.setXP(amount);
    } else {
        player.outputChatBox("SYNTAX: /setxp [new xp amount]");
    }
});

mp.events.add("playerXPChange", (player, oldXP, newXP, difference) => {
    console.log(`${player.name} ${difference < 0 ? "lost" : "gained"} some XP. Old: ${oldXP} - New: ${newXP} - Difference: ${difference}`);
});

mp.events.add("playerLevelChange", (player, oldLevel, newLevel) => {
    console.log(`${player.name} had a level change. Old: ${oldLevel} - New: ${newLevel}`);
});

 

Credits

 

Notes

  • This script will load and save level and XP data of players on its own but a function to save player data yourself is provided.
  • Like said before, don't change the values of currentLevel and currentXP shared data keys.
  • Maximum reachable level is 7999 but a player can earn XP until his rank bar is full, kinda reaching 8000. Use player.hasReachedMaxLevel() to detect if a player is level 7999 and his rank bar is full.

 

THYkXhr.jpg

  • Like 11

User Feedback

Create an account or sign in to leave a review

You need to be a member in order to leave a review

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

hartority

· Edited by hartority

   4 of 5 members found this review helpful 4 / 5 members

Change the colors of the icons

ihszoR9.png

if(!mp.game.graphics.hasHudScaleformLoaded(19)) 
{
    mp.game.graphics.requestHudScaleform(19);
    while (!mp.game.graphics.hasHudScaleformLoaded(19)) mp.game.wait(0);
}

mp.game.graphics.pushScaleformMovieFunctionFromHudComponent(19, "SET_COLOUR");
mp.game.graphics.pushScaleformMovieFunctionParameterInt(116); //Active bar color
mp.game.graphics.pushScaleformMovieFunctionParameterInt(123); //Background bar color
mp.game.graphics.popScaleformMovieFunctionVoid();

mp.game.ui.setHudColour(116, 171, 51, 42, 255);// HUD_COLOUR_FREEMODE - pattern color
mp.game.ui.setHudColour(140, 56, 36, 35, 255);// HUD_COLOUR_INGAME_BG - circle background color

mp.game.graphics.pushScaleformMovieFunctionFromHudComponent(19, "SET_RANK_SCORES");
mp.game.graphics.pushScaleformMovieFunctionParameterInt(currentRankLimit); //current rank limit
mp.game.graphics.pushScaleformMovieFunctionParameterInt(nextRankLimit); //next rank limit
mp.game.graphics.pushScaleformMovieFunctionParameterInt(playersPreviousXP); //players previous xp
mp.game.graphics.pushScaleformMovieFunctionParameterInt(playersCurrentXP); //players current xp
mp.game.graphics.pushScaleformMovieFunctionParameterInt(rank); //rank
mp.game.graphics.popScaleformMovieFunctionVoid();

mp.game.graphics.pushScaleformMovieFunctionFromHudComponent(19, "OVERRIDE_ANIMATION_SPEED");
mp.game.graphics.pushScaleformMovieFunctionParameterInt(2000);
mp.game.graphics.popScaleformMovieFunctionVoid();

Credits:

Porn 👑 - help in development

Guest Gtaplayer

  

What should i do if i only want the Logo with the Number

hubba

  

a root production...............

Hera

· Edited by Hera

  

yapıyon ha emmioğlu
 

×
×
  • Create New...