Advertisement
Shiranuit

ATM_Startup

Apr 17th, 2016
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 42.39 KB | None | 0 0
  1. ---------------------------------------------------------------------
  2. --                                                                 --
  3. --                   Programme de Shiranuit                        --
  4. --                                                                 --
  5. ---------------------------------------------------------------------
  6. -- APIS
  7. os.pullEvent = os.pullEventRaw
  8. os.loadAPI("InterfaceApi")
  9. os.loadAPI("NetSphere")
  10.  
  11. local h = http.get("http://pastebin.com/raw/9mQiK4PX")
  12. local DerniereVersion = textutils.unserialise(h.readAll())
  13. h.close()
  14.  
  15. local MaVersion = {["ATM"]=0}
  16. if fs.exists("Version") then
  17.     local h = fs.open("Version","r")
  18.     MaVersion = textutils.unserialise(h.readAll())
  19.     h.close()
  20. end
  21.  
  22. if MaVersion["ATM"] ~= DerniereVersion["ATM"] then
  23.     fs.delete("install")
  24.     shell.run("pastebin get SygpH4ub install")
  25.     shell.run("install")
  26. end
  27.  
  28. --OUVERTURE MODEM
  29.  
  30. while true do
  31. local modem = peripheral.find("modem",function(name,object) return object.isWireless() end)
  32.     if modem then
  33.         modem.open(os.getComputerID())
  34.         modem.open(65535)
  35.         break
  36.     else
  37.         shell.run("clear")
  38.         print("Veuillez placer un modem quelque part !")
  39.         os.pullEvent("peripheral")
  40.     end
  41. end
  42. function Isnull(info)
  43.     if info == nil then
  44.         return true
  45.     else
  46.         return false
  47.     end
  48. end
  49.  
  50. local IDTerminal = 50
  51. while true do
  52.     local r = rednet.lookup("Serveur_Banque","Serveur_Banque")
  53.     if r == nil then
  54.         shell.run("clear")
  55.         print("Appuyer sur une touche un fois le serveur allumer !")
  56.         os.pullEvent()
  57.     else
  58.         IDTerminal = r
  59.         break
  60.     end
  61. end
  62.  
  63. function send(id, texte)
  64.     NetSphere.send(id, texte)
  65. end
  66. --DECLARATION DE VARIABLES
  67. local width, height = term.getSize()
  68. local psd = ""
  69. local motdepasse = ""
  70. local CompteValider=false
  71. local historique = {}
  72. local solde = 0
  73. local Action="Connection"
  74. local nomTransfer = ""
  75. local sommeTransfer = 0
  76. local nEntreprise = ""
  77. local entreprises = {}
  78. local psdPlayer = ""
  79. local membres = {}
  80. local esolde = 0
  81. local ehistorique = {}
  82. local sommeTransferE = 0
  83. local statut = "PLAYER"
  84. local nCompteMO = ""
  85. local nSommeMO = 0
  86. local nPercentTransfersMO = 0
  87. local nATMIdMO = 0
  88. local nATMIDTransfersMO = 0
  89. local nMdpMO = ""
  90. local mAMdp = ""
  91. local mNMdp = ""
  92. local ComponmentList = {}
  93. local ListeComptes = {}
  94. --COMPOSANTS
  95. -- Menu Connection
  96. ComponmentList["PseudoTxtBoxMC"] = InterfaceApi.AddTextBox("PseudoTxtBoxMC",11,8,29,1,colors.yellow,colors.gray," Pseudo : ","",nil,{},nil)
  97. ComponmentList["MdpTxtBoxMC"] = InterfaceApi.AddTextBox("MdpTxtBoxMC",11,11,29,1,colors.yellow,colors.gray,"   Code : ","","*",{},ComponmentList["PseudoTxtBoxMC"])
  98. ComponmentList["PseudoTxtBoxMC"].TabComponment(ComponmentList["MdpTxtBoxMC"])
  99. ComponmentList["EffacerMC"] = InterfaceApi.AddBoutton("AnnulerMC",11,13,12,1,colors.yellow,colors.red,"Effacer")
  100. ComponmentList["ValiderMC"] = InterfaceApi.AddBoutton("ValiderMC",28,13,12,1,colors.yellow,colors.green,"Valider")
  101. ComponmentList["MenuConnection"] = InterfaceApi.AddFormSkin("MenuConnection",1,1,width,height,colors.yellow,colors.black,colors.gray,"[HelixProject] vous souhaite la bienvenue",false,{ComponmentList["PseudoTxtBoxMC"],ComponmentList["MdpTxtBoxMC"],ComponmentList["EffacerMC"],ComponmentList["ValiderMC"]})
  102. -- Menu Principal
  103. ComponmentList["TransfertMP"] = InterfaceApi.AddBoutton("TransfertMP",2,4,12,1,colors.yellow,colors.gray,"Transférer")
  104. ComponmentList["EntreprisesMP"] = InterfaceApi.AddBoutton("EntreprisesMP",2,6,12,1,colors.yellow,colors.gray,"Entreprises")
  105. ComponmentList["CleMP"] = InterfaceApi.AddBoutton("CleMP",2,8,12,1,colors.yellow,colors.gray,"Menu Clé")
  106. ComponmentList["OpMP"] = InterfaceApi.AddBoutton("OpMP",2,10,12,1,colors.yellow,colors.gray,"Menu OP")
  107. ComponmentList["LabelHistoriqueMP"] = InterfaceApi.AddLabel("LabelHistoriqueMP",15,4,colors.yellow,colors.lightGray," Historique de transactions :    ")
  108. ComponmentList["HistoriqueListBoxMP"] = InterfaceApi.AddListBox("HistoriqueListBoxMP",15,5,33,11,colors.yellow,colors.gray,colors.gray,colors.green,{},true,1,1)
  109. ComponmentList["ModifmdpMP"] = InterfaceApi.AddBoutton("ModifmdpMP",2,17,11,1,colors.yellow,colors.gray,"Modif Mdp")
  110. ComponmentList["EffHistoriqueMP"] = InterfaceApi.AddBoutton("EffHistoriqueMP",14,17,10,1,colors.yellow,colors.gray,"Effacer")
  111. ComponmentList["RecupHistoriqueMP"] = InterfaceApi.AddBoutton("RecupHistoriqueMP",25,17,11,1,colors.yellow,colors.gray,"Recuperer")
  112. ComponmentList["DeconnectionMP"] = InterfaceApi.AddBoutton("DeconnectionMP",37,17,11,1,colors.yellow,colors.red,"Quitter")
  113. ComponmentList["MenuPrincipal"] = InterfaceApi.AddFormSkin("MenuPrincipal",1,1,width,height,colors.yellow,colors.black,colors.gray,"",false,{ComponmentList["CleMP"],ComponmentList["TransfertMP"],ComponmentList["EntreprisesMP"],ComponmentList["OpMP"],ComponmentList["LabelHistoriqueMP"],ComponmentList["HistoriqueListBoxMP"],ComponmentList["ModifmdpMP"],ComponmentList["EffHistoriqueMP"],ComponmentList["RecupHistoriqueMP"],ComponmentList["DeconnectionMP"]})
  114. ComponmentList["OpMP"].Visible(false)
  115. --Menu Transfert
  116. ComponmentList["CompteTxtBoxMT"] = InterfaceApi.AddTextBox("CompteTxtBoxMT",4,3,35,1,colors.yellow,colors.gray,"Compte : ","",nil,{},nil)
  117. ComponmentList["SommeNumericUpDownMT"] = InterfaceApi.AddNumericUpDown("SommeNumericUpDownMT",40,3,9,1,colors.yellow,colors.gray,0,100,0,1,ComponmentList["CompteTxtBoxMT"])
  118. ComponmentList["CompteTxtBoxMT"].TabComponment(ComponmentList["SommeNumericUpDownMT"])
  119. ComponmentList["LabelHistoriqueMT"] = InterfaceApi.AddLabel("LabelHistoriqueMT",4,5,colors.yellow,colors.lightGray," Historique de transactions :      ")
  120. ComponmentList["HistoriqueListBoxMT"] = InterfaceApi.AddListBox("HistoriqueListBoxMT",4,6,35,12,colors.yellow,colors.gray,colors.gray,colors.green,{},true,1,1)
  121. ComponmentList["ValiderMT"] = InterfaceApi.AddBoutton("ValiderMT",40,5,9,1,colors.yellow,colors.green,"Valider")
  122. ComponmentList["EffacerMT"] = InterfaceApi.AddBoutton("EffacerMT",40,15,9,1,colors.yellow,colors.blue,"Effacer")
  123. ComponmentList["RetourMT"] = InterfaceApi.AddBoutton("RetourMT",40,17,9,1,colors.yellow,colors.red,"Retour")
  124. ComponmentList["MenuTransfert"] = InterfaceApi.AddFormSkin("MenuTransfert",1,1,width,height,colors.yellow,colors.black,colors.gray,"",false,{ComponmentList["CompteTxtBoxMT"],ComponmentList["SommeNumericUpDownMT"],ComponmentList["LabelHistoriqueMT"],ComponmentList["HistoriqueListBoxMT"],ComponmentList["ValiderMT"],ComponmentList["EffacerMT"],ComponmentList["RetourMT"]})
  125. -- Menu Entreprises :
  126. -- Menu Entreprise Principal
  127. ComponmentList["CreeEntrepriseME"] = InterfaceApi.AddBoutton("CreeEntrepriseME",2,4,20,1,colors.yellow,colors.gray,"Créer Entreprise")
  128. ComponmentList["SupprEntrepriseME"] = InterfaceApi.AddBoutton("SupprEntrepriseME",2,6,20,1,colors.yellow,colors.gray,"Retirer Entreprise")
  129. ComponmentList["GererMembresME"] = InterfaceApi.AddBoutton("GererMembresME",2,8,20,1,colors.yellow,colors.gray,"Gerer Membres")
  130. ComponmentList["GererTransfertME"] = InterfaceApi.AddBoutton("GererTransfertME",2,10,20,1,colors.yellow,colors.gray,"Gerer Transferts")
  131. ComponmentList["RetourME"] = InterfaceApi.AddBoutton("RetourME",40,17,9,1,colors.yellow,colors.red,"Retour")
  132. ComponmentList["EntrepriseTxtBoxME"] = InterfaceApi.AddTextBox("EntrepriseTxtBoxME",2,12,20,1,colors.yellow,colors.gray," Nom : ","",nil,{},nil)
  133. ComponmentList["EntrepriseListBoxME"] = InterfaceApi.AddListBox("EntrepriseListBoxME",24,4,25,12,colors.yellow,colors.gray,colors.gray,colors.red,{},true,1,1)
  134. ComponmentList["MenuEntreprise"] = InterfaceApi.AddFormSkin("MenuEntreprise",1,1,width,height,colors.yellow,colors.black,colors.gray,"Panneau de gestion des entreprises",false,{ComponmentList["CreeEntrepriseME"],ComponmentList["SupprEntrepriseME"],ComponmentList["GererMembresME"],ComponmentList["GererTransfertME"],ComponmentList["RetourME"],ComponmentList["EntrepriseTxtBoxME"],ComponmentList["EntrepriseListBoxME"]})
  135. -- Menu Entreprise Gestion Membres
  136. ComponmentList["EntrepriseAddMembreMEGM"] = InterfaceApi.AddBoutton("CreeEntrepriseMEGM",2,4,20,1,colors.yellow,colors.gray,"Ajouter Membre")
  137. ComponmentList["EntrepriseSupprMembreMEGM"] = InterfaceApi.AddBoutton("CreeEntrepriseMEGM",2,6,20,1,colors.yellow,colors.gray,"Retirer Membre")
  138. ComponmentList["EntreprisePermMembreMEGM"] = InterfaceApi.AddBoutton("CreeEntrepriseMEGM",2,8,20,1,colors.yellow,colors.gray,"Permissions Membre")
  139. ComponmentList["EntrepriseTxtBoxMEGM"] = InterfaceApi.AddTextBox("EntrepriseTxtBoxMEGM",2,10,20,1,colors.yellow,colors.gray," Nom : ","",nil,{},nil)
  140. ComponmentList["EntrepriseMembreListBoxMEGM"] = InterfaceApi.AddListBox("EntrepriseMembreListBoxMEGM",24,4,25,12,colors.yellow,colors.gray,colors.gray,colors.green,{},true,1,1)
  141. ComponmentList["RetourMEGM"] = InterfaceApi.AddBoutton("RetourMEGM",40,17,9,1,colors.yellow,colors.red,"Retour")
  142. ComponmentList["MenuEntrepriseGestionMembre"] = InterfaceApi.AddFormSkin("MenuEntrepriseGestionMembre",1,1,width,height,colors.yellow,colors.black,colors.gray,"",false,{ComponmentList["EntrepriseAddMembreMEGM"],ComponmentList["EntrepriseSupprMembreMEGM"],ComponmentList["EntreprisePermMembreMEGM"],ComponmentList["EntrepriseTxtBoxMEGM"],ComponmentList["EntrepriseMembreListBoxMEGM"],ComponmentList["RetourMEGM"]})
  143. -- Menu Entreprise Gestion Transferts
  144. ComponmentList["EntrepriseCreditMEGT"] = InterfaceApi.AddBoutton("EntrepriseCreditMEGT",4,3,14,1,colors.yellow,colors.gray,"Créditer")
  145. ComponmentList["EntrepriseDebitMEGT"] = InterfaceApi.AddBoutton("EntrepriseDebitMEGT",24,3,15,1,colors.yellow,colors.gray,"Débiter")
  146. ComponmentList["RetourMEGT"] = InterfaceApi.AddBoutton("RetourMEGT",40,17,9,1,colors.yellow,colors.red,"Retour")
  147. ComponmentList["SommeNumericUpDownMEGT"] = InterfaceApi.AddNumericUpDown("SommeNumericUpDownMEGT",40,3,9,1,colors.yellow,colors.gray,0,100,0,1,nil)
  148. ComponmentList["LabelHistoriqueMT"] = InterfaceApi.AddLabel("LabelHistoriqueMT",4,5,colors.yellow,colors.lightGray," Historique de transactions :      ")
  149. ComponmentList["HistoriqueListBoxMEGT"] = InterfaceApi.AddListBox("HistoriqueListBoxMEGT",4,6,35,12,colors.yellow,colors.gray,colors.gray,colors.green,{},true,1,1)
  150. ComponmentList["MenuEntrepriseGestionTranfert"] = InterfaceApi.AddFormSkin("MenuEntrepriseGestionTranfert",1,1,width,height,colors.yellow,colors.black,colors.gray,"",false,{ComponmentList["EntrepriseCreditMEGT"],ComponmentList["EntrepriseDebitMEGT"],ComponmentList["RetourMEGT"],ComponmentList["SommeNumericUpDownMEGT"],ComponmentList["LabelHistoriqueMT"],ComponmentList["HistoriqueListBoxMEGT"]})
  151. -- Menu Entreprise Gestion Permissions Membres
  152. ComponmentList["PermDelEntreprise"] = InterfaceApi.AddCheckBox("PermDelEntreprise",3,2,50,1,colors.yellow,colors.black,colors.green,colors.red,"Permission de supprimer l'entreprise : ",false)
  153. ComponmentList["PermDepos"] = InterfaceApi.AddCheckBox("PermDepos",3,4,50,1,colors.yellow,colors.black,colors.green,colors.red,"Permission de déposer de l'argent : ",false)
  154. ComponmentList["PermRetrait"] = InterfaceApi.AddCheckBox("PermRetrait",3,6,50,1,colors.yellow,colors.black,colors.green,colors.red,"Permission de retirer de l'argent : ",false)
  155. ComponmentList["PermDelMembre"] = InterfaceApi.AddCheckBox("PermDelMembre",3,8,50,1,colors.yellow,colors.black,colors.green,colors.red,"Permission de supprimer un membre : ",false)
  156. ComponmentList["PermModif"] = InterfaceApi.AddCheckBox("PermModif",3,10,50,1,colors.yellow,colors.black,colors.green,colors.red,"Permission de modifier les permissions : ",false)
  157. ComponmentList["PermAddMembre"] = InterfaceApi.AddCheckBox("PermAddMembre",3,12,50,1,colors.yellow,colors.black,colors.green,colors.red,"Permission d'ajouter un membre : ",false)
  158. ComponmentList["ValiderMEGPM"] = InterfaceApi.AddBoutton("ValiderMEGPM",28,17,9,1,colors.yellow,colors.green,"Valider")
  159. ComponmentList["RetourMEGPM"] = InterfaceApi.AddBoutton("RetourMEGPM",40,17,9,1,colors.yellow,colors.red,"Retour")
  160. ComponmentList["MenuEntrepriseGestionPermissionMembre"] = InterfaceApi.AddFormSkin("MenuEntrepriseGestionPermissionMembre",1,1,width,height,colors.yellow,colors.black,colors.gray,"",false,{ComponmentList["PermAddMembre"],ComponmentList["PermModif"],ComponmentList["PermDelMembre"],ComponmentList["PermRetrait"],ComponmentList["PermDelEntreprise"],ComponmentList["PermDepos"],ComponmentList["RetourMEGPM"],ComponmentList["ValiderMEGPM"]})
  161. -- Menu OP
  162. ComponmentList["AddCompteMO"] = InterfaceApi.AddBoutton("AddCompteMO",2,4,20,1,colors.yellow,colors.gray,"Ajouter Compte")
  163. ComponmentList["SupprCompteMO"] = InterfaceApi.AddBoutton("SupprCompteMO",2,6,20,1,colors.yellow,colors.gray,"Supprimer Compte")
  164. ComponmentList["GiveMonneyMO"] = InterfaceApi.AddBoutton("GiveMonneyMO",2,8,20,1,colors.yellow,colors.gray,"Donner Argent")
  165. ComponmentList["StealMonneyMO"] = InterfaceApi.AddBoutton("StealMonneyMO",2,10,20,1,colors.yellow,colors.gray,"Retirer Argent")
  166. ComponmentList["AddPercentMO"] = InterfaceApi.AddBoutton("AddPercentMO",2,12,20,1,colors.yellow,colors.gray,"Donner a * un %")
  167. ComponmentList["StealPercentMO"] = InterfaceApi.AddBoutton("StealPercentMO",2,14,20,1,colors.yellow,colors.gray,"Retirer a * un %")
  168. ComponmentList["ListeComptesMO"] = InterfaceApi.AddBoutton("ListeComptesMO",2,16,20,1,colors.yellow,colors.gray,"Liste des Comptes")
  169. ComponmentList["AddATMMO"] = InterfaceApi.AddBoutton("AddATMMO",2,18,9,1,colors.yellow,colors.gray,"Add ATM")
  170. ComponmentList["DelATMMO"] = InterfaceApi.AddBoutton("DelATMMO",12,18,10,1,colors.yellow,colors.gray,"Del ATM")
  171. ComponmentList["CompteTxtBoxMO"] = InterfaceApi.AddTextBox("CompteTxtBoxMO",23,4,25,1,colors.yellow,colors.gray," Compte : ","",nil,{},nil)
  172. ComponmentList["LabelSommeMO"] = InterfaceApi.AddLabel("LabelSommeMO",23,6,colors.yellow,colors.gray," Somme : ")
  173. ComponmentList["SommeNumericUpDownMO"] = InterfaceApi.AddNumericUpDown("SommeNumericUpDownMO",32,6,16,1,colors.yellow,colors.gray,0,9999999999,0,1,nil)
  174. ComponmentList["LabelPercentMO"] = InterfaceApi.AddLabel("LabelPercentMO",23,8,colors.yellow,colors.gray," % : ")
  175. ComponmentList["PercentNumericUpDownMO"] = InterfaceApi.AddNumericUpDown("PercentNumericUpDownMO",28,8,20,1,colors.yellow,colors.gray,0,9999999999,0,1,nil)
  176. ComponmentList["MdpTxtBoxMO"] = InterfaceApi.AddTextBox("MdpTxtBoxMO",23,10,25,1,colors.yellow,colors.gray," Mdp : ","",nil,{},nil)
  177. ComponmentList["ModifMdpMO"] = InterfaceApi.AddBoutton("ModifMdpMO",23,12,25,1,colors.yellow,colors.gray,"Changer le Mot de passe")
  178. ComponmentList["MakeOPMO"] = InterfaceApi.AddBoutton("MakeOPMO",23,14,12,1,colors.yellow,colors.gray,"Set OP")
  179. ComponmentList["MakePlayerMO"] = InterfaceApi.AddBoutton("MakePlayerMO",37,14,11,1,colors.yellow,colors.gray,"Set PLAYER")
  180. ComponmentList["HistoriqueMO"] = InterfaceApi.AddBoutton("HistoriqueMO",23,16,12,1,colors.yellow,colors.gray,"Historique")
  181. ComponmentList["RetourMO"] = InterfaceApi.AddBoutton("RetourMO",37,16,11,1,colors.yellow,colors.red,"Retour")
  182. ComponmentList["TerminateMO"] = InterfaceApi.AddBoutton("TerminateMO",48,16,1,1,colors.yellow,colors.blue,"S")
  183. ComponmentList["IDATMMO"] = InterfaceApi.AddNumericUpDown("IDATMMO",23,18,25,1,colors.yellow,colors.gray,0,9999999999,0,1,nil)
  184. ComponmentList["MenuOperateur"] = InterfaceApi.AddFormSkin("MenuOperateur",1,1,width,height,colors.yellow,colors.black,colors.gray,"[HelixProject] Bienvenue dans le Menu OP",false,{ComponmentList["AddCompteMO"],ComponmentList["SupprCompteMO"],ComponmentList["GiveMonneyMO"],ComponmentList["StealMonneyMO"],ComponmentList["AddPercentMO"],ComponmentList["StealPercentMO"],ComponmentList["ListeComptesMO"],ComponmentList["AddATMMO"],ComponmentList["DelATMMO"],ComponmentList["CompteTxtBoxMO"],ComponmentList["LabelSommeMO"],ComponmentList["SommeNumericUpDownMO"],ComponmentList["LabelPercentMO"],ComponmentList["PercentNumericUpDownMO"],ComponmentList["MdpTxtBoxMO"],ComponmentList["ModifMdpMO"],ComponmentList["MakeOPMO"],ComponmentList["MakePlayerMO"],ComponmentList["HistoriqueMO"],ComponmentList["RetourMO"],ComponmentList["TerminateMO"],ComponmentList["IDATMMO"]})
  185. -- Menu Modif Mdp
  186. ComponmentList["AMdpTxtBoxMM"] = InterfaceApi.AddTextBox("AMdpTxtBoxMM",6,6,40,1,colors.yellow,colors.gray," Ancien Mdp : ","","*",{},nil)
  187. ComponmentList["NMdpTxtBoxMM"] = InterfaceApi.AddTextBox("NMdpTxtBoxMM",6,8,40,1,colors.yellow,colors.gray," Nouveau Mdp : ","","*",{},nil)
  188. ComponmentList["ChangerMdpMM"] = InterfaceApi.AddBoutton("ChangerMdpMM",6,10,18,1,colors.yellow,colors.green,"Changer le Mdp")
  189. ComponmentList["RetourMM"] = InterfaceApi.AddBoutton("RetourMM",29,10,17,1,colors.yellow,colors.red,"Retour")
  190. ComponmentList["MenuModifMDP"] = InterfaceApi.AddFormSkin("MenuModifMDP",1,1,width,height,colors.yellow,colors.black,colors.gray,"[HelixProject] Modifier votre Mot de passe :",false,{ComponmentList["AMdpTxtBoxMM"],ComponmentList["NMdpTxtBoxMM"],ComponmentList["ChangerMdpMM"],ComponmentList["RetourMM"]})
  191. -- Menu Clé
  192. ComponmentList["RetourMC"] = InterfaceApi.AddBoutton("RetourMC",40,17,9,1,colors.yellow,colors.red,"Retour")
  193. ComponmentList["CleMC"] = InterfaceApi.AddTextBox("CleMC",4,3,35,1,colors.yellow,colors.gray,"Cle : ","",nil,{},nil)
  194. ComponmentList["SommeNumericUpDownMC"] = InterfaceApi.AddNumericUpDown("SommeNumericUpDownMC",40,3,9,1,colors.yellow,colors.gray,0,100,0,1,nil)
  195. ComponmentList["GenererMC"] = InterfaceApi.AddBoutton("GenererMC",4,5,17,1,colors.yellow,colors.green,"Generer une Clé")
  196. ComponmentList["UtiliserMC"] = InterfaceApi.AddBoutton("UtiliserMC",22,5,17,1,colors.yellow,colors.green,"Utiliser une Clé")
  197. ComponmentList["MenuMC"] = InterfaceApi.AddFormSkin("MenuMC",1,1,width,height,colors.yellow,colors.black,colors.gray,"Géneration de clés de transactions",false,{ComponmentList["RetourMC"],ComponmentList["CleMC"],ComponmentList["SommeNumericUpDownMC"],ComponmentList["GenererMC"],ComponmentList["UtiliserMC"]})
  198.  
  199. function HaveAModem()
  200.     while true do
  201.         local event, side = os.pullEvent("peripheral_detach")
  202.         local f = peripheral.find("modem",function(name, object) return object.isWireless() end)
  203.         if not f or #f == 0 then
  204.             os.reboot()
  205.         end
  206.     end
  207. end
  208.  
  209. function Deconnection()
  210.     ComponmentList["CleMC"].Texte("")
  211.     ComponmentList["SommeNumericUpDownMC"].Valeur(0)
  212.     info = {Act="Deconnection"}
  213.     infos = textutils.serialise(info)
  214.     send(IDTerminal,infos)
  215. end
  216.  
  217. function updateInfo()
  218.     info = {Act="ActualiserC",Proprio=psd}
  219.     infos = textutils.serialise(info)
  220.     send(IDTerminal, infos)
  221.     shell.run("clear")
  222.     while true do
  223.         event = os.pullEvent()
  224.         if event == "updateInfoReceive" then
  225.             break
  226.         end
  227.     end
  228. end
  229.  
  230. function updateInfoE()
  231.     info = {Act="ActualiserE",Entreprise=nEntreprise}
  232.     infos = textutils.serialise(info)
  233.     send(IDTerminal, infos)
  234. end
  235.  
  236. function replace(texte,mot,apres)
  237.     if string.find(texte,mot) then
  238.         return string.gsub(texte, mot, apres)
  239.     else
  240.         return texte
  241.     end
  242. end
  243.  
  244. function MenuAff()
  245.     ComponmentList["MenuConnection"].Hide()
  246.     ComponmentList["MenuPrincipal"].Hide()
  247.     ComponmentList["MenuTransfert"].Hide()
  248.     ComponmentList["MenuEntreprise"].Hide()
  249.     ComponmentList["MenuEntrepriseGestionMembre"].Hide()
  250.     ComponmentList["MenuEntrepriseGestionTranfert"].Hide()
  251.     ComponmentList["MenuOperateur"].Hide()
  252.     ComponmentList["MenuModifMDP"].Hide()
  253.     ComponmentList["MenuEntrepriseGestionPermissionMembre"].Hide()
  254.     ComponmentList["MenuMC"].Hide()
  255.     if Action == "Connection" then
  256.         InterfaceApi.set(ComponmentList["PseudoTxtBoxMC"].Nom(),"Texte",psd)
  257.         InterfaceApi.set(ComponmentList["MdpTxtBoxMC"].Nom(),"Texte",motdepasse)
  258.         ComponmentList["MenuConnection"].Show()
  259.     elseif Action == "MenuPrincipal" then
  260.         InterfaceApi.set(ComponmentList["HistoriqueListBoxMP"].Nom(),"Liste",historique)
  261.         ComponmentList["MenuPrincipal"].Texte("Bienvenue "..psd..", Votre Solde : "..solde)
  262.         ComponmentList["MenuPrincipal"].Show()
  263.         if statut == "OP" then
  264.             ComponmentList["OpMP"].Visible(true)
  265.         else
  266.             ComponmentList["OpMP"].Visible(false)
  267.         end
  268.         ComponmentList["MenuPrincipal"].Refresh()
  269.     elseif Action == "MenuTransfers" then
  270.         InterfaceApi.set(ComponmentList["CompteTxtBoxMT"].Nom(),"Texte",nomTransfer)
  271.         InterfaceApi.set(ComponmentList["SommeNumericUpDownMT"].Nom(),"Maximum",solde)
  272.         InterfaceApi.set(ComponmentList["SommeNumericUpDownMT"].Nom(),"Valeur",sommeTransfer)
  273.         InterfaceApi.set(ComponmentList["HistoriqueListBoxMT"].Nom(),"Liste",historique)
  274.         ComponmentList["MenuTransfert"].Texte("Votre Solde : "..solde)
  275.         ComponmentList["MenuTransfert"].Show()
  276.     elseif Action == "MenuEntreprise" then
  277.         InterfaceApi.set(ComponmentList["EntrepriseTxtBoxME"].Nom(),"Texte",nEntreprise)
  278.         InterfaceApi.set(ComponmentList["EntrepriseListBoxME"].Nom(),"Liste",entreprises)
  279.         ComponmentList["MenuEntreprise"].Texte("Panneau de gestion des entreprises")
  280.         ComponmentList["MenuEntreprise"].Show()
  281.     elseif Action == "MenuGestionMember" then
  282.         InterfaceApi.set(ComponmentList["EntrepriseTxtBoxMEGM"].Nom(),"Texte",psdPlayer)
  283.         InterfaceApi.set(ComponmentList["EntrepriseMembreListBoxMEGM"].Nom(),"Liste",membres)
  284.         ComponmentList["MenuEntrepriseGestionMembre"].Texte("Membres de l'entreprise '"..nEntreprise.."'")
  285.         ComponmentList["MenuEntrepriseGestionMembre"].Show()
  286.     elseif Action == "MenuEntrepriseTransfers" then
  287.         InterfaceApi.set(ComponmentList["HistoriqueListBoxMEGT"].Nom(),"Liste",ehistorique)
  288.         InterfaceApi.set(ComponmentList["SommeNumericUpDownMEGT"].Nom(),"Maximum",math.max(solde,esolde))
  289.         InterfaceApi.set(ComponmentList["SommeNumericUpDownMEGT"].Nom(),"Valeur",sommeTransferE)
  290.         ComponmentList["MenuEntrepriseGestionTranfert"].Texte("Transfert d'Entreprise, solde : "..esolde)
  291.         ComponmentList["MenuEntrepriseGestionTranfert"].Show()
  292.     elseif Action == "MenuEntrepriseGestionPermissionMembre" then
  293.         ComponmentList["MenuEntrepriseGestionPermissionMembre"].Texte("Permissions de "..psdPlayer)
  294.         ComponmentList["MenuEntrepriseGestionPermissionMembre"].Show()
  295.     elseif Action == "MenuOP" then
  296.         InterfaceApi.set(ComponmentList["MdpTxtBoxMO"].Nom(),"Texte",nMdpMO)
  297.         InterfaceApi.set(ComponmentList["CompteTxtBoxMO"].Nom(),"Texte",nCompteMO)
  298.         InterfaceApi.set(ComponmentList["SommeNumericUpDownMO"].Nom(),"Valeur",nSommeMO)
  299.         InterfaceApi.set(ComponmentList["PercentNumericUpDownMO"].Nom(),"Valeur",nPercentTransfersMO)
  300.         InterfaceApi.set(ComponmentList["IDATMMO"].Nom(),"Valeur",nATMIDTransfersMO)
  301.         ComponmentList["MenuOperateur"].Show()
  302.     elseif Action == "MenuModifMdp" then
  303.         InterfaceApi.set(ComponmentList["AMdpTxtBoxMM"].Nom(),"Texte",mAMdp)
  304.         InterfaceApi.set(ComponmentList["NMdpTxtBoxMM"].Nom(),"Texte",mNMdp)
  305.         ComponmentList["MenuModifMDP"].Show()
  306.     elseif Action == "MenuCle" then
  307.         ComponmentList["SommeNumericUpDownMC"].Maximum(tonumber(solde))
  308.         ComponmentList["MenuMC"].Show()
  309.     end
  310. end
  311.  
  312. function startup()
  313.     Deconnection()
  314.     MenuAff()
  315.     info = {Act="ListeComptes"}
  316.     infos = textutils.serialise(info)
  317.     send(IDTerminal, infos)
  318.     while true do
  319.         event, p1, p2, p3, p4 = os.pullEvent()
  320.         if event == "componment_click" then
  321.             if p1 == ComponmentList["EffacerMC"].Nom() then
  322.                 psd=""
  323.                 motdepasse=""
  324.                 CompteValider=false
  325.                 historique={}
  326.                 solde=0
  327.                 sommeTransfer = 0
  328.                 nomTransfer = ""
  329.                 MenuAff()
  330.             elseif p1 == ComponmentList["ValiderMC"].Nom() then
  331.                 info = {Act="Connection",Pseudo=psd,Mdp=motdepasse}
  332.                 infos = textutils.serialise(info)
  333.                 send(IDTerminal, infos)
  334.             elseif p1 == ComponmentList["ChangerMdpMM"].Nom() then
  335.                 info = {Act="ModifMdpPlayer",Pseudo=psd,AncienMdp=mAMdp,NouveauMdp=mNMdp}
  336.                 infos = textutils.serialise(info)
  337.                 send(IDTerminal, infos)
  338.             elseif p1 == ComponmentList["RetourMM"].Nom() then
  339.                 Action = "MenuPrincipal"
  340.                 MenuAff()
  341.                 mAMdp = ""
  342.                 mNMdp = ""
  343.             elseif p1 == ComponmentList["HistoriqueMO"].Nom() then
  344.                 info = {Act="RecupHisto",Pseudo=nCompteMO}
  345.                 infos = textutils.serialise(info)
  346.                 send(IDTerminal, infos)
  347.             elseif p1 == ComponmentList["AddCompteMO"].Nom() then
  348.                 info = {Act="CreeCompte",Pseudo=nCompteMO}
  349.                 infos = textutils.serialise(info)
  350.                 send(IDTerminal, infos)
  351.             elseif p1 == ComponmentList["SupprCompteMO"].Nom() then
  352.                 info = {Act="DelCompte",Pseudo=nCompteMO}
  353.                 infos = textutils.serialise(info)
  354.                 send(IDTerminal, infos)
  355.             elseif p1 == ComponmentList["ModifMdpMO"].Nom() then
  356.                 info = {Act="ChangerMdp",Pseudo=nCompteMO,Mdp=nMdpMO}
  357.                 infos = textutils.serialise(info)
  358.                 send(IDTerminal, infos)
  359.             elseif p1 == ComponmentList["MakeOPMO"].Nom() then
  360.                 info = {Act="setOP",Pseudo=nCompteMO}
  361.                 infos = textutils.serialise(info)
  362.                 send(IDTerminal, infos)
  363.             elseif p1 == ComponmentList["MakePlayerMO"].Nom() then
  364.                 info = {Act="setPLAYER",Pseudo=nCompteMO}
  365.                 infos = textutils.serialise(info)
  366.                 send(IDTerminal, infos)
  367.             elseif p1 == ComponmentList["AddATMMO"].Nom() then
  368.                 info = {Act="AddATM",ATMID=nATMIDTransfersMO}
  369.                 infos = textutils.serialise(info)
  370.                 send(IDTerminal, infos)
  371.             elseif p1 == ComponmentList["DelATMMO"].Nom() then
  372.                 info = {Act="DelATM",ATMID=nATMIDTransfersMO}
  373.                 infos = textutils.serialise(info)
  374.                 send(IDTerminal, infos)
  375.             elseif p1 == ComponmentList["GiveMonneyMO"].Nom() then
  376.                 info = {Act="AddMonney",Pseudo=nCompteMO,Somme=nSommeMO}
  377.                 infos = textutils.serialise(info)
  378.                 send(IDTerminal, infos)
  379.             elseif p1 == ComponmentList["StealMonneyMO"].Nom() then
  380.                 info = {Act="StealMonney",Pseudo=nCompteMO,Somme=nSommeMO}
  381.                 infos = textutils.serialise(info)
  382.                 send(IDTerminal, infos)
  383.             elseif p1 == ComponmentList["AddPercentMO"].Nom() then
  384.                 info = {Act="AddPercent",Pourcent=nPercentTransfersMO}
  385.                 infos = textutils.serialise(info)
  386.                 send(IDTerminal, infos)
  387.             elseif p1 == ComponmentList["StealPercentMO"].Nom() then
  388.                 info = {Act="StealPercent",Pourcent=nPercentTransfersMO}
  389.                 infos = textutils.serialise(info)
  390.                 send(IDTerminal, infos)
  391.             elseif p1 == ComponmentList["ListeComptesMO"].Nom() then
  392.                 info = {Act="ListeComptesD"}
  393.                 infos = textutils.serialise(info)
  394.                 send(IDTerminal, infos)
  395.             elseif p1 == ComponmentList["RetourMO"].Nom() then
  396.                 Action = "MenuPrincipal"
  397.                 updateInfo()
  398.             elseif p1 == ComponmentList["TerminateMO"].Nom() then
  399.                 Action="STOP"
  400.                 InterfaceApi.EventsStop()
  401.                 term.setBackgroundColor(colors.black)
  402.                 shell.run("clear")
  403.                 shell.run("shell")
  404.             elseif p1 == ComponmentList["TransfertMP"].Nom() then
  405.                 Action = "MenuTransfers"
  406.                 updateInfo()
  407.             elseif p1 == ComponmentList["ModifmdpMP"].Nom() then
  408.                 Action = "MenuModifMdp"
  409.                 MenuAff()
  410.             elseif p1 == ComponmentList["EntreprisesMP"].Nom() then
  411.                 Action = "MenuEntreprise"
  412.                 updateInfo()
  413.             elseif p1 == ComponmentList["RecupHistoriqueMP"].Nom() then
  414.                 info = {Act="RecupHistorique",Pseudo=psd}
  415.                 infos = textutils.serialise(info)
  416.                 send(IDTerminal, infos)
  417.             elseif p1 == ComponmentList["EffHistoriqueMP"].Nom() then
  418.                 info = {Act="EffHistorique",Pseudo=psd}
  419.                 infos = textutils.serialise(info)
  420.                 send(IDTerminal, infos)
  421.             elseif p1 == ComponmentList["OpMP"].Nom() then
  422.                 Action = "MenuOP"
  423.                 MenuAff()
  424.             elseif p1 == ComponmentList["DeconnectionMP"].Nom() then
  425.                 Deconnection()
  426.                 psd = ""
  427.                 motdepasse = ""
  428.                 CompteValider=false
  429.                 historique = {}
  430.                 solde = 0
  431.                 Action="Connection"
  432.                 nomTransfer = ""
  433.                 sommeTransfer = 0
  434.                 nEntreprise = ""
  435.                 entreprises = {}
  436.                 psdPlayer = ""
  437.                 membres = {}
  438.                 esolde = 0
  439.                 ehistorique = {}
  440.                 sommeTransferE = 0
  441.                 statut = "PLAYER"
  442.                 nCompteMO = ""
  443.                 nSommeMO = 0
  444.                 nPercentTransfersMO = 0
  445.                 nATMIdMO = 0
  446.                 nATMIDTransfersMO = 0
  447.                 nMdpMO = ""
  448.                 mAMdp = ""
  449.                 mNMdp = ""
  450.                 MenuAff()
  451.             elseif p1 == ComponmentList["ValiderMT"].Nom() then
  452.                 info = {Act="Transfer",Proprio=psd,Destinataire=nomTransfer,Somme=sommeTransfer}
  453.                 infos = textutils.serialise(info)
  454.                 send(IDTerminal, infos)
  455.             elseif p1 == ComponmentList["RetourMT"].Nom() then
  456.                 Action = "MenuPrincipal"
  457.                 updateInfo()
  458.             elseif p1 == ComponmentList["EffacerMT"].Nom() then
  459.                 sommeTransfer= 0
  460.                 nomTransfer = ""
  461.                 updateInfo()
  462.             elseif p1 == ComponmentList["CreeEntrepriseME"].Nom() then
  463.                 info = {Act="CreeEntreprise",Nom=nEntreprise,Proprio=psd}
  464.                 infos = textutils.serialise(info)
  465.                 send(IDTerminal, infos)
  466.             elseif p1 == ComponmentList["GererTransfertME"].Nom() then
  467.                 if nEntreprise == "" then
  468.                     term.setCursorPos(2,17)
  469.                     term.setTextColor(colors.red)
  470.                     term.setBackgroundColor(colors.black)
  471.                     print("Entrer le nom d'une entreprise !")
  472.                 else
  473.                     info = {Act="EntrepriseTransfers",Entreprise=nEntreprise,Demandeur=psd}
  474.                     infos = textutils.serialise(info)
  475.                     send(IDTerminal, infos)
  476.                 end
  477.             elseif p1 == ComponmentList["SupprEntrepriseME"].Nom() then
  478.                 info = {Act="SupprEntreprise",Entreprise=nEntreprise,Demandeur=psd}
  479.                 infos = textutils.serialise(info)
  480.                 send(IDTerminal, infos)
  481.             elseif p1 == ComponmentList["GererMembresME"].Nom() then
  482.                 if nEntreprise == "" then
  483.                     term.setCursorPos(2,17)
  484.                     term.setTextColor(colors.red)
  485.                     term.setBackgroundColor(colors.black)
  486.                     print("Entrer le nom d'une entreprise !")
  487.                 else
  488.                     info = {Act="AddMemberConnection",Entreprise=nEntreprise,Demandeur=psd}
  489.                     infos = textutils.serialise(info)
  490.                     send(IDTerminal, infos)
  491.                 end
  492.             elseif p1 == ComponmentList["RetourME"].Nom() then
  493.                 Action = "MenuPrincipal"
  494.                 updateInfo()
  495.             elseif p1 ==  ComponmentList["EntrepriseAddMembreMEGM"].Nom() then
  496.                 if psdPlayer == "" then
  497.                     term.setCursorPos(2,17)
  498.                     term.setTextColor(colors.red)
  499.                     term.setBackgroundColor(colors.black)
  500.                     print("Entrer le nom d'un compte !")
  501.                 else
  502.                     info = {Act="AddMember",Entreprise=nEntreprise,Demandeur=psd, pseudo=psdPlayer}
  503.                     infos = textutils.serialise(info)
  504.                     send(IDTerminal, infos)
  505.                 end
  506.             elseif p1 == ComponmentList["RetourMEGM"].Nom() then
  507.                 Action = "MenuEntreprise"
  508.                 MenuAff()
  509.             elseif p1 == ComponmentList["EntreprisePermMembreMEGM"].Nom() then
  510.                 if psdPlayer == "" then
  511.                     term.setCursorPos(2,17)
  512.                     term.setTextColor(colors.red)
  513.                     term.setBackgroundColor(colors.black)
  514.                     print("Entrer le nom d'un compte !")
  515.                 else
  516.                     info = {Act="PermMember",Entreprise=nEntreprise,Demandeur=psd, pseudo=psdPlayer}
  517.                     infos = textutils.serialise(info)
  518.                     send(IDTerminal, infos)
  519.                 end
  520.             elseif p1 == ComponmentList["EntrepriseSupprMembreMEGM"].Nom() then
  521.                 if psdPlayer == "" then
  522.                     term.setCursorPos(2,17)
  523.                     term.setTextColor(colors.red)
  524.                     term.setBackgroundColor(colors.black)
  525.                     print("Entrer le nom d'un compte !")
  526.                 else
  527.                     info = {Act="DelMember",Entreprise=nEntreprise,Demandeur=psd, pseudo=psdPlayer}
  528.                     infos = textutils.serialise(info)
  529.                     send(IDTerminal, infos)
  530.                 end
  531.             elseif p1 == ComponmentList["EntrepriseCreditMEGT"].Nom() then
  532.                 if sommeTransferE+0 > solde+0 then
  533.                     sommeTransferE = solde+0
  534.                 end
  535.                 if sommeTransferE+0 < 0 then
  536.                     sommeTransferE = 0
  537.                 end
  538.                 ComponmentList["SommeNumericUpDownMEGT"].Valeur(sommeTransferE)
  539.                 info = {Act="TransferToEntreprise",Proprio=psd,Somme=sommeTransferE+0,Entreprise=nEntreprise}
  540.                 infos = textutils.serialise(info)
  541.                 send(IDTerminal, infos)
  542.                 updateInfoE()
  543.             elseif p1 == ComponmentList["EntrepriseDebitMEGT"].Nom() then
  544.                 if sommeTransferE+0 > esolde+0 then
  545.                     sommeTransferE = esolde+0
  546.                 end
  547.                 if sommeTransferE+0 < 0 then
  548.                     sommeTransferE = 0
  549.                 end
  550.                 ComponmentList["SommeNumericUpDownMEGT"].Valeur(sommeTransferE)
  551.                 info = {Act="RetraitToEntreprise",Proprio=psd,Somme=sommeTransferE+0,Entreprise=nEntreprise}
  552.                 infos = textutils.serialise(info)
  553.                 send(IDTerminal, infos)
  554.                 updateInfoE()
  555.             elseif p1 == ComponmentList["RetourMEGT"].Nom() then
  556.                 Action = "MenuEntreprise"
  557.                 MenuAff()
  558.             elseif p1 == ComponmentList["RetourMEGPM"].Nom() then
  559.                 Action = "MenuGestionMember"
  560.                 MenuAff()
  561.             elseif p1 == ComponmentList["ValiderMEGPM"].Nom() then
  562.                 local nPerm = {DeleteEntrep=ComponmentList["PermDelEntreprise"].Checked(),Depos=ComponmentList["PermDepos"].Checked(),Retrait=ComponmentList["PermRetrait"].Checked(),DeleteMembre=ComponmentList["PermDelMembre"].Checked(),ModifPerm=ComponmentList["PermModif"].Checked(),AddMembre=ComponmentList["PermAddMembre"].Checked()}
  563.                 ninfo = {Act="ReplyPerm",permissions=nPerm,pseudo=psdPlayer,Demandeur=psd,Entreprise=nEntreprise}  
  564.                 send(IDTerminal,textutils.serialise(ninfo))
  565.                 Action = "MenuGestionMember"
  566.                 MenuAff()
  567.             elseif p1 == ComponmentList["CleMP"].Nom() then
  568.                 Action = "MenuCle"
  569.                 MenuAff()
  570.             elseif p1 == ComponmentList["RetourMC"].Nom() then
  571.                 Action = "MenuPrincipal"
  572.                 updateInfo()
  573.                 MenuAff()
  574.             elseif p1 == ComponmentList["GenererMC"].Nom() then
  575.                 if ComponmentList["SommeNumericUpDownMC"].Valeur() > 0 then
  576.                     if ComponmentList["SommeNumericUpDownMC"].Valeur() > tonumber(solde) then
  577.                         ComponmentList["SommeNumericUpDownMC"].Valeur(tonumber(solde))
  578.                     end
  579.                     send(IDTerminal,textutils.serialise({Act="GenKey",Somme=ComponmentList["SommeNumericUpDownMC"].Valeur(),psd=psd,mdp=motdepasse}))
  580.                 end
  581.             elseif p1 == ComponmentList["UtiliserMC"].Nom() then
  582.                 if ComponmentList["SommeNumericUpDownMC"].Valeur() > 0 then
  583.                     send(IDTerminal,textutils.serialise({Act="UseKey",Somme=ComponmentList["SommeNumericUpDownMC"].Valeur(),psd=psd,Cle=ComponmentList["CleMC"].Texte()}))
  584.                 end
  585.             end
  586.         elseif event == "textbox_textchange" then
  587.             if p1 == ComponmentList["PseudoTxtBoxMC"].Nom() then
  588.                 psd = p2
  589.             elseif p1 == ComponmentList["MdpTxtBoxMC"].Nom() then
  590.                 motdepasse = p2
  591.             elseif p1 == ComponmentList["AMdpTxtBoxMM"].Nom() then
  592.                 mAMdp = p2
  593.             elseif p1 == ComponmentList["NMdpTxtBoxMM"].Nom() then
  594.                 mNMdp = p2
  595.             elseif p1 == ComponmentList["CompteTxtBoxMO"].Nom() then
  596.                 nCompteMO = p2
  597.             elseif p1 == ComponmentList["MdpTxtBoxMO"].Nom() then
  598.                 nMdpMO = p2
  599.             elseif p1 == ComponmentList["CompteTxtBoxMT"].Nom() then
  600.                 nomTransfer = p2
  601.             elseif p1 == ComponmentList["EntrepriseTxtBoxME"].Nom() then
  602.                 nEntreprise = p2
  603.             elseif p1 == ComponmentList["EntrepriseTxtBoxMEGM"].Nom() then
  604.                 psdPlayer = p2
  605.             end
  606.         elseif event == "numericupdown_valuechange" then
  607.             if p1 == ComponmentList["IDATMMO"].Nom() then
  608.                 nATMIDTransfersMO = p2
  609.             elseif p1 == ComponmentList["SommeNumericUpDownMO"].Nom() then
  610.                 nSommeMO = p2
  611.             elseif p1 == ComponmentList["PercentNumericUpDownMO"].Nom() then
  612.                 nPercentTransfersMO = p2
  613.             elseif p1 == ComponmentList["SommeNumericUpDownMT"].Nom() then
  614.                 sommeTransfer = p2
  615.             elseif p1 == ComponmentList["SommeNumericUpDownMEGT"].Nom() then
  616.                 sommeTransferE = p2
  617.             end
  618.         elseif event == "listbox_selecteditemchange" then
  619.             if p1 == ComponmentList["EntrepriseListBoxME"].Nom() then
  620.                 if p3 ~= nil then
  621.                     ComponmentList["EntrepriseTxtBoxME"].Texte(p3)
  622.                 else
  623.                     ComponmentList["EntrepriseTxtBoxME"].Texte("")
  624.                 end
  625.                 os.queueEvent("textbox_textchange","EntrepriseTxtBoxME",ComponmentList["EntrepriseTxtBoxME"].Texte())
  626.             elseif p1 == ComponmentList["EntrepriseMembreListBoxMEGM"].Nom() then
  627.                 if p3 ~= nil then
  628.                     ComponmentList["EntrepriseTxtBoxMEGM"].Texte(p3)
  629.                 else
  630.                     ComponmentList["EntrepriseTxtBoxMEGM"].Texte("")
  631.                 end
  632.                 os.queueEvent("textbox_textchange","EntrepriseTxtBoxMEGM",ComponmentList["EntrepriseTxtBoxMEGM"].Texte())
  633.             end
  634.         end
  635.     end
  636. end
  637.  
  638. function Reception()
  639.     while true do
  640.         id, message = NetSphere.receive()
  641.         ID = id
  642.         local haveNil = false
  643.         if message == nil then
  644.             haveNil = true
  645.         else
  646.             info = message
  647.         end
  648.         if haveNil == false then
  649.             if ID == IDTerminal then
  650.                 infos = textutils.unserialise(info)
  651.                 if type(infos) == "nil" then
  652.                 else
  653.                     infos = textutils.unserialise(info)
  654.                     MenuAff()
  655.                     if infos.Act == "CompteValide" then
  656.                         CompteValider=true
  657.                         Action="MenuPrincipal"
  658.                         solde = infos.Solde
  659.                         statut = infos.Statut
  660.                         entreprises = textutils.unserialise(infos.Entreprises)
  661.                         historique = textutils.unserialise(infos.Historique)
  662.                         MenuAff()
  663.                     elseif infos.Act == "KeyGen" then
  664.                         ComponmentList["CleMC"].Texte(infos.Cle)
  665.                     elseif infos.Act == "ReplyHisto" then
  666.                         h = fs.open("HistoriqueJoueur","w")
  667.                         h.write(infos.Historique)
  668.                         h.close()
  669.                         ComponmentList["MenuOperateur"].Hide()
  670.                         shell.run("edit HistoriqueJoueur")
  671.                         fs.delete("HistoriqueJoueur")
  672.                         Action = "MenuOP"
  673.                         MenuAff()
  674.                     elseif infos.Act == "ListesDComptes" then
  675.                         Action = "ListeCompteRead"
  676.                         h = fs.open("ListeComptes","w")
  677.                         h.write(infos.Liste)
  678.                         h.close()
  679.                         ComponmentList["MenuOperateur"].Hide()
  680.                         shell.run("edit ListeComptes")
  681.                         fs.delete("ListeComptes")
  682.                         Action = "MenuOP"
  683.                         MenuAff()
  684.                     elseif infos.Act == "Erreur" then
  685.                         if infos.Menu == "MenuOP" then
  686.                             term.setBackgroundColor(colors.black)
  687.                             term.setTextColor(colors.red)
  688.                             term.setCursorPos(2,2)
  689.                             print(infos.Message)
  690.                         elseif infos.Menu == "Connection" then
  691.                             Action="Connection"
  692.                             MenuAff()
  693.                             term.setCursorPos(11,15)
  694.                             term.setTextColor(colors.red)
  695.                             term.setBackgroundColor(colors.black)
  696.                             print(infos.Message)
  697.                         elseif infos.Menu == "MenuEntreprise" then
  698.                             term.setBackgroundColor(colors.black)
  699.                             term.setTextColor(colors.red)
  700.                             term.setCursorPos(2,17)
  701.                             print(infos.Message)
  702.                         elseif infos.Menu == "MenuCle" then
  703.                             term.setBackgroundColor(colors.black)
  704.                             term.setTextColor(colors.red)
  705.                             term.setCursorPos(11,15)
  706.                             print(infos.Message)
  707.                         end
  708.                     elseif infos.Act == "Succes" then
  709.                         if infos.Menu == "MenuOP" then
  710.                             term.setBackgroundColor(colors.black)
  711.                             term.setTextColor(colors.green)
  712.                             term.setCursorPos(2,2)
  713.                             print(infos.Message)
  714.                         elseif infos.Menu == "MenuCle" then
  715.                             term.setBackgroundColor(colors.black)
  716.                             term.setTextColor(colors.green)
  717.                             term.setCursorPos(11,15)
  718.                             print(infos.Message)
  719.                         end
  720.                     elseif infos.Act == "AncMdpInco" then
  721.                         term.setCursorPos(6,13)
  722.                         term.setTextColor(colors.red)
  723.                         term.setBackgroundColor(colors.black)
  724.                         print("Ancien Mot de passe Incorrect !")
  725.                     elseif infos.Act == "TransferConnecAut" then
  726.                         Action = "MenuEntrepriseTransfers"
  727.                         ehistorique = infos.Historique
  728.                         esolde = infos.Solde
  729.                         MenuAff()
  730.                     elseif infos.Act == "RetraitEntrepRef" then
  731.                         term.setCursorPos(2,17)
  732.                         term.setTextColor(colors.red)
  733.                         term.setBackgroundColor(colors.black)
  734.                         print("Retrait d'argent Interdit !")
  735.                     elseif infos.Act == "DeposEntrepRef" then
  736.                         term.setCursorPos(2,17)
  737.                         term.setTextColor(colors.red)
  738.                         term.setBackgroundColor(colors.black)
  739.                         print("Depos d'argent Interdit !")
  740.                     elseif infos.Act == "CompteNValide" then
  741.                         CompteValider=false
  742.                         Action="Connection"
  743.                         term.setCursorPos(11,15)
  744.                         term.setTextColor(colors.red)
  745.                         term.setBackgroundColor(colors.black)
  746.                         print("Mauvais Pseudo/Mot de passe !")
  747.                     elseif infos.Act == "ActualiserE" then
  748.                         esolde = infos.Solde
  749.                         ehistorique = textutils.unserialise(infos.Historique)
  750.                         os.queueEvent("updateInfoEReceive")
  751.                         MenuAff()
  752.                     elseif infos.Act == "NvmdpOk" then
  753.                         Action="MenuPrincipal"
  754.                         MenuAff()
  755.                         mAMdp = ""
  756.                         mNMdp = ""
  757.                     elseif infos.Act == "Actualiser" then
  758.                         solde = infos.Solde
  759.                         statut = infos.Statut
  760.                         entreprises = textutils.unserialise(infos.Entreprises)
  761.                         historique = textutils.unserialise(infos.Historique)
  762.                         os.queueEvent("updateInfoReceive")
  763.                         MenuAff()
  764.                     elseif infos.Act == "CompteNExist" then
  765.                         term.setCursorPos(2,17)
  766.                         term.setTextColor(colors.red)
  767.                         term.setBackgroundColor(colors.black)
  768.                         print("Compte Inexistant !")
  769.                     elseif infos.Act == "AddMemberConnecAut" then
  770.                         Action="MenuGestionMember"
  771.                         membres = textutils.unserialise(infos.membres)
  772.                         MenuAff()
  773.                     elseif infos.Act == "DeleteEntrepRef" then
  774.                         term.setCursorPos(2,17)
  775.                         term.setTextColor(colors.red)
  776.                         term.setBackgroundColor(colors.black)
  777.                         print("Supression Interdite !")
  778.                     elseif infos.Act == "EntrepriseNExist" then
  779.                         term.setCursorPos(2,17)
  780.                         term.setTextColor(colors.red)
  781.                         term.setBackgroundColor(colors.black)
  782.                         print("L'entreprise n'existe pas !")
  783.                     elseif infos.Act == "ListeComptesTab" then
  784.                         ListeComptes = infos.Liste
  785.                         ListeEnt = infos.ListeEnt
  786.                         local LstA = {}
  787.                         for k,v in pairs(ListeComptes) do
  788.                             LstA[#LstA+1]=v
  789.                         end
  790.                         for k,v in pairs(ListeEnt) do
  791.                             LstA[#LstA+1]=v
  792.                         end
  793.                         ComponmentList["PseudoTxtBoxMC"].ListeMots(ListeComptes)
  794.                         ComponmentList["CompteTxtBoxMT"].ListeMots(LstA)
  795.                         ComponmentList["CompteTxtBoxMO"].ListeMots(ListeComptes)
  796.                         ComponmentList["EntrepriseTxtBoxMEGM"].ListeMots(ListeComptes)
  797.                         MenuAff()
  798.                     elseif infos.Act == "DelMemberConnecRef" then
  799.                         term.setCursorPos(2,17)
  800.                         term.setTextColor(colors.red)
  801.                         term.setBackgroundColor(colors.black)
  802.                         print("Supression de membres Interdit !")
  803.                     elseif infos.Act == "PermMemberConnecRef" then
  804.                         term.setCursorPos(2,17)
  805.                         term.setTextColor(colors.red)
  806.                         term.setBackgroundColor(colors.black)
  807.                         print("Modif Permissions Interdit !")
  808.                     elseif infos.Act == "DelMemberImpossible" then
  809.                         term.setCursorPos(2,17)
  810.                         term.setTextColor(colors.red)
  811.                         term.setBackgroundColor(colors.black)
  812.                         print("Impossible de vous supprimer ! !")
  813.                     elseif infos.Act == "PermEdit" then
  814.                         local perm = textutils.unserialise(infos.permissions)
  815.                         ComponmentList["PermAddMembre"].Checked(perm.AddMembre)
  816.                         ComponmentList["PermDelMembre"].Checked(perm.DeleteMembre)
  817.                         ComponmentList["PermDelEntreprise"].Checked(perm.DeleteEntrep)
  818.                         ComponmentList["PermDepos"].Checked(perm.Depos)
  819.                         ComponmentList["PermRetrait"].Checked(perm.Retrait)
  820.                         ComponmentList["PermModif"].Checked(perm.ModifPerm)
  821.                         Action = "MenuEntrepriseGestionPermissionMembre"
  822.                         MenuAff()
  823.                     elseif infos.Act == "AddMemberConnecRef" then
  824.                         term.setCursorPos(2,17)
  825.                         term.setTextColor(colors.red)
  826.                         term.setBackgroundColor(colors.black)
  827.                         print("Ajout de membres Interdit !")
  828.                     elseif infos.Act == "ErreurCreeEntreprise" then
  829.                         term.setCursorPos(2,17)
  830.                         term.setTextColor(colors.red)
  831.                         term.setBackgroundColor(colors.black)
  832.                         print("Nom d'Entreprise déjà pris !")
  833.                     end
  834.                 end
  835.             end
  836.         end
  837.     end
  838. end
  839.  
  840. function diskEject()
  841.     while true do
  842.         event, side = os.pullEvent("disk")
  843.         if event == "disk" then
  844.             disk.eject(side)
  845.         end
  846.     end
  847. end
  848.  
  849. function Veille()
  850.     local timerId = os.startTimer(30)
  851.     while true do
  852.         event, p1 = os.pullEvent()
  853.         if event == "key" or event == "char" or event == "mouse_click" or event == "mouse_drag" then
  854.             os.cancelTimer(timerId)
  855.             timerId = os.startTimer(30)
  856.         else
  857.             if event == "timer" then
  858.                 if p1 == timerId then
  859.                     os.shutdown()
  860.                 end
  861.             end
  862.         end
  863.     end
  864. end
  865.  
  866. parallel.waitForAll(startup,Reception,HaveAModem,diskEject,InterfaceApi.Events,Veille)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement