Jump to content

تصحيح كود بسيط


#TeKa

Recommended Posts

السلام عليكم اليوم حاولت اني اسوي بنك بس ما يشتغل و ما اعرف ايش المشكله ممكن حل

انا مسوي الماركرات في ملف Banks.xml فا انا راح احطو مع الكلينت و السيرفر

اول شييء:

Client Side

addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()), 
  fuction () 
  -- bank 
   
  bankWindow = guiCreateWindow(201,104,290,287,"-- BANK NAME --",false) 
  guiSetVisible (bankWindow,false) 
  bankWindowDisplay = guiCreateEdit(0.0483,0.115,0.8897,0.108,"",true,bankWindow) 
  guiEditSetReadOnly(bankWindowDisplay,true) 
  bankWindow1 = guiCreateButton(0.0793,0.2404,0.1759,0.1638,"1",true,bankWindow) 
  bankWindow2 = guiCreateButton(0.3,0.2404,0.1759,0.1638,"2",true,bankWindow) 
  bankWindow3 = guiCreateButton(0.5241,0.2404,0.1759,0.1638,"3",true,bankWindow) 
  bankWindow4 = guiCreateButton(0.0793,0.4425,0.1759,0.1638,"4",true,bankWindow) 
  bankWindow5 = guiCreateButton(0.3,0.4425,0.1759,0.1638,"5",true,bankWindow) 
  bankWindow6 = guiCreateButton(0.5241,0.4425,0.1759,0.1638,"6",true,bankWindow) 
  bankWindow7 = guiCreateButton(0.0793,0.6481,0.1759,0.1638,"7",true,bankWindow) 
  bankWindow8 = guiCreateButton(0.3034,0.6481,0.1759,0.1638,"8",true,bankWindow) 
  bankWindow9 = guiCreateButton(0.5241,0.6481,0.1759,0.1638,"9",true,bankWindow) 
  bankWindowClose = guiCreateButton(0.0793,0.8328,0.8448,0.0906,"Close",true,bankWindow) 
  bankWindowStore = guiCreateButton(0.7448,0.2404,0.1759,0.1638,"Store",true,bankWindow) 
  bankWindowWithdraw = guiCreateButton(0.7448,0.4425,0.1759,0.1638,"Withdraw",true,bankWindow) 
  bankWindow0 = guiCreateButton(0.7448,0.6481,0.1759,0.1638,"0",true,bankWindow) 
  
    enableWideScreen (getLocalPlayer()) 
  elseif (source == bankWindow1) then 
    addIntoBankEditDisplay ("1") 
  elseif (source == bankWindow2) then 
    addIntoBankEditDisplay ("2") 
  elseif (source == bankWindow3) then 
    addIntoBankEditDisplay ("3") 
  elseif (source == bankWindow4) then 
    addIntoBankEditDisplay ("4") 
  elseif (source == bankWindow5) then 
    addIntoBankEditDisplay ("5") 
  elseif (source == bankWindow6) then 
    addIntoBankEditDisplay ("6") 
  elseif (source == bankWindow7) then 
    addIntoBankEditDisplay ("7") 
  elseif (source == bankWindow8) then 
    addIntoBankEditDisplay ("8") 
  elseif (source == bankWindow9) then 
    addIntoBankEditDisplay ("9") 
  elseif (source == bankWindow0) then 
    addIntoBankEditDisplay ("0") 
  elseif (source == bankWindowClose) then 
    guiSetVisible (bankWindow,false) 
    guiSetText (bankWindowDisplay,"") 
    showCursor (false,false) 
  elseif (source == bankWindowStore) then 
    triggerServerEvent ("bankStoreMoney",getLocalPlayer(),tonumber(guiGetText(bankWindowDisplay))) 
  elseif (source == bankWindowWithdraw) then 
    triggerServerEvent ("bankWithdrawMoney",getLocalPlayer(),tonumber(guiGetText(bankWindowDisplay))) 
  end 
end) 

________________

Server Side

addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
  bankr = xmlLoadFile("banks.xml"); 
  
addEventHandler("onResourceStop",getResourceRootElement(getThisResource()), 
function () 
  xmlUnloadFile(bankr); 
end); 
  
-- BANK 
addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
  local allBanks = xmlNodeGetChildren (bankr) 
  for i,v in ipairs (allBanks) do 
    local x = xmlNodeGetAttribute (v,"x") 
    local y = xmlNodeGetAttribute (v,"y") 
    local z = xmlNodeGetAttribute (v,"z") 
    local bankname = xmlNodeGetValue  (v) 
    createBlip (x,y,z,52) 
    local atmmarker = createMarker (x,y,z-1,"cylinder",2,0,255,0,100) 
    local atm = createObject (2942,x,y+0.75,z-0.25) 
    setElementData (atmmarker,"bank",bankname) 
  end 
   
addEvent ("bankStoreMoney",true) 
addEventHandler ("bankStoreMoney",getRootElement(), 
function(amount) 
  local playerMoney = getPlayerMoney (source) 
  if (playerMoney < amount) then 
  outputChatBox ("You Don't Have any Money in The Bank!!", source, 0, 255, 0, false) 
  else 
      local currentBank = xmlNodeGetAttribute (characterRoot,"bank") 
      local newBank = tonumber (currentBank) + amount 
      setPlayerMoney (source,getPlayerMoney (source) -amount)   
      local bank = xmlNodeGetAttribute (characterRoot,"bank") 
      triggerClientEvent (source,"lolmodRefreshBankInfoMenu",source,getPlayerMoney (source),bank) 
      xmlSaveFile (root) 
    end 
  end 
end 
) 
  
addEvent ("bankWithdrawMoney",true) 
addEventHandler ("bankWithdrawMoney",getRootElement(), 
function(amount) 
  local charactername = getPlayerNametagText (source) 
  local accountName = getAccountName(getPlayerAccount(source)) 
  local characterindex = getCharacterIndexByCharacterName (accountName,charactername) 
  if (characterindex) then 
    local playerRoot = xmlFindChild (root,"player",findPlayerIndexByName (tostring(accountName))) 
    local characterRoot = xmlNodeGetChildren (playerRoot,tonumber(characterindex)-1) 
    if (characterRoot) then 
      local currentBank = xmlNodeGetAttribute (characterRoot,"bank") 
      if not (currentBank) then 
        local currentBank = nil 
        local currentBank = 0 
      end 
      if (tonumber(currentBank) >= tonumber(amount)) then 
        local newBank = tonumber (currentBank) - amount 
        givePlayerMoney (source,amount) 
        xmlNodeSetAttribute (characterRoot,"bank",newBank) 
        outputChatBox ("You Money is Wathdraw!!", source, 0, 255, 0, false) 
        local bank = xmlNodeGetAttribute (characterRoot,"bank") 
        xmlSaveFile (root) 
      else 
        outputChatBox ("You Dont have any mone in the bank Him!!", source, 0, 255, 0, false) 
        local cash = xmlNodeGetAttribute (characterRoot,"cash") 
        local bank = xmlNodeGetAttribute (characterRoot,"bank") 
        xmlSaveFile (root) 
      end 
    end 
  end 
end) 

_______________________

Bank.xml

  "-2036.83" y="140.41" z="28.83">Trainstation ATM
  "-2675.41" y="634.08" z="14.45">SF Hospital ATM
  "-1955.3544287109" y="307.355223" z="35.461">Carshop ATM
  "2619.69" y="2344.76" z="10.8">vRock ATM
  "2589.14" y="1897.5" z="11">JobZone ATM

اعتقد ان البنك ما فيه شييء صعب اصلا لني سويتو بي 30 دقيقه بظبط بس ما يشتغل ما اعرف وش الحل

ارجوكم الرد سريع :)

Link to comment
السلام عليكم اليوم حاولت اني اسوي بنك بس ما يشتغل و ما اعرف ايش المشكله ممكن حل

انا مسوي الماركرات في ملف Banks.xml فا انا راح احطو مع الكلينت و السيرفر

اول شييء:

Client Side

addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()), 
  fuction () 
  -- bank 
   
  bankWindow = guiCreateWindow(201,104,290,287,"-- BANK NAME --",false) 
  guiSetVisible (bankWindow,false) 
  bankWindowDisplay = guiCreateEdit(0.0483,0.115,0.8897,0.108,"",true,bankWindow) 
  guiEditSetReadOnly(bankWindowDisplay,true) 
  bankWindow1 = guiCreateButton(0.0793,0.2404,0.1759,0.1638,"1",true,bankWindow) 
  bankWindow2 = guiCreateButton(0.3,0.2404,0.1759,0.1638,"2",true,bankWindow) 
  bankWindow3 = guiCreateButton(0.5241,0.2404,0.1759,0.1638,"3",true,bankWindow) 
  bankWindow4 = guiCreateButton(0.0793,0.4425,0.1759,0.1638,"4",true,bankWindow) 
  bankWindow5 = guiCreateButton(0.3,0.4425,0.1759,0.1638,"5",true,bankWindow) 
  bankWindow6 = guiCreateButton(0.5241,0.4425,0.1759,0.1638,"6",true,bankWindow) 
  bankWindow7 = guiCreateButton(0.0793,0.6481,0.1759,0.1638,"7",true,bankWindow) 
  bankWindow8 = guiCreateButton(0.3034,0.6481,0.1759,0.1638,"8",true,bankWindow) 
  bankWindow9 = guiCreateButton(0.5241,0.6481,0.1759,0.1638,"9",true,bankWindow) 
  bankWindowClose = guiCreateButton(0.0793,0.8328,0.8448,0.0906,"Close",true,bankWindow) 
  bankWindowStore = guiCreateButton(0.7448,0.2404,0.1759,0.1638,"Store",true,bankWindow) 
  bankWindowWithdraw = guiCreateButton(0.7448,0.4425,0.1759,0.1638,"Withdraw",true,bankWindow) 
  bankWindow0 = guiCreateButton(0.7448,0.6481,0.1759,0.1638,"0",true,bankWindow) 
  
    enableWideScreen (getLocalPlayer()) 
  elseif (source == bankWindow1) then 
    addIntoBankEditDisplay ("1") 
  elseif (source == bankWindow2) then 
    addIntoBankEditDisplay ("2") 
  elseif (source == bankWindow3) then 
    addIntoBankEditDisplay ("3") 
  elseif (source == bankWindow4) then 
    addIntoBankEditDisplay ("4") 
  elseif (source == bankWindow5) then 
    addIntoBankEditDisplay ("5") 
  elseif (source == bankWindow6) then 
    addIntoBankEditDisplay ("6") 
  elseif (source == bankWindow7) then 
    addIntoBankEditDisplay ("7") 
  elseif (source == bankWindow8) then 
    addIntoBankEditDisplay ("8") 
  elseif (source == bankWindow9) then 
    addIntoBankEditDisplay ("9") 
  elseif (source == bankWindow0) then 
    addIntoBankEditDisplay ("0") 
  elseif (source == bankWindowClose) then 
    guiSetVisible (bankWindow,false) 
    guiSetText (bankWindowDisplay,"") 
    showCursor (false,false) 
  elseif (source == bankWindowStore) then 
    triggerServerEvent ("bankStoreMoney",getLocalPlayer(),tonumber(guiGetText(bankWindowDisplay))) 
  elseif (source == bankWindowWithdraw) then 
    triggerServerEvent ("bankWithdrawMoney",getLocalPlayer(),tonumber(guiGetText(bankWindowDisplay))) 
  end 
end) 

________________

Server Side

addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
  bankr = xmlLoadFile("banks.xml"); 
  
addEventHandler("onResourceStop",getResourceRootElement(getThisResource()), 
function () 
  xmlUnloadFile(bankr); 
end); 
  
-- BANK 
addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
  local allBanks = xmlNodeGetChildren (bankr) 
  for i,v in ipairs (allBanks) do 
    local x = xmlNodeGetAttribute (v,"x") 
    local y = xmlNodeGetAttribute (v,"y") 
    local z = xmlNodeGetAttribute (v,"z") 
    local bankname = xmlNodeGetValue  (v) 
    createBlip (x,y,z,52) 
    local atmmarker = createMarker (x,y,z-1,"cylinder",2,0,255,0,100) 
    local atm = createObject (2942,x,y+0.75,z-0.25) 
    setElementData (atmmarker,"bank",bankname) 
  end 
   
addEvent ("bankStoreMoney",true) 
addEventHandler ("bankStoreMoney",getRootElement(), 
function(amount) 
  local playerMoney = getPlayerMoney (source) 
  if (playerMoney < amount) then 
  outputChatBox ("You Don't Have any Money in The Bank!!", source, 0, 255, 0, false) 
  else 
      local currentBank = xmlNodeGetAttribute (characterRoot,"bank") 
      local newBank = tonumber (currentBank) + amount 
      setPlayerMoney (source,getPlayerMoney (source) -amount)   
      local bank = xmlNodeGetAttribute (characterRoot,"bank") 
      triggerClientEvent (source,"lolmodRefreshBankInfoMenu",source,getPlayerMoney (source),bank) 
      xmlSaveFile (root) 
    end 
  end 
end 
) 
  
addEvent ("bankWithdrawMoney",true) 
addEventHandler ("bankWithdrawMoney",getRootElement(), 
function(amount) 
  local charactername = getPlayerNametagText (source) 
  local accountName = getAccountName(getPlayerAccount(source)) 
  local characterindex = getCharacterIndexByCharacterName (accountName,charactername) 
  if (characterindex) then 
    local playerRoot = xmlFindChild (root,"player",findPlayerIndexByName (tostring(accountName))) 
    local characterRoot = xmlNodeGetChildren (playerRoot,tonumber(characterindex)-1) 
    if (characterRoot) then 
      local currentBank = xmlNodeGetAttribute (characterRoot,"bank") 
      if not (currentBank) then 
        local currentBank = nil 
        local currentBank = 0 
      end 
      if (tonumber(currentBank) >= tonumber(amount)) then 
        local newBank = tonumber (currentBank) - amount 
        givePlayerMoney (source,amount) 
        xmlNodeSetAttribute (characterRoot,"bank",newBank) 
        outputChatBox ("You Money is Wathdraw!!", source, 0, 255, 0, false) 
        local bank = xmlNodeGetAttribute (characterRoot,"bank") 
        xmlSaveFile (root) 
      else 
        outputChatBox ("You Dont have any mone in the bank Him!!", source, 0, 255, 0, false) 
        local cash = xmlNodeGetAttribute (characterRoot,"cash") 
        local bank = xmlNodeGetAttribute (characterRoot,"bank") 
        xmlSaveFile (root) 
      end 
    end 
  end 
end) 

_______________________

Bank.xml

  "-2036.83" y="140.41" z="28.83">Trainstation ATM
  "-2675.41" y="634.08" z="14.45">SF Hospital ATM
  "-1955.3544287109" y="307.355223" z="35.461">Carshop ATM
  "2619.69" y="2344.76" z="10.8">vRock ATM
  "2589.14" y="1897.5" z="11">JobZone ATM

اعتقد ان البنك ما فيه شييء صعب اصلا لني سويتو بي 30 دقيقه بظبط بس ما يشتغل ما اعرف وش الحل

ارجوكم الرد سريع :)

؟ account data او sql و ليه ماتعملوش بأستخدام

يكون احسن و تقل الاخطاء

Link to comment
السلام عليكم اليوم حاولت اني اسوي بنك بس ما يشتغل و ما اعرف ايش المشكله ممكن حل

انا مسوي الماركرات في ملف Banks.xml فا انا راح احطو مع الكلينت و السيرفر

اول شييء:

Client Side

addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()), 
  fuction () 
  -- bank 
   
  bankWindow = guiCreateWindow(201,104,290,287,"-- BANK NAME --",false) 
  guiSetVisible (bankWindow,false) 
  bankWindowDisplay = guiCreateEdit(0.0483,0.115,0.8897,0.108,"",true,bankWindow) 
  guiEditSetReadOnly(bankWindowDisplay,true) 
  bankWindow1 = guiCreateButton(0.0793,0.2404,0.1759,0.1638,"1",true,bankWindow) 
  bankWindow2 = guiCreateButton(0.3,0.2404,0.1759,0.1638,"2",true,bankWindow) 
  bankWindow3 = guiCreateButton(0.5241,0.2404,0.1759,0.1638,"3",true,bankWindow) 
  bankWindow4 = guiCreateButton(0.0793,0.4425,0.1759,0.1638,"4",true,bankWindow) 
  bankWindow5 = guiCreateButton(0.3,0.4425,0.1759,0.1638,"5",true,bankWindow) 
  bankWindow6 = guiCreateButton(0.5241,0.4425,0.1759,0.1638,"6",true,bankWindow) 
  bankWindow7 = guiCreateButton(0.0793,0.6481,0.1759,0.1638,"7",true,bankWindow) 
  bankWindow8 = guiCreateButton(0.3034,0.6481,0.1759,0.1638,"8",true,bankWindow) 
  bankWindow9 = guiCreateButton(0.5241,0.6481,0.1759,0.1638,"9",true,bankWindow) 
  bankWindowClose = guiCreateButton(0.0793,0.8328,0.8448,0.0906,"Close",true,bankWindow) 
  bankWindowStore = guiCreateButton(0.7448,0.2404,0.1759,0.1638,"Store",true,bankWindow) 
  bankWindowWithdraw = guiCreateButton(0.7448,0.4425,0.1759,0.1638,"Withdraw",true,bankWindow) 
  bankWindow0 = guiCreateButton(0.7448,0.6481,0.1759,0.1638,"0",true,bankWindow) 
  
    enableWideScreen (getLocalPlayer()) 
  elseif (source == bankWindow1) then 
    addIntoBankEditDisplay ("1") 
  elseif (source == bankWindow2) then 
    addIntoBankEditDisplay ("2") 
  elseif (source == bankWindow3) then 
    addIntoBankEditDisplay ("3") 
  elseif (source == bankWindow4) then 
    addIntoBankEditDisplay ("4") 
  elseif (source == bankWindow5) then 
    addIntoBankEditDisplay ("5") 
  elseif (source == bankWindow6) then 
    addIntoBankEditDisplay ("6") 
  elseif (source == bankWindow7) then 
    addIntoBankEditDisplay ("7") 
  elseif (source == bankWindow8) then 
    addIntoBankEditDisplay ("8") 
  elseif (source == bankWindow9) then 
    addIntoBankEditDisplay ("9") 
  elseif (source == bankWindow0) then 
    addIntoBankEditDisplay ("0") 
  elseif (source == bankWindowClose) then 
    guiSetVisible (bankWindow,false) 
    guiSetText (bankWindowDisplay,"") 
    showCursor (false,false) 
  elseif (source == bankWindowStore) then 
    triggerServerEvent ("bankStoreMoney",getLocalPlayer(),tonumber(guiGetText(bankWindowDisplay))) 
  elseif (source == bankWindowWithdraw) then 
    triggerServerEvent ("bankWithdrawMoney",getLocalPlayer(),tonumber(guiGetText(bankWindowDisplay))) 
  end 
end) 

________________

Server Side

addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
  bankr = xmlLoadFile("banks.xml"); 
  
addEventHandler("onResourceStop",getResourceRootElement(getThisResource()), 
function () 
  xmlUnloadFile(bankr); 
end); 
  
-- BANK 
addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
  local allBanks = xmlNodeGetChildren (bankr) 
  for i,v in ipairs (allBanks) do 
    local x = xmlNodeGetAttribute (v,"x") 
    local y = xmlNodeGetAttribute (v,"y") 
    local z = xmlNodeGetAttribute (v,"z") 
    local bankname = xmlNodeGetValue  (v) 
    createBlip (x,y,z,52) 
    local atmmarker = createMarker (x,y,z-1,"cylinder",2,0,255,0,100) 
    local atm = createObject (2942,x,y+0.75,z-0.25) 
    setElementData (atmmarker,"bank",bankname) 
  end 
   
addEvent ("bankStoreMoney",true) 
addEventHandler ("bankStoreMoney",getRootElement(), 
function(amount) 
  local playerMoney = getPlayerMoney (source) 
  if (playerMoney < amount) then 
  outputChatBox ("You Don't Have any Money in The Bank!!", source, 0, 255, 0, false) 
  else 
      local currentBank = xmlNodeGetAttribute (characterRoot,"bank") 
      local newBank = tonumber (currentBank) + amount 
      setPlayerMoney (source,getPlayerMoney (source) -amount)   
      local bank = xmlNodeGetAttribute (characterRoot,"bank") 
      triggerClientEvent (source,"lolmodRefreshBankInfoMenu",source,getPlayerMoney (source),bank) 
      xmlSaveFile (root) 
    end 
  end 
end 
) 
  
addEvent ("bankWithdrawMoney",true) 
addEventHandler ("bankWithdrawMoney",getRootElement(), 
function(amount) 
  local charactername = getPlayerNametagText (source) 
  local accountName = getAccountName(getPlayerAccount(source)) 
  local characterindex = getCharacterIndexByCharacterName (accountName,charactername) 
  if (characterindex) then 
    local playerRoot = xmlFindChild (root,"player",findPlayerIndexByName (tostring(accountName))) 
    local characterRoot = xmlNodeGetChildren (playerRoot,tonumber(characterindex)-1) 
    if (characterRoot) then 
      local currentBank = xmlNodeGetAttribute (characterRoot,"bank") 
      if not (currentBank) then 
        local currentBank = nil 
        local currentBank = 0 
      end 
      if (tonumber(currentBank) >= tonumber(amount)) then 
        local newBank = tonumber (currentBank) - amount 
        givePlayerMoney (source,amount) 
        xmlNodeSetAttribute (characterRoot,"bank",newBank) 
        outputChatBox ("You Money is Wathdraw!!", source, 0, 255, 0, false) 
        local bank = xmlNodeGetAttribute (characterRoot,"bank") 
        xmlSaveFile (root) 
      else 
        outputChatBox ("You Dont have any mone in the bank Him!!", source, 0, 255, 0, false) 
        local cash = xmlNodeGetAttribute (characterRoot,"cash") 
        local bank = xmlNodeGetAttribute (characterRoot,"bank") 
        xmlSaveFile (root) 
      end 
    end 
  end 
end) 

_______________________

Bank.xml

  "-2036.83" y="140.41" z="28.83">Trainstation ATM
  "-2675.41" y="634.08" z="14.45">SF Hospital ATM
  "-1955.3544287109" y="307.355223" z="35.461">Carshop ATM
  "2619.69" y="2344.76" z="10.8">vRock ATM
  "2589.14" y="1897.5" z="11">JobZone ATM

اعتقد ان البنك ما فيه شييء صعب اصلا لني سويتو بي 30 دقيقه بظبط بس ما يشتغل ما اعرف وش الحل

ارجوكم الرد سريع :)

؟ account data او sql و ليه ماتعملوش بأستخدام

يكون احسن و تقل الاخطاء

مينفعش لني مقدرش اعمل account data لني لسا مبتداء البرمجه :D

Link to comment

اعتقد ان البنك ما فيه شييء صعب اصلا لني سويتو بي 30 دقيقه بظبط بس ما يشتغل ما اعرف وش الحل

؟؟

:mrgreen:

30 دقيقة ؟

انا لما اسوي مود اخد به ساعه ونص

+ المود حق تابل ومنشور :lol:

Link to comment

اعتقد ان البنك ما فيه شييء صعب اصلا لني سويتو بي 30 دقيقه بظبط بس ما يشتغل ما اعرف وش الحل

؟؟

:mrgreen:

30 دقيقة ؟

انا لما اسوي مود اخد به ساعه ونص

+ المود حق تابل ومنشور :lol:

خخخخخخخخخخخخخخخخخخخخخخ مين الي تابل انا موت لحد لما سويت الاكواد و فعلت يسحب الفلوس و يحفظ الفلو في البنك يا اخوي خذ اكواداو و صلحها و جرب شغلو و شوف شكلووووووو خخخخخخخخخخخخخ تقلي حق تابل

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