gravgor2137

setVariable dosen't work

Recommended Posts

mp.events.add("getInformationAboutDuty", (player) => {
        gm.mysql.handle.query('SELECT `login`,`ranga`, `adminduty` FROM `rp_administration` WHERE `login` = ?', [player], function(err, res){
            let login = res[0]["login"];
            let ranga = res[0]["ranga"];
            let aduty = res[0]["adminduty"];
            console.log(`Login gracza: ${login}, Ranga gracza: ${ranga}, Level duty: ${aduty}`);
            player.setVariable('duty', aduty);
            player.outputChatBox(`Zostałeś zalogowany na służbę administracyjną`);
            player.setVariable('ranga', ranga);
        });
    });

 

 

 

Hi! In this code something does not work for me setVariable - does anyone know why? No error in the console.
   

Share this post


Link to post
Share on other sites

asdaxacacshffs48e.png
read this.

try this:

mp.events.add("getInformationAboutDuty", (player) => {
	gm.mysql.handle.query('SELECT * FROM rp_administration WHERE login = ?', [player], function(err, res) {
		player.setVariable('login', result[0].login);
		player.setVariable('ranga', result[0].ranga);
		player.setVariable('adminduty', result[0].adminduty);
		console.log(`Login gracza: ${player.getVariable('login')}, Ranga gracza: ${player.getVariable('ranga')}, Level duty: ${player.getVariable('adminduty')}`);
		player.outputChatBox(`Zostałeś zalogowany na służbę administracyjną`);
	});
});

 

Share this post


Link to post
Share on other sites

/clients/s44127/packages/administration-system/mysql.js:75: TypeError: Cannot read property 'query' of null
gm.mysql.handle.query('SELECT * FROM rp_administration WHERE login = ?', [player], function(err, res) {

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

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

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

  • Recently Browsing   0 members

    No registered users viewing this page.