Jump to content

!! table طلب شرح للـ


PaiN^

Recommended Posts

GUIEditor_Grid = {} 
  
Vehicle = guiCreateWindow(453,218,302,379,"x[ Vehicle Systm ]x",false) 
guiSetVisible(Vehicle,false) 
guiSetAlpha (Vehicle, 1) 
GUIEditor_Button[5] = guiCreateButton (0.0795,0.8575,0.4007,0.1135,"x[ set ]x",true,Vehicle) 
GUIEditor_Button[4] = guiCreateButton (0.5166,0.8602,0.4007,0.1135,"x[ close ]x",true,Vehicle) 
GUIEditor_Grid[1] = guiCreateGridList(0.106,0.1214,0.7583,0.6887,true,Vehicle) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
guiGridListAddColumn(GUIEditor_Grid[1],"Vehicle  ",0.9) 
guiSetAlpha(GUIEditor_Grid[1],0.89999997615814) 
      
      
addEventHandler("onClientGUIClick",root,      
      
CarsTable = { 
    { "Sultan" }, 
    { "Banshee" }, 
    { "Cheetah" }, 
    { "Admiral" }, 
} 
        
for i, v in ipairs ( CarsTable ) do 
    local row = guiGridListAddRow ( GUIEditor_Grid[1] ) 
    guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, v[1], false, true ) 
    triggerServerEvent("CarsTable",localPlayer) 
    guiSetVisible(Vehicle,false) 
    showCursor(false) 
end 
  
  
  
  
marker = createMarker ( -3583.56934, -3001.66870, 44.00367, "cylinder", 2, 255, 0, 0, 255 ) 
  
addEventHandler("onClientMarkerHit",marker, 
  function (player) 
    if (getElementType (player) == "player") and (player == localPlayer) and not isPedInVehicle (player) then 
        guiSetVisible(Vehicle,true) 
        showCursor(true) 
        end 
    end 
) 

خطا ولا صح

Link to comment
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if source == [ButtonName] then  
            -- Add Your Code. 
        elseif source == [ButtonName] then -- Another Button 
            -- Add Your Code. 
        end 
    end 
) 

Link to comment
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if source == [ButtonName] then  
            -- Add Your Code. 
        elseif source == [ButtonName] then -- Another Button 
            -- Add Your Code. 
        end 
    end 
) 

كذا يا عنآد لو يضغط الزر بدون مايشيك ~_~ او يجيب السيارهـ اصلا ماراح يسوي الوظيفة المطلوبة اللي يبيها الاخ ~

Link to comment

جرب كذا بـما انك ماسويت لااي دي في الجدول /

GUIEditor_Grid = {} 
GUIEditor_Button = {} 
  
Vehicle = guiCreateWindow(453,218,302,379,"x[ Vehicle Systm ]x",false) 
guiSetVisible(Vehicle,false) 
guiSetAlpha (Vehicle, 1) 
GUIEditor_Button[5] = guiCreateButton (0.0795,0.8575,0.4007,0.1135,"x[ set ]x",true,Vehicle) 
GUIEditor_Button[4] = guiCreateButton (0.5166,0.8602,0.4007,0.1135,"x[ close ]x",true,Vehicle) 
GUIEditor_Grid[1] = guiCreateGridList(0.106,0.1214,0.7583,0.6887,true,Vehicle) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
local col = guiGridListAddColumn(GUIEditor_Grid[1],"Vehicle  ",0.9) 
guiSetAlpha(GUIEditor_Grid[1],0.89999997615814) 
      
      
CarsTable = { 
    { "Sultan" }, 
    { "Banshee" }, 
    { "Cheetah" }, 
    { "Admiral" }, 
} 
        
for i, v in ipairs ( CarsTable ) do 
    local row = guiGridListAddRow ( GUIEditor_Grid[1] ) 
    guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, v[1], false, true ) 
end 
  
  
  
  
marker = createMarker ( x,y,z, "cylinder", 2, 255, 0, 0, 255 ) 
  
addEventHandler("onClientMarkerHit",marker, 
  function (player) 
    if (getElementType (player) == "player") and (player == localPlayer) and not isPedInVehicle (player) then 
        guiSetVisible(Vehicle,true) 
        showCursor(true) 
        end 
    end 
) 
  
addEventHandler("onClientGUIClick",root, 
    function() 
                if (source == GUIEditor_Button[5]) then 
                        local row, col = guiGridListGetSelectedItem ( GUIEditor_Grid[1] )  
                        local get =  guiGridListGetItemText(GUIEditor_Grid[1], row, 1 )  
                        if ( row and col and row ~= -1 and col ~= -1 ) then 
                     if ( get == "Sultan" ) then 
                            triggerServerEvent("Sultan", localPlayer) 
                             guiSetVisible(Vehicle,false) 
                              showCursor(false) 
                        end 
                end 
        end 
end 
) 

راح يجيب كل كلام الجريد ليست انت سوي

elseif ( get == "الكلمة يعني السيارهـ اللي بالجدول") then

triggerServerEvent(...)

وعلى هذا النحو وهذي السيرفر :

addEvent("Sultan",true) 
addEventHandler("Sultan",root, 
function () 
local x,y,z = getElementPosition (source) 
Sultan = createVehicle (411,x,y,z) 
warpPedIntoVehicle(source,Sultan) 
end 
) 
Link to comment

جرب ماجربتة بس المفروض يشتغل ~

addEvent("Sultan",true) 
addEventHandler("Sultan",root, 
    function() 
    if getElementData ( source, "destroy" ) then 
      destroyElement ( getElementData( source, "destroy" )) 
end 
local x,y,z = getElementPosition (source) 
Sultan = createVehicle (411,x,y,z) 
warpPedIntoVehicle(source,Sultan) 
setElementData ( source,"destroy", Sultan ) 
                  end 
) 
Link to comment

فيه امكانية تختصر كودك بدال كثرة الإيفنت و التريقر

ليكون بالشكل التالي ..

-- Client Side 
GUIEditor_Grid = {} 
GUIEditor_Button = {} 
  
Vehicle = guiCreateWindow(453,218,302,379,"x[ Vehicle Systm ]x",false) 
guiSetVisible(Vehicle,false) 
guiSetAlpha (Vehicle, 1) 
GUIEditor_Button[5] = guiCreateButton (0.0795,0.8575,0.4007,0.1135,"x[ set ]x",true,Vehicle) 
GUIEditor_Button[4] = guiCreateButton (0.5166,0.8602,0.4007,0.1135,"x[ close ]x",true,Vehicle) 
GUIEditor_Grid[1] = guiCreateGridList(0.106,0.1214,0.7583,0.6887,true,Vehicle) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
col = guiGridListAddColumn(GUIEditor_Grid[1],"Vehicle  ",0.9) 
guiSetAlpha(GUIEditor_Grid[1],0.89999997615814) 
      
CarsTable = { 
    { "Sultan" }, 
    { "Banshee" }, 
    { "Cheetah" }, 
    { "Admiral" }, 
} 
        
for i, v in ipairs ( CarsTable ) do 
    local row = guiGridListAddRow ( GUIEditor_Grid[1] ) 
    guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, v[1], false, true ) 
end 
  
marker = createMarker ( x,y,z, "cylinder", 2, 255, 0, 0, 255 ) 
  
addEventHandler ( "onClientMarkerHit", marker, 
  function ( player ) 
        if ( getElementType ( player ) == "player" ) and ( player == localPlayer ) and not isPedInVehicle ( player ) then 
            guiSetVisible ( Vehicle, true ) 
            showCursor ( true ) 
        end 
    end 
) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if source == GUIEditor_Button[5] then 
            local aGet = guiGridListGetItemText ( GUIEditor_Grid[1], guiGridListGetSelectedItem ( GUIEditor_Grid[1] ), 1 ) 
            if aGet == "" then return end 
            triggerServerEvent ( "onSelectedVehicle", localPlayer, aGet ) 
            guiSetVisible ( Vehicle, false ) 
            showCursor ( false ) 
             
        elseif source == GUIEditor_Button[4] then 
            guiSetVisible ( Vehicle, false ) 
            showCursor ( false )             
        end 
    end 
) 

-- Server Side 
Vehicles = { } 
  
addEvent ( "onSelectedVehicle", true ) 
addEventHandler ( "onSelectedVehicle", root, 
    function ( vehicleName ) 
        if Vehicles [ source ] then 
            destroyElement ( Vehicles [ source ] )  
        end 
        local vName = getVehicleModelFromName ( vehicleName ) 
        if vName then 
            local x, y, z = getElementPosition ( source ) 
            Vehicles [ source ] = createVehicle ( vName, x, y, z ) 
            warpPedIntoVehicle ( source, Vehicles [ source ] ) 
        end 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if Vehicles [ source ] then 
            destroyElement ( Vehicles [ source ] )  
            Vehicles [ source ] = nil 
        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...