montel Posted April 10, 2013 Share Posted April 10, 2013 How to register logs from the xml when i was bought buy cars? Client maFen = nil local colorButton = {} local cColor = {} local colorButtonA = {} local colorEx = {} local player = getLocalPlayer() function guiStart (atList) if maFen == nil then local x, y = guiGetScreenSize() maFen = guiCreateWindow( x / 2 - 200, y / 2 - 175, 400, 350, "Vehicles Shop", false ) guiSetText ( maFen, "Araç Dükkanı") maTab = guiCreateTabPanel( 180, 30, 230, 100, false, maFen ) carPic = guiCreateStaticImage( 5, 5, 200, 85, "Png\\rien.png", false, maTab ) local cBNum = 0 local cBx = 0.46 while cBNum ~= 4 do cBNum = cBNum + 1 colorButtonA[cBNum] = guiCreateButton ( cBx, 0.39, 0.10, 0.06, "Renk"..cBNum.."", true , maFen ) cBx = cBx + 0.13 end guiWindowSetSizable (maFen, false ) guiWindowSetMovable (maFen, true ) showList(atList) buyButton = guiCreateButton( 0.03, 0.89, 0.33, 0.10, "Satın Al", true, maFen ) closeButton = guiCreateButton( 0.66, 0.89, 0.33, 0.10, "Kapat", true, maFen ) addEventHandler( "onClientGUIClick", maFen, aClickGui ) showCursor ( true ) guiSetVisible ( maFen, true ) --guiCreateStaticImage( 5, 5, 200, 85, "colors\\2.png", false, maTab ) colorFen = guiCreateWindow( x / 2 - 260, y / 2 - 40, 520, 210, "Renkler", false ) local colorNum = 0 local colorNum1 = 0 local colorX = 10 local colorY = 25 while colorNum ~= 127 do colorButton = guiCreateStaticImage( colorX, colorY, 23, 23, "colors\\"..colorNum..".png", false, colorFen ) setElementData ( colorButton , "colorNum1", ""..colorNum.."" ) addEventHandler( "onClientGUIClick", colorButton, aClickGuiColor ) colorNum = colorNum + 1 colorX = colorX + 25 if colorNum1 == 19 then colorY = colorY + 25 colorNum1 = 0 colorX = 10 else colorNum1 = colorNum1 + 1 end end colorCloseButton = guiCreateButton( 0.76, 0.85, 0.23, 0.1, "Kapat", true, colorFen ) addEventHandler( "onClientGUIClick", colorFen, aClickGui ) guiWindowSetSizable ( colorFen, false ) guiSetVisible ( colorFen, false ) else guiSetVisible ( maFen, true ) showCursor ( true ) guiBringToFront ( maFen ) showList(atList) end end addEvent( "guiStart", true ) addEventHandler( "guiStart", getRootElement(), guiStart ) function destroyvehicles ( vehicle ) destroyElement ( vehicle ) end addEvent( "destroyvehicles", true ) addEventHandler( "destroyvehicles", getRootElement(), destroyvehicles ) function showList(atList) local table = {} -- outputChatBox ( ""..atList.."" ) vehicleList = guiCreateGridList ( 0.03 , 0.07, 0.4, 0.8, true, maFen ) vehicleList1 = guiGridListAddColumn( vehicleList, "Araçlar", 0.5 ) priceList = guiGridListAddColumn( vehicleList, "Fiyatı", 0.3 ) node = xmlLoadFile("data\\vehicles.xml") if ( node ) then local vNum = 0 while ( xmlFindSubNode ( node, "group", vNum ) ~= false ) do local group = xmlFindSubNode ( node, "group", vNum ) if xmlNodeGetAttribute ( group, "type" ) == atList then local gName = xmlNodeGetAttribute ( group, "id" ) -- guiGridListSetItemText( vehicleList, guiGridListAddRow ( vehicleList ), 1, ""..gName.."", false, false ) local vNum1 = 0 while ( xmlFindSubNode ( group, "vehicle", vNum1 ) ~= false ) do local aVehicle = xmlFindSubNode ( group, "vehicle", vNum1 ) local vId = xmlNodeGetAttribute ( aVehicle, "id" ) local vName = getVehicleNameFromID ( vId ) local vPrice = xmlNodeGetAttribute ( aVehicle, "price" ) local row = guiGridListAddRow ( vehicleList ) guiGridListSetItemText( vehicleList, row, 1, ""..vName.."", false, false ) guiGridListSetItemText( vehicleList, row, 2, ""..vPrice.."", false, false ) vNum1 = vNum1 + 1 end end vNum = vNum + 1 end addEventHandler( "onClientGUIClick", vehicleList, aClickGuiCar ) addEventHandler( "onClientGUIDoubleClick", vehicleList, aClickDoubleGui ) bindKey ( "arrow_u", "down", navList ) bindKey ( "arrow_d", "down", navList ) xmlUnloadFile ( node ) end return table end function navList ( key, keyState) local rowSel = guiGridListGetSelectedItem ( vehicleList ) if key == "arrow_u" then guiGridListSetSelectedItem ( vehicleList, tonumber(rowSel)-1, 1 ) elseif key == "arrow_d" then guiGridListSetSelectedItem ( vehicleList, tonumber(rowSel)+1, 1 ) end local aCurrentVehicle = guiGridListGetItemText ( vehicleList, guiGridListGetSelectedItem ( vehicleList ), 1 ) guiStaticImageLoadImage ( carPic, "Png\\"..aCurrentVehicle..".png" ) end function aClickGui (button) if ( button == "left") then if ( source == closeButton ) then guiSetVisible ( maFen, false ) guiSetVisible ( colorFen, false ) showCursor ( false ) destroyElement ( vehicleList ) unbindKey ( "arrow_u", "down", navList ) unbindKey ( "arrow_d", "down", navList ) local num = 0 while num ~= 4 do num = num + 1 if ( colorEx[num] ) then guiStaticImageLoadImage ( colorEx[num], "colors\\rien.png" ) end end guiStaticImageLoadImage ( carPic, "Png\\rien.png" ) elseif ( source == buyButton ) then if ( aCurrentVehicle ) ~= "" then local cNum = 0 while cNum ~=4 do cNum = cNum + 1 cColor[cNum] = getElementData ( colorButtonA[cNum], "apColor" ) if cColor[cNum] == false then cColor[cNum] = "1" end end applyVehicle ( cColor[1], cColor[2], cColor[3], cColor[4] ) guiSetVisible ( maFen, false ) guiSetVisible ( colorFen, false ) showCursor ( false ) unbindKey ( "arrow_u", "down", navList ) unbindKey ( "arrow_d", "down", navList ) destroyElement ( vehicleList ) guiStaticImageLoadImage ( carPic, "Png\\rien.png" ) else outputChatBox ( "no vehicle selected" ) end elseif ( source == colorCloseButton ) then guiSetVisible ( colorFen, false ) elseif ( source == colorButtonA[4] ) then guiSetVisible ( colorFen, true ) guiBringToFront ( colorFen ) setElementData ( colorFen, "typColor", "4" ) elseif ( source == colorButtonA[3] ) then guiSetVisible ( colorFen, true ) guiBringToFront ( colorFen ) setElementData ( colorFen, "typColor", "3" ) elseif ( source == colorButtonA[2] ) then guiSetVisible ( colorFen, true ) guiBringToFront ( colorFen ) setElementData ( colorFen, "typColor", "2" ) elseif ( source == colorButtonA[1] ) then guiSetVisible ( colorFen, true ) guiBringToFront ( colorFen ) setElementData ( colorFen, "typColor", "1" ) end end end function aClickGuiColor (button) color1Choose = getElementData ( source, "colorNum1" ) if color1Choose ~= false then typeColorButton = getElementData ( colorFen, "typColor" ) if typeColorButton == "2" then local exPosX = 0.60 affColorExemple ( color1Choose, typeColorButton, exPosX ) elseif typeColorButton == "1" then local exPosX = 0.47 affColorExemple ( color1Choose, typeColorButton, exPosX ) elseif typeColorButton == "3" then local exPosX = 0.73 affColorExemple ( color1Choose, typeColorButton, exPosX ) elseif typeColorButton == "4" then local exPosX = 0.86 affColorExemple ( color1Choose, typeColorButton, exPosX ) end end end function affColorExemple ( color1Choose, typeColorButton, exPosX ) -- outputChatBox ( ""..color1Choose.."" ) guiSetVisible ( colorFen, false ) setElementData ( colorButtonA[tonumber(typeColorButton)], "apColor", ""..color1Choose.."" ) if ( colorEx[tonumber(typeColorButton)] ) then guiStaticImageLoadImage ( colorEx[tonumber(typeColorButton)], "colors\\"..color1Choose..".png" ) else colorEx[tonumber(typeColorButton)] = guiCreateStaticImage( exPosX, 0.46, 0.08, 0.06, "colors\\"..color1Choose..".png", true, maFen ) end end function aClickDoubleGui (button) if (button == "left" ) then if ( source == vehicleList ) then local cNum = 0 while cNum ~=4 do cNum = cNum + 1 cColor[cNum] = getElementData ( colorButtonA[cNum], "apColor" ) if cColor[cNum] == false then cColor[cNum] = "1" end end applyVehicle (cColor[1], cColor[2], cColor[3], cColor[4] ) if aCurrentVehicle ~= "" then --- SE IF FAUDRAI LE METTRE PLUS HAUT y a un doublon ligne 303 guiSetVisible ( maFen, false ) showCursor ( false ) unbindKey ( "arrow_u", "down", navList ) unbindKey ( "arrow_d", "down", navList ) destroyElement ( vehicleList ) guiStaticImageLoadImage ( carPic, "Png\\rien.png" ) end end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now