Jump to content

GridList


Bo7meeeD

Recommended Posts

انظر على المثال

guiGridListGetItemData :

function clientsideResourceStart () 
    local numberList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
    local column = guiGridListAddColumn ( numberList, "Column Title", 0.85 ) 
    if ( column ) then 
        local row = guiGridListAddRow ( numberList ) 
        local myItem = guiGridListSetItemText ( numberList, row, column, tostring( math.random(0, 10) ^ 100 ), false, false ) 
        local myItemData = guiGridListGetItemData ( numberList, row, column ) 
        outputChatBox ( "My gridlist item data: " .. myItemData ) 
    end 
end 
addEventHandler ( "onClientResourceStart", getRootElement(), clientsideResourceStart ) 

guiGridListSetItemData:

function showPlayers() 
    local window = guiCreateWindow(0,0,500,400,"Window example - Title",false) -- Create the window 
    grid = guiCreateGridList(0,0,100,300,false,window) -- Create the gridlist 
    local column = guiGridListAddColumn(grid, "Players online", 0.9) -- Create a column 
    showCursor(true)--show cursor 
    for index,player in ipairs(getElementsByType("player")) do -- Loop through all players 
        local row = guiGridListAddRow(grid) -- Add a row 
        guiGridListSetItemText ( grid, row, column, (string.gsub ( getPlayerName(player), '#%x%x%x%x%x%x', '' ) or getPlayerName(player)), false, false) -- Set it's text to the player's name excluding colorcodes 
        guiGridListSetItemData ( grid, row, column, getPlayerName(player)) -- Set it's data to the player's name with colorcodes 
    end 
end 
  
function outputPlayerName() 
    if source == grid then -- If the player clicked something in the grid 
        local selectedRow, selectedColumn = guiGridListGetSelectedItem(grid) -- See which player he selected 
        local playerName = guiGridListGetItemData(grid, selectedRow, selectedColumn) -- Get the selected player's name with color codes   local playerNameWithoutColorCodes = guiGridListGetItemText(grid, selectedRow, selectedColumn) -- Get the selected player's name without color codes 
        local playerNameWithoutColorCodes = guiGridListGetItemText(grid, selectedRow, selectedColumn) -- Get the selected player's name without color codes 
        if playerName and playerNameWithoutColorCodes then -- If he really selected something 
            outputChatBox("The selected player's name without color codes : "..playerNameWithoutColorCodes, 255,255,255,false) -- output without color codes 
            outputChatBox("The selected player's name with color codes : "..playerName, 255,255,255,false) -- output with color codes 
            outputChatBox("The selected player's name with colors : "..playerName, 255,255,255,true) -- output with colors 
        end 
    end 
end 
  
addEventHandler("onClientGUIClick", getRootElement(), outputPlayerName) 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), showPlayers) 

Link to comment

حق وش استخدمها ؟

تعطي قيمة للنص في القريد وهذي القيمة تكون مهيب ظاهرة .

انا لسى ما عرفت اسوي الجريد لست

حاولت فيها

شباب وش الغلط ؟

GUIEditor_Window = {} 
GUIEditor_Grid = {} 
  
local mohamad = {} 
GUIEditor_Window[1] = guiCreateWindow(250,128,321,319,"",false) 
guiSetVisible (  GUIEditor_Window[1],false ) 
GUIEditor_Grid[1] = guiCreateGridList(9,23,303,283,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
mohamad.give1 = guiGridListAddRow(GUIEditor_Grid[1]) 
mohamad.give2 = guiGridListAddRow(GUIEditor_Grid[1]) 
guiGridListAddColumn(GUIEditor_Grid[1],"players",0.2) 
guiGridListSetItemText(GUIEditor_Grid[1],mohamad.give1,1,"Skin 1",1,false,false) 
guiGridListSetItemText(GUIEditor_Grid[1],mohamad.give2,1,"fdjdfd",1,false,false) 
  
  
Marker1 = createMarker(1467.2055664063, -1012.4879150391, 28.84375, 'arrow', 2.5, 0, 0, 255, 150) 
addEventHandler("onClientMarkerHit", root, 
function () 
if ( source == Marker1 ) then  
guiSetVisible (  GUIEditor_Window[1],true ) 
end 
   end  
   ) 
    
addEventHandler("onClientGUIClick", GUIEditor_Grid[1], 
    function() 
        for i, v in pairs( mohamad ) do 
            if( guiGridListGetSelectedItem(source) == v )then 
            triggerServerEvent ( "give", localPlayer ) 
end 
   end  
      end ) 
       
  

Link to comment
GUIEditor_Window = {} 
GUIEditor_Grid = {} 
GUIEditor_Window[1] = guiCreateWindow(250,128,321,319,"",false) 
guiSetVisible( GUIEditor_Window[1], false ) 
GUIEditor_Grid[1] = guiCreateGridList( 9,23,303,283, false, GUIEditor_Window[1] ) 
guiGridListSetSelectionMode( GUIEditor_Grid[1], 2 ) 
guiGridListAddColumn( GUIEditor_Grid[1], 'Skins', 0.80 ) 
  
aSkins = 
{ 
    --[[{ 'Name Skin', ID Skin };]] 
    { 'Skin`1', 46 }; 
    { 'Skin`2', 47 }; 
    { 'Skin`3', 48 }; 
} 
  
for _, aSkin in ipairs( aSkins )do 
    local gRow = guiGridListAddRow( GUIEditor_Grid[1] ) 
    guiGridListSetItemText( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aSkin[ 1 ] ), false, false  
    ) 
    guiGridListSetItemData( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aSkin[ 2 ] ) 
    ) 
end 
     
addEventHandler( 'onClientGUIDoubleClick', GUIEditor_Grid[1], 
    function( ) 
        local iRow, iCol = guiGridListGetSelectedItem( GUIEditor_Grid[1] ) 
        if( iRow and iCol and iRow ~= -1 and iCol ~= -1 )then 
            local ID_Skin = tonumber( guiGridListGetItemData( GUIEditor_Grid[1], iRow, 1 ) ) 
            if ID_Skin ~= '' then 
                setElementModel( localPlayer, ID_Skin ) 
                guiSetVisible( GUIEditor_Window[1], false ) 
                showCursor( false ) 
            end 
        end 
    end, false 
) 
  
Marker1 = createMarker( 1467, -1012, 28, 'arrow', 2.5, 0, 0, 255, 150 ) 
  
addEventHandler( 'onClientMarkerHit', Marker1, 
    function( hitPlayer ) 
        if hitPlayer == localPlayer then 
            guiSetVisible( GUIEditor_Window[1], true ) 
            showCursor( true ) 
        end 
    end 
) 

Link to comment

انا حاولت اسوي يعطيك سيارة ضبط بس مشكلته اي شي تضغط عليه دبل كلك ينفذ الوظيفة

هذا الكود

GUIEditor_Window = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(275,125,292,313,"",false) 
guiSetVisible ( GUIEditor_Window[1] , false ) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
  
  
  
 cars = 
            { 
            {"Befalow"}, 
            } 
             
 GUIEditor_Grid[1] = guiCreateGridList(9,23,274,281,false,GUIEditor_Window[1]) 
 guiGridListAddColumn(GUIEditor_Grid[1],"vehicles",0.2) 
      
    for i,veh in ipairs(cars) do 
         row = guiGridListAddRow( GUIEditor_Grid[1]) 
         -- 
         guiGridListSetItemText( GUIEditor_Grid[1], row, 1, tostring(veh[1]), false, false) 
         guiGridListSetItemData( GUIEditor_Grid[1], row, 1, tostring(veh[2])) 
    end 
      
    function use() 
         local row, col = guiGridListGetSelectedItem( GUIEditor_Grid[1])   
         if (row and col and row ~= -1 and col ~= -1) then 
              local model = tonumber(guiGridListGetItemData( GUIEditor_Grid[1], row, 1)) 
              if model ~= "" then 
                   triggerServerEvent("BB", localPlayer) 
                   guiSetVisible ( GUIEditor_Window[1] , false ) 
                   showCursor ( false )  
              end 
         end 
    end 
    addEventHandler("onClientDoubleClick", root, use, false) 
     
Marker1 = createMarker(0, 0, 4, 'arrow', 2.5, 0, 0, 255, 150) 
  
addEventHandler("onClientMarkerHit", root, 
function () 
if ( source == Marker1 ) then  
guiSetVisible ( GUIEditor_Window[1] , true ) 
showCursor ( true )  
end 
   end ) 

ابغى حل للمشكله

طبعا الكود مو كامل انا مسويه حملت مود وتعلمت منه

Link to comment
GUIEditor_Window = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(275,125,292,313,"",false) 
guiSetVisible ( GUIEditor_Window[1] , false ) 
GUIEditor_Grid[1] = guiCreateGridList(9,23,274,281,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
guiGridListAddColumn(GUIEditor_Grid[1],"vehicles",0.2) 
  
aCars = 
{ 
    { 'Befalow', 411 }; 
} 
  
for _, aCar in ipairs( aCars )do 
    local gRow = guiGridListAddRow( GUIEditor_Grid[1] ) 
    guiGridListSetItemText( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aCar[ 1 ] ), false, false  
    ) 
    guiGridListSetItemData( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aCar[ 2 ] ) 
    ) 
end 
  
addEventHandler( 'onClientGUIDoubleClick', GUIEditor_Grid[1], 
    function( ) 
        local iRow, iCol = guiGridListGetSelectedItem( GUIEditor_Grid[1] ) 
        if( iRow and iCol and iRow ~= -1 and iCol ~= -1 )then 
            local ID_Car = tonumber( guiGridListGetItemData( GUIEditor_Grid[1], iRow, 1 ) ) 
            if ID_Car ~= '' then 
                triggerServerEvent( 'BB', localPlayer, ID_Car ) 
                guiSetVisible( GUIEditor_Window[1], false ) 
                showCursor( false ) 
            end 
        end 
    end, false 
) 
  
Marker1 = createMarker( 0, 0, 4, 'arrow', 2.5, 0, 0, 255, 150 ) 
  
addEventHandler( 'onClientMarkerHit', Marker1, 
    function( hitPlayer ) 
        if hitPlayer == localPlayer then 
            guiSetVisible( GUIEditor_Window[1], true ) 
            showCursor( true ) 
        end 
    end 
) 

اذا ماضبط المشكلة من كود السيرفر اطرحه .

Edited by Guest
Link to comment
GUIEditor_Window = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(275,125,292,313,"",false) 
guiSetVisible ( GUIEditor_Window[1] , false ) 
GUIEditor_Grid[1] = guiCreateGridList(9,23,274,281,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
guiGridListAddColumn(GUIEditor_Grid[1],"vehicles",0.2) 
  
aCars = 
{ 
    { 'Befalow', 411 }; 
} 
  
for _, aCar in ipairs( aCars )do 
    local gRow = guiGridListAddRow( GUIEditor_Grid[1] ) 
    guiGridListSetItemText( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aCars[ 1 ] ), false, false  
    ) 
    guiGridListSetItemData( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aCars[ 2 ] ) 
    ) 
end 
  
addEventHandler( 'onClientGUIDoubleClick', GUIEditor_Grid[1], 
    function( ) 
        local iRow, iCol = guiGridListGetSelectedItem( GUIEditor_Grid[1] ) 
        if( iRow and iCol and iRow ~= -1 and iCol ~= -1 )then 
            local ID_Car = tonumber( guiGridListGetItemData( GUIEditor_Grid[1], iRow, 1 ) ) 
            if ID_Car ~= '' then 
                triggerServerEvent( 'BB', localPlayer, ID_Car ) 
                guiSetVisible( GUIEditor_Window[1], false ) 
                showCursor( false ) 
            end 
        end 
    end, false 
) 
  
Marker1 = createMarker( 0, 0, 4, 'arrow', 2.5, 0, 0, 255, 150 ) 
  
addEventHandler( 'onClientMarkerHit', Marker1, 
    function( hitPlayer ) 
        if hitPlayer == localPlayer then 
            guiSetVisible( GUIEditor_Window[1], true ) 
            showCursor( true ) 
        end 
    end 
) 

اذا ماضبط المشكلة من كود السيرفر اطرحه .

GUIEditor_Window = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(275,125,292,313,"",false) 
guiSetVisible ( GUIEditor_Window[1] , false ) 
GUIEditor_Grid[1] = guiCreateGridList(9,23,274,281,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
guiGridListAddColumn(GUIEditor_Grid[1],"vehicles",0.2) 
  
local aCars = {'Befalow', 411} 
for _, aCar in ipairs( aCars )do 
    local gRow = guiGridListAddRow( GUIEditor_Grid[1] ) 
    guiGridListSetItemText( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aCars[ 1 ] ), false, false  
    ) 
    guiGridListSetItemData( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aCars[ 2 ] ) 
    ) 
end 
  
addEventHandler( 'onClientGUIDoubleClick', GUIEditor_Grid[1], 
    function( ) 
        local iRow, iCol = guiGridListGetSelectedItem( GUIEditor_Grid[1] ) 
        if( iRow and iCol and iRow ~= -1 and iCol ~= -1 )then 
            local ID_Car = tonumber( guiGridListGetItemData( GUIEditor_Grid[1], iRow, 1 ) ) 
            if ID_Car ~= '' then 
                triggerServerEvent( 'BB', localPlayer, ID_Car ) 
                guiSetVisible( GUIEditor_Window[1], false ) 
                showCursor( false ) 
            end 
        end 
    end, false 
) 
  
Marker1 = createMarker( 0, 0, 4, 'arrow', 2.5, 0, 0, 255, 150 ) 
  
addEventHandler( 'onClientMarkerHit', Marker1, 
    function( hitPlayer ) 
        if hitPlayer == localPlayer then 
            guiSetVisible( GUIEditor_Window[1], true ) 
            showCursor( true ) 
        end 
    end 
) 

مشكلتك هنا انك كنت مسوي جدول داخل جدول ومستخدم

ipairs

Link to comment

شكرا تيتي على التجربة ولكن المشكلة مهيب هنا

for _, aCar in ipairs( aCars )do 
    local gRow = guiGridListAddRow( GUIEditor_Grid[1] ) 
    guiGridListSetItemText( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aCars[ 1 ] ), false, false  
    ) 
    guiGridListSetItemData( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aCars[ 2 ] ) 
    ) 
end 

في اللوب انا حاط aCar

ويوم جيت اضيف النص للقريد حطيت

aCars

P.S: انا معدل كود الشخصيات الي فوق عشان كذا نسيت + تم تعديل ردي .

Link to comment

انا اعرفها لكن هذي ماراح تحقق فائدة ابدا في الكود هذا

gRow = guiGridListAddRow( GUIEditor_Grid[1] ) 
guiGridListSetItemText( GUIEditor_Grid[1], 
    gRow, 
    1, tostring( aCars[ 1 ][ 1 ] ), false, false  
) 

يعني لو تبي تسويها بهذي الطريقة راح تكرر الكود على كل سيارة تضيفها اللوب يختصر لك

Link to comment

الكودين الي فوق كلها خطأ

aCars = 
{ 
    { 'Befalow', 411 }; -- مسوي جدولين في بعض عشان تسهل اضافة السيارات للقريد  
    { 'Car', 581 };  
} 
  
for _, aCar in ipairs( aCars )do 
    local gRow = guiGridListAddRow( GUIEditor_Grid[1] ) --  اللوب راح يكرر مرتين راح يسوي صفين يعني على عدد الجدول 
    guiGridListSetItemText( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aCar[ 1 ] ), false, false  
    ) 
    guiGridListSetItemData( GUIEditor_Grid[1], 
        gRow, 
        1, tostring( aCar[ 2 ] ) 
    ) 
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...