@@ -497,6 +497,7 @@ wndClothes = {
497
497
},
498
498
{' br' },
499
499
{' btn' , text = ' add' , id = ' addremove' , width = 60 , onclick = applyClothes , ClickSpamProtected = true },
500
+ {' btn' , id = ' outfits' , onclick = function () createWindow (wndOutfits ) end },
500
501
{' btn' , id = ' close' , closeswindow = true }
501
502
},
502
503
oncreate = clothesInit
@@ -526,6 +527,121 @@ end
526
527
addCommandHandler (' removeclothes' , removeClothesCommand )
527
528
addCommandHandler (' rc' , removeClothesCommand )
528
529
530
+ ---- -----------------------
531
+ -- Outfits window
532
+ ---- -----------------------
533
+
534
+ local outfitList
535
+ local outfits
536
+
537
+ function initOutfits ()
538
+ outfitList = wndOutfits .controls [1 ].element
539
+ if outfits then return end
540
+ loadOutfits ()
541
+ addEventHandler (' onClientGUIDoubleClick' , outfitList , loadClothes )
542
+ end
543
+
544
+ function loadOutfits ()
545
+ outfits = {}
546
+
547
+ local xml = xmlLoadFile (' outfits.xml' )
548
+ if not xml then
549
+ xml = xmlCreateFile (' outfits.xml' , ' catalog' )
550
+ end
551
+ guiGridListClear (outfitList )
552
+ for i ,child in ipairs (xmlNodeGetChildren (xml ) or {}) do
553
+ local row = guiGridListAddRow (outfitList )
554
+ guiGridListSetItemText (outfitList , row , 1 , tostring (xmlNodeGetAttribute (child , ' name' )), false , false )
555
+ outfits [row + 1 ] = {}
556
+ for j = 0 ,17 do
557
+ table.insert (outfits [row + 1 ], j , xmlNodeGetAttribute (child , ' c' .. j ))
558
+ end
559
+ end
560
+ end
561
+
562
+ function saveOutfits ()
563
+ if fileExists (' outfits.xml' ) then
564
+ fileDelete (' outfits.xml' )
565
+ end
566
+ local xml = xmlCreateFile (' outfits.xml' , ' catalog' )
567
+ for row = 0 ,(guiGridListGetRowCount (outfitList )- 1 ) do
568
+ local child = xmlCreateChild (xml , ' outfit' )
569
+ xmlNodeSetAttribute (child , ' name' , guiGridListGetItemText (outfitList , row , 1 ))
570
+ for k ,v in pairs (outfits [row + 1 ]) do
571
+ xmlNodeSetAttribute (child , ' c' .. k ,v )
572
+ end
573
+ end
574
+ xmlSaveFile (xml )
575
+ xmlUnloadFile (xml )
576
+ end
577
+
578
+ function saveOutfit ()
579
+ local name = getControlText (wndOutfits ,' outfitname' )
580
+ if name ~= " " then
581
+ local row = guiGridListAddRow (outfitList )
582
+ outfits [row + 1 ] = {}
583
+ for i = 0 ,17 do
584
+ local texture ,model = getPedClothes (localPlayer , i )
585
+ if texture and model then
586
+ table.insert (outfits [row + 1 ], i , texture .. ' , ' .. model )
587
+ else
588
+ table.insert (outfits [row + 1 ], i , ' none' )
589
+ end
590
+ end
591
+ guiGridListSetItemText (outfitList , row , 1 , name , false , false )
592
+ setControlText (wndOutfits , ' outfitname' , ' ' )
593
+ saveOutfits ()
594
+ else
595
+ outputChatBox (' Please enter a name for the outfit' )
596
+ end
597
+ end
598
+
599
+ function deleteOutfit ()
600
+ local row = guiGridListGetSelectedItem (outfitList )
601
+ if row and row ~= - 1 then
602
+ table.remove (outfits , row + 1 )
603
+ guiGridListRemoveRow (outfitList , row )
604
+ saveOutfits ()
605
+ end
606
+ end
607
+
608
+ function loadClothes ()
609
+ local row = guiGridListGetSelectedItem (outfitList )
610
+ if row and row ~= - 1 then
611
+ for k ,v in pairs (outfits [row + 1 ]) do
612
+ if v ~= ' none' then
613
+ local clothes = split (v , ' , ' )
614
+ server .addPedClothes (localPlayer , clothes [1 ], clothes [2 ], k )
615
+ else
616
+ server .removePedClothes (localPlayer , k )
617
+ end
618
+ end
619
+ end
620
+ end
621
+
622
+ wndOutfits = {
623
+ ' wnd' ,
624
+ text = ' Outfits' ,
625
+ width = 170 ,
626
+ x = - 400 ,
627
+ y = 0.3 ,
628
+ controls = {
629
+ {
630
+ ' lst' ,
631
+ id = ' outfits' ,
632
+ width = 150 ,
633
+ height = 250 ,
634
+ columns = {
635
+ {text = ' Name' , attr = ' name' , width = 0.85 },
636
+ }
637
+ },
638
+ {' txt' , id = ' outfitname' , text = ' ' , width = 100 },
639
+ {' btn' , id = ' save' , onclick = saveOutfit , width = 45 },
640
+ {' btn' , id = ' delete selected' , onclick = deleteOutfit , width = 100 },
641
+ {' btn' , id = ' close' , closeswindow = true , width = 45 }
642
+ },
643
+ oncreate = initOutfits
644
+ }
529
645
---- -----------------------
530
646
-- Player gravity window
531
647
---- -----------------------
0 commit comments