Jump to content

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


Recommended Posts

Posted

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.

Posted
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?

Posted
2 minutes ago, javad_iran said:

error:

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

 

how to fix?

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

Posted (edited)
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
Posted
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.

Posted
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

Posted
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.");

Posted
On 9/7/2018 at 1:47 PM, MrPancakers said:

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

thanks.

how to player join , send message for all players online? (notify)

sorry for bad english

Posted
16 hours ago, javad_iran said:

thanks.

how to player join , send message for all players online? (notify)

sorry for bad english

mp.players.broadcast() will send a message to all users on the server. Use the playerJoin event.

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...