Jump to content

GetMoney Script ( MySQL Gamemode [Login/Registration System] )


javad_iran

Recommended Posts

12 minutes ago, MrPancakers said:

player.getMoney() is a clientside function, so it needs to be mp.players.local.getMoney();

You also don't need to provide a number inside the brackets, the function is used to GET money, not SET how much the player has.

error:

mp.players.local.getMoney is not a function
                        mp.players.local.getMoney(250);

 

how to fix?

Link to comment
Share on other sites

8 minutes ago, MrPancakers said:

I should have asked, are you doing this clientside or serverside

See,
I want to do it, when someone creates a vehicle, 250 money will be reduced, this is my vehicle's server code:

mp.events.addCommand('veh', (player, _, vehName) => {
    if (vehName && vehName.trim().length > 0) {
        mp.players.local.getMoney(250);
        let pos = player.position;
        pos.x += 2;
        // If player has vehicle - change model.
        if (player.customData.vehicle) {
            player.customData.vehicle.repair();
            player.customData.vehicle.position = pos;
            player.customData.vehicle.model = mp.joaat(vehName);
        // Else - create new vehicle.
        } else {
            player.customData.vehicle = mp.vehicles.new(mp.joaat(vehName), pos);
        }
    } else {
        player.outputChatBox(`<b>Command syntax:</b> /veh [vehicle_name]`);
    }
});

 

sorry for bad english

Edited by javad_iran
Link to comment
Share on other sites

43 minutes ago, javad_iran said:

See,
I want to do it, when someone creates a vehicle, 250 money will be reduced, this is my vehicle's server code:

mp.events.addCommand('veh', (player, _, vehName) => {
    if (vehName && vehName.trim().length > 0) {
        mp.players.local.getMoney(250);
        let pos = player.position;
        pos.x += 2;
        // If player has vehicle - change model.
        if (player.customData.vehicle) {
            player.customData.vehicle.repair();
            player.customData.vehicle.position = pos;
            player.customData.vehicle.model = mp.joaat(vehName);
        // Else - create new vehicle.
        } else {
            player.customData.vehicle = mp.vehicles.new(mp.joaat(vehName), pos);
        }
    } else {
        player.outputChatBox(`<b>Command syntax:</b> /veh [vehicle_name]`);
    }
});

 

sorry for bad english

Do player.money -= 250 (This will take away 250 from player.money)

player.getMoney() is a clientside function so you can't use it serverside which is what you're trying to do.

Link to comment
Share on other sites

10 minutes ago, MrPancakers said:

Do player.money -= 250 (This will take away 250 from player.money)

player.getMoney() is a clientside function so you can't use it serverside which is what you're trying to do.

Thank you very much, the problem was fixed
I had another question:
How to make a bet if there are 250 money, make a car, otherwise it will give an error

very sorry for bad english , i am use translate

Link to comment
Share on other sites

1 minute ago, javad_iran said:

Thank you very much, the problem was fixed
I had another question:
How to make a bet if there are 250 money, make a car, otherwise it will give an error

very sorry for bad english , i am use translate

if(player.money < 250) return player.outputChatBox("You don't have enough money.");

Link to comment
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.
×
×
  • Create New...