PatrickChucky Posted July 10, 2012 Share Posted July 10, 2012 Hey guys, Im making a paycheck script and i cant figure out how to make the givemoney ( exported from another resource ) work. I included it in the meta file already, is there anything else i should do? I'm using Paradise Roleplay btw. Here's the code. function onPayDay () local money = math.random( 400, 800 ) local player = getLocalPlayer() local currentMoney = getPlayerMoney( player ) outputChatBox(" ") outputChatBox("|||------------ Pay Day ------------|||", 70, 200, 0) outputChatBox(" ") outputChatBox("Saldo actual -| #EEDDAA"..currentMoney, 250, 250, 250, true) outputChatBox("Ganho -| #EEDDAA"..money, 250, 250, 250, true) outputChatBox("Novo saldo -| #EEDDAA"..currentMoney + money, 250, 250, 250, true) outputChatBox(" ") outputChatBox("|||------------------------------------|||", 70, 200, 0) exports.players:giveMoney( player, money ) -- This should give money to the player and update the database too. givePlayerMoney( player, money ) -- This just gives him money, whenever he dies or leaves the server this money is gone. end Thanks in advance, PatrickChucky Link to comment
Tete omar Posted July 10, 2012 Share Posted July 10, 2012 (edited) firstly you shouldn't use comma after the function name like this onPayDay () and where's it's event handler ? try this function onPayDay() local money = math.random( 400, 800 ) local player = getLocalPlayer() local currentMoney = getPlayerMoney( player ) outputChatBox(" ") outputChatBox("|||------------ Pay Day ------------|||", 70, 200, 0) outputChatBox(" ") outputChatBox("Saldo actual -| #EEDDAA"..currentMoney, 250, 250, 250, true) outputChatBox("Ganho -| #EEDDAA"..money, 250, 250, 250, true) outputChatBox("Novo saldo -| #EEDDAA"..currentMoney and money, 250, 250, 250, true) outputChatBox(" ") outputChatBox("|||------------------------------------|||", 70, 200, 0) exports.players:giveMoney( player, money ) if isPlayerDead( source ) then givePlayerMoney( player, money ) end end addEventHandler("onPlayerQuit", getRootElement(), onPayDay) addEventHandler("onPlayerWasted", getRootElement(), onPayDay) this is must be on server side but i'm not sure because you didn't specific what side is this code Edited July 10, 2012 by Guest Link to comment
PatrickChucky Posted July 10, 2012 Author Share Posted July 10, 2012 This is the code i have, i just thought it was irrelevant, this is client side. function onPayDay () local money = math.random( 400, 800 ) local player = getLocalPlayer() local currentMoney = getPlayerMoney( player ) outputChatBox(" ") outputChatBox("|||------------ Pay Day ------------|||", 70, 200, 0) outputChatBox(" ") outputChatBox("Saldo actual -| #EEDDAA"..currentMoney, 250, 250, 250, true) outputChatBox("Ganho -| #EEDDAA"..money, 250, 250, 250, true) outputChatBox("Novo saldo -| #EEDDAA"..currentMoney + money, 250, 250, 250, true) outputChatBox(" ") outputChatBox("|||------------------------------------|||", 70, 200, 0) exports.players:giveMoney( player, money ) givePlayerMoney( player, money ) end addEvent( "isTimeToPayDay", true) addEventHandler( "isTimeToPayDay", getRootElement(), onPayDay) Server side i have this. function payDay () local time = getRealTime() local minutes = time.minute local seconds = time.seconds if minutes == 00 and seconds == 0 then triggerClientEvent("isTimeToPayDay", getRootElement()) end end addCommandHandler( "paycheck", function ( playerSource, commandName ) triggerClientEvent("isTimeToPayDay", getRootElement()) end ) addEventHandler("onResourceStart", resourceRoot, function () setTimer(payDay, 1000,0) end) firstly you shouldn't use comma after the function name like this onPayDay () I don't understand what you mean with this... Thanks for helping. Link to comment
Anderl Posted July 10, 2012 Share Posted July 10, 2012 addEvent( 'isTimeToPayDay', true ); addEventHandler( 'isTimeToPayDay', root, function( ) local nMoney = math.random( 400, 800 ); local nCurrent = getPlayerMoney( localPlayer ); outputChatBox( '' ); outputChatBox( '|||------------ Pay Day ------------|||', 70, 200, 0, false ); outputChatBox(" ") outputChatBox( 'Saldo actual -| #EEDDAA' .. currentMoney, 250, 250, 250, true ); outputChatBox( 'Ganho -| #EEDDAA' .. money, 250, 250, 250, true ); outputChatBox( 'Novo saldo -| #EEDDAA' .. currentMoney + money, 250, 250, 250, true ); outputChatBox( '' ); outputChatBox( '|||------------------------------------|||', 70, 200, 0, false ); exports['players']:giveMoney( localPlayer, nMoney ); givePlayerMoney( nMoney ); end ) Not tested. Link to comment
Tete omar Posted July 10, 2012 Share Posted July 10, 2012 I didn't know that you triggered the code but you good luck with this function onPayDay() local money = math.random( 400, 800 ) local player = getLocalPlayer() local currentMoney = getPlayerMoney( player ) outputChatBox(" ") outputChatBox("|||------------ Pay Day ------------|||", 70, 200, 0) outputChatBox(" ") outputChatBox("Saldo actual -| #EEDDAA"..currentMoney, 250, 250, 250, true) outputChatBox("Ganho -| #EEDDAA"..money, 250, 250, 250, true) outputChatBox("Novo saldo -| #EEDDAA"..currentMoney and money, 250, 250, 250, true) outputChatBox(" ") outputChatBox("|||------------------------------------|||", 70, 200, 0) exports.players:giveMoney( player, money ) if isPlayerDead( player ) then givePlayerMoney( player, money ) end end and your welcome Link to comment
Anderl Posted July 10, 2012 Share Posted July 10, 2012 I didn't know that you triggered the code but you good luck with this function onPayDay() local money = math.random( 400, 800 ) local player = getLocalPlayer() local currentMoney = getPlayerMoney( player ) outputChatBox(" ") outputChatBox("|||------------ Pay Day ------------|||", 70, 200, 0) outputChatBox(" ") outputChatBox("Saldo actual -| #EEDDAA"..currentMoney, 250, 250, 250, true) outputChatBox("Ganho -| #EEDDAA"..money, 250, 250, 250, true) outputChatBox("Novo saldo -| #EEDDAA"..currentMoney and money, 250, 250, 250, true) outputChatBox(" ") outputChatBox("|||------------------------------------|||", 70, 200, 0) exports.players:giveMoney( player, money ) if isPlayerDead( player ) then givePlayerMoney( player, money ) end end and your welcome Wrong. Link to comment
Wei Posted July 10, 2012 Share Posted July 10, 2012 secund argument in outputChatBox must be root.... Link to comment
PatrickChucky Posted July 10, 2012 Author Share Posted July 10, 2012 Still the same. exports.players:giveMoney( getLocalPlayer(), nMoney ); This is what is not working, but i have no idea why, i have the the includes in meta file... Link to comment
Wei Posted July 10, 2012 Share Posted July 10, 2012 Client-side, no. i tought it was server. Link to comment
Castillo Posted July 10, 2012 Share Posted July 10, 2012 If I'm right, the exported function: giveMoney is not available client side. Link to comment
PatrickChucky Posted July 10, 2012 Author Share Posted July 10, 2012 If I'm right, the exported function: giveMoney is not available client side. You're right, put everything server side and its working. Thanks everyone for your help. Peace. PatrickChucky Link to comment
Tete omar Posted July 10, 2012 Share Posted July 10, 2012 He confused between the client side and server side lol sorry i got careless of your code but good luck Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now