Jump to content

[HELP] Problem with exports


Recommended Posts

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

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 by Guest
Link to comment

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

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

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