Jump to content

تصحيح خطأ


Recommended Posts

وين الخطأ ؟؟؟

#Client

---------------------------------------------------------------------------------------------------------------- 
function showWarningMessage( message ) 
    local x, y = guiGetScreenSize() 
    if not warningBox then 
        warningBox = guiCreateWindow( x*.5-150, y*.5-65, 300, 120, "warning", false ) 
            guiWindowSetSizable( warningBox, false ) 
        warningImage = guiCreateStaticImage( 10, 30, 60, 60, "warning.png", false, warningBox ) 
        --outputChatBox( tostring( warningImage ) ); 
        warningMessage = guiCreateLabel( 100, 40, 180, 60, "", false, warningBox ) 
        warningOk = guiCreateButton( 130, 90, 70, 20, "Ok", false, warningBox ) 
        addEventHandler( "onClientGUIClick", warningOk, function() guiSetVisible( warningBox, false ) end ) 
    else 
        guiSetPosition( warningBox, x*.5-150, y*.5-65, false ) 
        guiSetVisible( warningBox, true ) 
    end 
    guiSetText( warningMessage, message ) 
    guiBringToFront( warningBox ) 
end 
addEvent( "bank_showWarningMessage", true ) 
addEventHandler( "bank_showWarningMessage", g_localPlayer, showWarningMessage ) 
  
---------------------------------------------------------------------------------------------------------------- 
function performBankAction( ) 
    if source == SendButton then 
        local to_who = guiGetText( SendNameEdit ) 
        amount = tonumber( guiGetText( SendEdit ) ) 
        if to_who == nil or to_who == false or to_who == "" then 
            showWarningMessage( "You must type the name of\nplayer you want to transfer\nmoney to!" ) 
        elseif amount == nil then  
            showWarningMessage( "You must type the amount\nyou want to transfer!" ) 
        elseif amount < 0 then 
            showWarningMessage( "You can't enter negative values!" ) 
        else 
            local money_receiver = getPlayerFromNick( to_who ) 
            if money_receiver == g_localPlayer then 
                showWarningMessage( "You can not transfer money\nto youself!" ) 
            elseif money_receiver ~= g_localPlayer then 
                triggerServerEvent( "bank_transferMoney", g_localPlayer, g_localPlayer, money_receiver, amount ) 
            else 
                showWarningMessage( "Player \"".. to_who .."\"\nis not connected!" ) 
            end 
        end 
    end 
end 

#Server

------------------------------------------------------------------------------- 
function transferMoney( player, receiver, money ) 
    local playerBankID = getBankID( getPlayerBank( player ) ) 
    if type( money ) == 'number' and playersAccount[ player ].balance >= money then 
        local atm = ( banksInfo[ playerBankID ].ATM and true or false ) 
        local triggered = triggerEvent( "onPlayerTransferMoney", player, getPlayerBank( player ), money, receiver, atm  ) 
        if triggered then 
            playersAccount[ player ]:withdraw( money, player, true ) 
            playersAccount[ receiver ]:deposit( money ) 
            triggerClientEvent( player, "bank_updateMyBalance", player, playersAccount[ player ].balance ) 
            bank_savePlayerMoney( player, getPlayerAccount( player ) ) 
            bank_savePlayerMoney( receiver, getPlayerAccount( receiver ) ) 
            if isPlayerInBank( receiver ) then 
                triggerClientEvent( receiver, "bank_updateMyBalance", receiver, playersAccount[ receiver ].balance ) 
            end 
        end 
    elseif type( money ) == 'string' and money == 'all' then     
        money = playersAccount[ player ].balance 
        local atm = ( banksInfo[ playerBankID ].ATM and true or false ) 
        local triggered = triggerEvent( "onPlayerTransferMoney", player, getPlayerBank( player ), money, receiver, atm  ) 
        if triggered then 
            playersAccount[ player ]:withdraw( money, player, true ) 
            playersAccount[ receiver ]:deposit( money ) 
            bank_savePlayerMoney( player, getPlayerAccount( player ) ) 
            bank_savePlayerMoney( receiver, getPlayerAccount( receiver ) ) 
            triggerClientEvent( player, "bank_updateMyBalance", player, playersAccount[ player ].balance ) 
            if isPlayerInBank( receiver ) then 
                triggerClientEvent( receiver, "bank_updateMyBalance", receiver, playersAccount[ receiver ].balance ) 
            end 
        end 
    else 
        triggerClientEvent( player, "bank_showWarningMessage", player, "Insufficient founds!" ) 
    end 
end 
addEvent( "bank_transferMoney", true ) 
addEventHandler( "bank_transferMoney", root, transferMoney ) 

Link to comment

-- Client Side --

---------------------------------------------------------------------------------------------------------------- 
function showWarningMessage( message ) 
    local x, y = guiGetScreenSize() 
    if not warningBox then 
        warningBox = guiCreateWindow( x*.5-150, y*.5-65, 300, 120, "warning", false ) 
            guiWindowSetSizable( warningBox, false ) 
        warningImage = guiCreateStaticImage( 10, 30, 60, 60, "warning.png", false, warningBox ) 
        --outputChatBox( tostring( warningImage ) ); 
        warningMessage = guiCreateLabel( 100, 40, 180, 60, "", false, warningBox ) 
        warningOk = guiCreateButton( 130, 90, 70, 20, "Ok", false, warningBox ) 
        addEventHandler( "onClientGUIClick", warningOk, function() guiSetVisible( warningBox, false ) end ) 
    else 
        guiSetPosition( warningBox, x*.5-150, y*.5-65, false ) 
        guiSetVisible( warningBox, true ) 
    end 
    guiSetText( warningMessage, message ) 
    guiBringToFront( warningBox ) 
end 
addEvent( "bank_showWarningMessage", true ) 
addEventHandler( "bank_showWarningMessage", localPlayer, showWarningMessage ) 
  
---------------------------------------------------------------------------------------------------------------- 
function performBankAction( ) 
    if source == SendButton then 
        local to_who = guiGetText( SendNameEdit ) 
        amount = tonumber( guiGetText( SendEdit ) ) 
        if to_who == nil or to_who == false or to_who == "" then 
            showWarningMessage( "You must type the name of\nplayer you want to transfer\nmoney to!" ) 
        elseif amount == nil then 
            showWarningMessage( "You must type the amount\nyou want to transfer!" ) 
        elseif amount < 0 then 
            showWarningMessage( "You can't enter negative values!" ) 
        else 
            local money_receiver = getPlayerFromNick( to_who ) 
            if not money_receiver then return showWarningMessage( "Player \"".. to_who .."\"\nis not connected!" ) end 
            if money_receiver == localPlayer then 
                showWarningMessage( "You can not transfer money\nto youself!" ) 
            else 
                triggerServerEvent( "bank_transferMoney", localPlayer, localPlayer, money_receiver, amount ) 
            end 
        end 
    end 
end 

Link to comment
-- Client Side --
---------------------------------------------------------------------------------------------------------------- 
function showWarningMessage( message ) 
    local x, y = guiGetScreenSize() 
    if not warningBox then 
        warningBox = guiCreateWindow( x*.5-150, y*.5-65, 300, 120, "warning", false ) 
            guiWindowSetSizable( warningBox, false ) 
        warningImage = guiCreateStaticImage( 10, 30, 60, 60, "warning.png", false, warningBox ) 
        --outputChatBox( tostring( warningImage ) ); 
        warningMessage = guiCreateLabel( 100, 40, 180, 60, "", false, warningBox ) 
        warningOk = guiCreateButton( 130, 90, 70, 20, "Ok", false, warningBox ) 
        addEventHandler( "onClientGUIClick", warningOk, function() guiSetVisible( warningBox, false ) end ) 
    else 
        guiSetPosition( warningBox, x*.5-150, y*.5-65, false ) 
        guiSetVisible( warningBox, true ) 
    end 
    guiSetText( warningMessage, message ) 
    guiBringToFront( warningBox ) 
end 
addEvent( "bank_showWarningMessage", true ) 
addEventHandler( "bank_showWarningMessage", localPlayer, showWarningMessage ) 
  
---------------------------------------------------------------------------------------------------------------- 
function performBankAction( ) 
    if source == SendButton then 
        local to_who = guiGetText( SendNameEdit ) 
        amount = tonumber( guiGetText( SendEdit ) ) 
        if to_who == nil or to_who == false or to_who == "" then 
            showWarningMessage( "You must type the name of\nplayer you want to transfer\nmoney to!" ) 
        elseif amount == nil then 
            showWarningMessage( "You must type the amount\nyou want to transfer!" ) 
        elseif amount < 0 then 
            showWarningMessage( "You can't enter negative values!" ) 
        else 
            local money_receiver = getPlayerFromNick( to_who ) 
            if not money_receiver then return showWarningMessage( "Player \"".. to_who .."\"\nis not connected!" ) end 
            if money_receiver == localPlayer then 
                showWarningMessage( "You can not transfer money\nto youself!" ) 
            else 
                triggerServerEvent( "bank_transferMoney", localPlayer, localPlayer, money_receiver, amount ) 
            end 
        end 
    end 
end 

شكرا يخوى وين كان الخطأ ؟

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