Jump to content

[ تمت الإفادة ]x استفسار عن كود


Recommended Posts

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

addEvent("opening", true) 
  
local vehiclesTable = { 
    ["ADMIN-CAR"] = 581, 
    ["NRG-500"] = 522, 
    ["ADMIN-CAR2"] = 462, 
    ["PCJ-600"] = 461, 
    ["ADMIN-CAR3"] = 521, 
    ["ADMIN-CAR4"] = 463, 
} 
  
theWindow = guiCreateWindow(478, 201, 296, 372, "Select a vehicle", false) 
guiWindowSetSizable(theWindow, false) 
guiSetVisible(theWindow, false) 
  
theGridList = guiCreateGridList(9, 21, 278, 243, false, theWindow) 
guiGridListAddColumn(theGridList, "Available vehicles :", 0.9) 
for i = 1, 15 do 
    guiGridListAddRow(theGridList) 
end 
guiGridListSetItemText(theGridList, 1, 1, "ADMIN-CAR", false, false) 
guiGridListSetItemText(theGridList, 2, 1, "NRG-500", false, false) 
guiGridListSetItemText(theGridList, 3, 1, "ADMIN-CAR2", false, false) 
guiGridListSetItemText(theGridList, 4, 1, "PCJ-600", false, false) 
guiGridListSetItemText(theGridList, 5, 1, "ADMIN-CAR3", false, false) 
guiGridListSetItemText(theGridList, 6, 1, "ADMIN-CAR4", false, false) 
Select = guiCreateButton(9, 270, 278, 38, "Select", false, theWindow) 
guiSetProperty(Select, "NormalTextColour", "FF") 
Close = guiCreateButton(10, 318, 277, 38, "Close", false, theWindow) 
guiSetProperty(Close, "NormalTextColour", "FF") 
  
addEventHandler("onClientGUIClick", root, 
    function() 
        if(source == Select)then 
            local row, col = guiGridListGetSelectedItem(theGridList) 
            local vehName = guiGridListGetItemText(theGridList, row, col) 
            if(vehName and vehiclesTable[vehName])then 
                guiSetVisible(theWindow, false) 
                guiSetInputEnabled(false) 
                if(vehName == "Sultan")then 
                    triggerServerEvent("spawningAVehicle", localPlayer, vehiclesTable[vehName], "Special") 
                end 
                triggerServerEvent("spawningAVehicle", localPlayer, vehiclesTable[vehName], "Else") 
            end 
        elseif(source == Close)then 
            guiSetVisible(theWindow, false) 
            guiSetInputEnabled(false) 
        end 
    end 
) 
  
addEventHandler("opening", root, 
    function(state) 
        if(state == "true")then 
            guiSetVisible(theWindow, true) 
            guiSetInputEnabled(true) 
        elseif(state == "false")then 
            guiSetVisible(theWindow, false) 
            guiSetInputEnabled(false) 
        end 
    end 

هذا ملف العلامه الي تبان يليت تفيدوني

addEvent("spawningAVehicle", true) 
  
local Marker = createMarker(218.54807, 1862.53955, 13.140625-1, "cylinder", 1.5, 255, 0, 0, 180) 
  
addEventHandler("onMarkerHit", Marker, 
    function(hitElem) 
        if(getElementType(hitElem) == "player")then 
            if not(isPedInVehicle(hitElem))then 
                triggerClientEvent(hitElem, "opening", hitElem, "true") 
            end 
        end 
    end 
) 
  
local Upgrades = {1138, 1031, 1033, 1010, 1087, 1098, 1029, 1170, 1141} 
local vehicles = {} 
  
addEventHandler("spawningAVehicle", root, 
    function(model, state) 
        if(state == "Special")then 
            if(isElement(vehicles[ client ]))then 
                destroyElement(vehicles[ client ]) 
                vehicles[ client ] = nil 
            end 
            vehicles[ client ] = createVehicle(model, getElementPosition(client)) 
            setElementData(vehicles[ client ], "adminVehicle", "none") 
            setVehicleDamageProof(vehicles[ client ], true) 
            for i = 1, #Upgrades do 
                addVehicleUpgrade(vehicles[ client ], Upgrades[i]) 
            end 
            warpPedIntoVehicle(client, vehicles[ client ]) 
        elseif(state == "Else")then 
            if(isElement(vehicles[ client ]))then 
                destroyElement(vehicles[ client ]) 
                vehicles[ client ] = nil 
            end 
            vehicles[ client ] = createVehicle(model, getElementPosition(client)) 
            setElementData(vehicles[ client ], "adminVehicle", "none") 
            setVehicleDamageProof(vehicles[ client ], true) 
            warpPedIntoVehicle(client, vehicles[ client ]) 
        end 
    end 
) 
  
addEventHandler("onPlayerQuit", root, 
    function() 
        if(vehicles[ source ])then 
            destroyElement(vehicles[ source ]) 
            vehicles[ source ] = nil 
        end 
    end 
) 

Link to comment

يَ ليت توضح كلآمكـ إذا كنت تبي تسوي قائمتين وحدة الإسم والثانية الأي دي جرب ذآ

-- Client Side 
addEvent("opening", true) 
  
local vehiclesTable = { 
    {"ADMIN-CAR", 581}, 
    {"NRG-500", 522}, 
    {"ADMIN-CAR2", 462}, 
    {"PCJ-600", 461}, 
    {"ADMIN-CAR3", 521}, 
    {"ADMIN-CAR4", 463}, 
} 
  
theWindow = guiCreateWindow(478, 201, 296, 372, "Select a vehicle", false) 
guiWindowSetSizable(theWindow, false) 
guiSetVisible(theWindow, false) 
  
theGridList = guiCreateGridList(9, 21, 278, 243, false, theWindow) 
cl1 = guiGridListAddColumn(theGridList, "Available vehicles :", 0.6) 
cl2 = guiGridListAddColumn(theGridList, "ID", 0.3) 
for _, v in ipairs ( vehiclesTable ) do 
    local row = guiGridListAddRow ( theGridList ) 
    guiGridListSetItemText ( theGridList, row, cl1, tostring(v[1]), false, true) 
    guiGridListSetItemText ( theGridList, row, cl2, tostring(v[2]), false, true) 
end 
Select = guiCreateButton(9, 270, 278, 38, "Select", false, theWindow) 
guiSetProperty(Select, "NormalTextColour", "FF") 
Close = guiCreateButton(10, 318, 277, 38, "Close", false, theWindow) 
guiSetProperty(Close, "NormalTextColour", "FF") 
  
addEventHandler("onClientGUIClick", root, 
    function() 
        if(source == Select)then 
            local vehName = guiGridListGetItemText ( theGridList, guiGridListGetSelectedItem ( theGridList ), 2 ) 
            if vehName ~= "" or vehName ~= " " then 
                guiSetVisible ( theWindow, false ) 
                guiSetInputEnabled ( false ) 
                if vehName == "Sultan" then 
                    triggerServerEvent("spawningAVehicle", localPlayer, vehName, "Special") 
                else 
                    triggerServerEvent("spawningAVehicle", localPlayer, vehName, "Else")                 
                end 
            end 
        elseif(source == Close)then 
            guiSetVisible(theWindow, false) 
            guiSetInputEnabled(false) 
        end 
    end 
) 
  
addEventHandler("opening", root, 
    function(state) 
        if(state == "true")then 
            guiSetVisible(theWindow, true) 
            guiSetInputEnabled(true) 
        elseif(state == "false")then 
            guiSetVisible(theWindow, false) 
            guiSetInputEnabled(false) 
        end 
    end 
) 

-- Server Side 
addEvent("spawningAVehicle", true) 
  
local Marker = createMarker(218.54807, 1862.53955, 13.140625-1, "cylinder", 1.5, 255, 0, 0, 180) 
  
addEventHandler("onMarkerHit", Marker, 
    function(hitElem) 
        if(getElementType(hitElem) == "player")then 
            if not(isPedInVehicle(hitElem))then 
                triggerClientEvent(hitElem, "opening", hitElem, "true") 
            end 
        end 
    end 
) 
  
local Upgrades = {1138, 1031, 1033, 1010, 1087, 1098, 1029, 1170, 1141} 
local vehicles = {} 
  
addEventHandler("spawningAVehicle", root, 
    function(model, state) 
        if(state == "Special")then 
            if(isElement(vehicles[ client ]))then 
                destroyElement(vehicles[ client ]) 
                vehicles[ client ] = nil 
            end 
            vehicles[ client ] = createVehicle(model, getElementPosition(client)) 
            setElementData(vehicles[ client ], "adminVehicle", "none") 
            setVehicleDamageProof(vehicles[ client ], true) 
            for i = 1, #Upgrades do 
                addVehicleUpgrade(vehicles[ client ], Upgrades[i]) 
            end 
            warpPedIntoVehicle(client, vehicles[ client ]) 
        elseif(state == "Else")then 
            if(isElement(vehicles[ client ]))then 
                destroyElement(vehicles[ client ]) 
                vehicles[ client ] = nil 
            end 
            vehicles[ client ] = createVehicle(model, getElementPosition(client)) 
            setElementData(vehicles[ client ], "adminVehicle", "none") 
            setVehicleDamageProof(vehicles[ client ], true) 
            warpPedIntoVehicle(client, vehicles[ client ]) 
        end 
    end 
) 
  
addEventHandler("onPlayerQuit", root, 
    function() 
        if(vehicles[ source ])then 
            destroyElement(vehicles[ source ]) 
            vehicles[ source ] = nil 
        end 
    end 
) 

Link to comment

ياعناد انا قصدي اسوي علامتين يعني احط علامتين وفي كل علامه اروح فيها تفتح لي قائمة هنا سيارات مثلا وهنا دبابات بس اذ دخلت في علامه تطلع قائمه وحده بس نا تجيني قائمتين ماعرفت لها يليلت تكون فهمتني :$

Edited by Guest
Link to comment

وبعدين اذ ضغطت على سياره في علامه حقتها ولا على دباب في العلامه حقته يطلع سياره وحده بس ولا دباب واحد بس مابيهم يطلعون اثنين هنا ولا هنا

Edited by Guest
Link to comment

-- Client Side

GUIEditor_Window = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(478, 201, 296, 372, "Select a vehicle", false) 
guiSetVisible ( GUIEditor_Window[1] , false ) 
GUIEditor_Grid[1] = guiCreateGridList(9, 21, 278, 243, false, GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
guiGridListAddColumn(GUIEditor_Grid[1], "Available vehicles :", 0.9) 
  
aCars = 
{ 
    --[[{ 'Car Name', Id Car };]] 
    { 'Camry', 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( 'giveCar', 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 
) 

-- Server Side

vehicle = { } 
  
addEvent( 'giveCar', true ) 
addEventHandler( 'giveCar', getRootElement( ), 
    function( ID ) 
        if isElement( vehicle[ source ] ) then 
            destroyElement( vehicle[ source ] ) 
            vehicle[ source ] = nil 
        end 
        vehicle[ source ] = createVehicle( ID , getElementPosition( source ) ) 
        warpPedIntoVehicle( source, vehicle[ source ] ) 
    end 
) 
  
addEventHandler( 'onPlayerQuit', getRootElement( ), 
    function( ) 
        if isElement( vehicle[ source ] ) then 
            destroyElement( vehicle[ source ] ) 
            vehicle[ source ] = nil 
        end 
    end 
) 

Link to comment
-- Client Side
GUIEditor_Window = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(478, 201, 296, 372, "Select a vehicle", false) 
guiSetVisible ( GUIEditor_Window[1] , false ) 
GUIEditor_Grid[1] = guiCreateGridList(9, 21, 278, 243, false, GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
guiGridListAddColumn(GUIEditor_Grid[1], "Available vehicles :", 0.9) 
  
aCars = 
{ 
    --[[{ 'Car Name', Id Car };]] 
    { 'Camry', 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( 'giveCar', 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 
) 

-- Server Side

vehicle = { } 
  
addEvent( 'giveCar', true ) 
addEventHandler( 'giveCar', getRootElement( ), 
    function( ID ) 
        if isElement( vehicle[ source ] ) then 
            destroyElement( vehicle[ source ] ) 
            vehicle[ source ] = nil 
        end 
        vehicle[ source ] = createVehicle( ID , getElementPosition( source ) ) 
        warpPedIntoVehicle( source, vehicle[ source ] ) 
    end 
) 
  
addEventHandler( 'onPlayerQuit', getRootElement( ), 
    function( ) 
        if isElement( vehicle[ source ] ) then 
            destroyElement( vehicle[ source ] ) 
            vehicle[ 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...