Jump to content

ترتيب GridList بااسامي السيارات ؟؟


Booo

Recommended Posts

السلام عليكم ورحمة الله وببركاته

اخبااركم ياشباب ان شاء الله بخير

انا سويت

GridList

وفيها اسامي سيارات

بس المشكله الاسامي غير مرتبه يعنياسامي السيارات جايه مع الطيارات والخ

بغيت اسئلكم كيف اسوي لها ترتيب

يعني تجي اول شي

اسامي الطيارات

بعدين الهيلوكبتر

بعدين السيارات الي لها بابين

4 ابواب

دبابات

سيارات الفان

والخ

؟

Link to comment

تقدر تسوي لها ترتيب حسب الايدي

كيف حسب الايدي ؟

عندك الكود هذا

يالله خلني اشوف كيف بتسوي ترتيب :mrgreen:

  
vehicleIDS = { 602, 545, 496, 517, 401, 410, 518, 600, 527, 436, 589, 580, 419, 439, 533, 549, 526, 491, 474, 445, 467, 604, 426, 507, 547, 585, 
405, 587, 409, 466, 550, 492, 566, 546, 540, 551, 421, 516, 529, 592, 553, 577, 488, 511, 497, 548, 563, 512, 476, 593, 447, 425, 519, 520, 460, 
417, 469, 487, 513, 581, 510, 509, 522, 481, 461, 462, 448, 521, 468, 463, 586, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 485, 552, 431,  
438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 523, 470, 598, 499, 588, 609, 403, 498, 514, 524,  
423, 532, 414, 578, 443, 486, 515, 406, 531, 573, 456, 455, 459, 543, 422, 583, 482, 478, 605, 554, 530, 418, 572, 582, 413, 440, 536, 575, 534,  
567, 535, 576, 412, 402, 542, 603, 475, 449, 537, 538, 441, 464, 501, 465, 564, 568, 557, 424, 471, 504, 495, 457, 539, 483, 508, 571, 500,  
444, 556, 429, 411, 541, 559, 415, 561, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458,  
606, 607, 610, 590, 569, 611, 584, 608, 435, 450, 591, 594 } 
  
  
function changeGridlistToNameVehicle(gridlist,col) 
if not col then col = 1 end 
    if gridlist then 
        if getElementType ( GridList ) == "gui-gridlist" then 
        guiGridListClear (gridlist) 
            for k, v in pairs(vehicleIDS) do 
       guiGridListSetItemText (gridlist,guiGridListAddRow (gridlist),col,getVehicleNameFromModel(v), false, false ) 
            end 
    end 
    end 
end 
  
addEventHandler( "onClientResourceStart",resourceRoot, 
    function ( ) 
    local carsList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
    local column = guiGridListAddColumn(carsList, "cars", 0.85 ) 
changeGridlistToNameVehicle(carsList) 
  
end 
) 
  
  
  
  

ذا انت مسوي جدول استخدم


صآحي انت اسويها جدإول ؟؟

بيجي بكرإ وانا ماخلصت :mrgreen:

Link to comment

شكلك فاهم غلط

و كودك فية اغلاط

كود هيك راح يصير

vehicleIDS = { 602, 545, 496, 517, 401, 410, 518, 600, 527, 436, 589, 580, 419, 439, 533, 549, 526, 491, 474, 445, 467, 604, 426, 507, 547, 585, 
405, 587, 409, 466, 550, 492, 566, 546, 540, 551, 421, 516, 529, 592, 553, 577, 488, 511, 497, 548, 563, 512, 476, 593, 447, 425, 519, 520, 460, 
417, 469, 487, 513, 581, 510, 509, 522, 481, 461, 462, 448, 521, 468, 463, 586, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 485, 552, 431, 
438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 523, 470, 598, 499, 588, 609, 403, 498, 514, 524, 
423, 532, 414, 578, 443, 486, 515, 406, 531, 573, 456, 455, 459, 543, 422, 583, 482, 478, 605, 554, 530, 418, 572, 582, 413, 440, 536, 575, 534, 
567, 535, 576, 412, 402, 542, 603, 475, 449, 537, 538, 441, 464, 501, 465, 564, 568, 557, 424, 471, 504, 495, 457, 539, 483, 508, 571, 500, 
444, 556, 429, 411, 541, 559, 415, 561, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458, 
606, 607, 610, 590, 569, 611, 584, 608, 435, 450, 591, 594 } 
  
addEventHandler( "onClientResourceStart",resourceRoot, 
    function ( ) 
                local carsList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
                local column = guiGridListAddColumn(carsList, "cars", 0.85 ) 
                changeGridlistToNameVehicle( carsList, column ) 
        end 
) 
  
function changeGridlistToNameVehicle( gridlist, col ) 
    if gridlist then 
        if getElementType ( gridlist ) == "gui-gridlist" then 
                        guiGridListClear (gridlist) 
            for k, v in pairs(vehicleIDS) do 
                                local row = guiGridListAddRow (gridlist) 
                                if getVehicleNameFromModel(v) ~= "" then 
                                        guiGridListSetItemText( gridlist, row, col, getVehicleNameFromModel(v), false, false ) 
                                end 
                        end 
                end 
        end 
end 

وهد الكود بيرتب السيارات على حسب نوعها حطه تحت الجدول

  
table.sort( vehicleIDS, 
function(a, b) 
return getVehicleType(a) < getVehicleType(b) 
end 
) 
  
  

Link to comment
شكلك فاهم غلط

و كودك فية اغلاط

كود هيك راح يصير

vehicleIDS = { 602, 545, 496, 517, 401, 410, 518, 600, 527, 436, 589, 580, 419, 439, 533, 549, 526, 491, 474, 445, 467, 604, 426, 507, 547, 585, 
405, 587, 409, 466, 550, 492, 566, 546, 540, 551, 421, 516, 529, 592, 553, 577, 488, 511, 497, 548, 563, 512, 476, 593, 447, 425, 519, 520, 460, 
417, 469, 487, 513, 581, 510, 509, 522, 481, 461, 462, 448, 521, 468, 463, 586, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 485, 552, 431, 
438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 523, 470, 598, 499, 588, 609, 403, 498, 514, 524, 
423, 532, 414, 578, 443, 486, 515, 406, 531, 573, 456, 455, 459, 543, 422, 583, 482, 478, 605, 554, 530, 418, 572, 582, 413, 440, 536, 575, 534, 
567, 535, 576, 412, 402, 542, 603, 475, 449, 537, 538, 441, 464, 501, 465, 564, 568, 557, 424, 471, 504, 495, 457, 539, 483, 508, 571, 500, 
444, 556, 429, 411, 541, 559, 415, 561, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458, 
606, 607, 610, 590, 569, 611, 584, 608, 435, 450, 591, 594 } 
  
addEventHandler( "onClientResourceStart",resourceRoot, 
    function ( ) 
                local carsList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
                local column = guiGridListAddColumn(carsList, "cars", 0.85 ) 
                changeGridlistToNameVehicle( carsList, column ) 
        end 
) 
  
function changeGridlistToNameVehicle( gridlist, col ) 
    if gridlist then 
        if getElementType ( gridlist ) == "gui-gridlist" then 
                        guiGridListClear (gridlist) 
            for k, v in pairs(vehicleIDS) do 
                                local row = guiGridListAddRow (gridlist) 
                                if getVehicleNameFromModel(v) ~= "" then 
                                        guiGridListSetItemText( gridlist, row, col, getVehicleNameFromModel(v), false, false ) 
                                end 
                        end 
                end 
        end 
end 

وهد الكود بيرتب السيارات على حسب نوعها حطه تحت الجدول

  
table.sort( vehicleIDS, 
function(a, b) 
return getVehicleType(a) < getVehicleType(b) 
end 
) 
  
  

يخوي الكود صح

بس بالويكي حاطين بالجدول ارقام زياده

وتقدر تتجاوز الفراغات بالكود هذا

if getVehicleNameFromModel(v) ~= "" then

بالنسبه ياصاحبي لـ

table.sort( vehicleIDS,

function(a, b)

return getVehicleType(a) < getVehicleType(b)

end

)

مآاعتقد انك سويت شي

انا اقولك

ببداية الموضوع

يعني تجي اول شي

اسامي الطيارات

بعدين الهيلوكبتر

بعدين السيارات الي لها بابين

4 ابواب

دبابات

سيارات الفان

والخ

بس خلإص مايحتاج تتعب نفسك انا ضبطت كود !

يحل المشكله هذي

Link to comment

في طريقة اعرفها مدري تناسب لطلبكـ .. بس شفها :

local vehicles = {     } 
  
addEventHandler( "onClientResourceStart", resourceRoot, function(  ) 
  for i = 400, 611 do 
     if ( getVehicleNameFromModel ( i ) ~= "" ) then 
                 table.insert( vehicles, { theName = getVehicleNameFromModel ( i ) } ) 
              end 
         end 
     table.sort( vehicles, function(a, b) return a.theName < b.theName 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...