Jump to content

جدول سيارات


Recommended Posts

شباب انا مسوي معرض

بس ابي لما تجي النافضة يكون اسم السيارة في القريد ليست اسم اختياري مو اسم السيارة الاصلي

هم كودين

for i,v in ipairs (cars) do 
    local carName = getVehicleNameFromModel (v[1]) 
    local row = guiGridListAddRow (carGridList) 
    guiGridListSetItemText (carGridList, row, 1, carName, false, true) 
    guiGridListSetItemText (carGridList, row, 2, tostring(v[2]), false, true) 
end 

function onClientGUIClick (button, state, absoluteX, absoluteYe) 
  if (source == buyButton) then guiSetVisible (carshopWindow, false) showCursor (false) 
    if (guiGridListGetSelectedItem (carGridList)) then 
      local carName = guiGridListGetItemText (carGridList, guiGridListGetSelectedItem (carGridList), 1) 
      local carID = getVehicleModelFromName (carName) 
      local carCost = guiGridListGetItemText (carGridList, guiGridListGetSelectedItem (carGridList), 2) 
      triggerServerEvent ("carShopCarBuy", getLocalPlayer(), carID, carCost, carName) 
    end 
end 

Link to comment

نفسي افهم ليش محد يرد وش فيكم ماتردون؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟

Link to comment

شباب الكود الاول حليت مشكلته بس الثاني بحط الكودين:كاملين

function onClientGUIClick (button, state, absoluteX, absoluteYe) 
  if (source == buyButton) then guiSetVisible (carshopWindow, false) showCursor (false) 
    if (guiGridListGetSelectedItem (carGridList)) then 
      local carName = guiGridListGetItemText (carGridList, guiGridListGetSelectedItem (carGridList), 1) 
      local carID = getVehicleModelFromName (carName) 
      local carCost = guiGridListGetItemText (carGridList, guiGridListGetSelectedItem (carGridList), 2) 
      triggerServerEvent ("carShopCarBuy", getLocalPlayer(), carID, carCost, carName) 
    end 
  elseif (source == closeButton) then 
  guiSetVisible (carshopWindow, false) 
  showCursor (false) 
  end 
end 
2-- 
local cars = {{411,"gallardo",1900000}} 
for i,v in ipairs (cars) do 
    local row = guiGridListAddRow (carGridList) 
    guiGridListSetItemText (carGridList, row, 1, tostring(v[2]), false, true) 
    guiGridListSetItemText (carGridList, row, 2, tostring(v[3]), false, true) 
end 

كيف اخلي الكود الاول يطلع ايدي السيارة من الجدول ان شاء الله رد

Link to comment

سوي جدول مع اي دي السياره,

Vehicles = { 
    {'Ford',435}, 
-- {carName,ID} 
} 

واستخدم اللوب عشان تضيف الكلام,

for k,v in ipairs(Vehicles) do 
    local row = guiGridListAddRow(carGridList) 
        guiGridListSetItemText(carGridList,row,1,v[1],false,false) 
            guiGridListSetItemData(carGridList,row,1,v[2]) 
end 

وتسوي حدث اذا ضغط الزر ,

addEventHandler('onClientGUIClick',buyButton,function() 
    if guiGridListGetSelectedItem(carGridList) ~= -1 then 
        local car = guiGridListGetItemData ( carGridList,guiGridListGetSelectedItem ( carGridList ), 1) 
            triggerServerEvent('CreateCarForPlayer',localPlayer,car) 
    end 
end,false) 

وكمل السيرفر

Link to comment

والله مانفع كودك جربت بس مانفع

function onClientGUIClick (button, state, absoluteX, absoluteYe) 
  if (source == buyButton) then guiSetVisible (carshopWindow, false) showCursor (false) 
    if (guiGridListGetSelectedItem (carGridList)) then 
      local car = guiGridListGetItemData ( carGridList,guiGridListGetSelectedItem ( carGridList ), 1) 
      local carCost = guiGridListGetItemText (carGridList, guiGridListGetSelectedItem (carGridList), 2) 
      triggerServerEvent("carShopCarBuy",getLocalPlayer(),car,carCost) 
    end 
  elseif (source == closeButton) then 
  guiSetVisible (carshopWindow, false) 
  showCursor (false) 
  end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), onClientGUIClick) 

2

for i,v in ipairs (cars) do 
    local row = guiGridListAddRow (carGridList) 
    guiGridListSetItemText (carGridList, row, 1, tostring(v[1]), false, true) 
    guiGridListSetItemText (carGridList, row, 2, tostring(v[3]), false, true) 
    guiGridListSetItemData(carGridList,row,1,v[2]) 
end 

Link to comment

جرب,

-- Client Side # 
local Vehicles = { 
    {'Ford',10000,602}, 
 -- {carName,money,ID} 
} 
  
for k,v in ipairs(Vehicles) do 
    local row = guiGridListAddRow(carGridList) 
        guiGridListSetItemText(carGridList,row,1,v[1],false,false) 
        guiGridListSetItemText(carGridList,row,2,v[2],false,false) 
        guiGridListSetItemData(carGridList,row,2,v[2]) 
        guiGridListSetItemData(carGridList,row,1,v[3]) 
end 
  
addEventHandler('onClientGUIClick',root,function() 
    if source == buyButton then 
        if guiGridListGetSelectedItem(carGridList) ~= -1 then 
            local car = guiGridListGetItemData ( carGridList,guiGridListGetSelectedItem ( carGridList ), 1) 
            local money = guiGridListGetItemData ( carGridList,guiGridListGetSelectedItem ( carGridList ), 2) 
                triggerServerEvent('CreateCarForPlayer',localPlayer,car,money) 
    elseif source == closeButton then  
        guiSetVisible (carshopWindow, false)  
            showCursor (false) 
        end 
    end 
end) 

-- Server Side # 
local vehicle = {} 
  
addEvent('CreateCarForPlayer',true) 
addEventHandler('CreateCarForPlayer',root,function(model,money) 
    if getPlayerMoney(source) >= tonumber(money) then 
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) vehicle[source] = nil end 
            local x,y,z = getElementPosition(source) 
                vehicle[source] = createVehicle(tonumber(model),x,y,z) 
                    warpPedIntoVehicle(source,vehicle[source]) 
                        takePlayerMoney(source,tonumber(money)) 
        end 
    end 
) 
  
addEventHandler('onPlayerQuit',root,function() 
    if isElement(vehicle[source]) then  
        destroyElement(vehicle[source])  
            vehicle[source] = nil  
        end 
    end 
) 
Link to comment

شباب خلاص تم حل المشكلة وشكرا يا ذابيست على كود

guiGridListSetItemData

edit:

جرب,

-- Client Side # 
local Vehicles = { 
    {'Ford',10000,602}, 
 -- {carName,money,ID} 
} 
  
for k,v in ipairs(Vehicles) do 
    local row = guiGridListAddRow(carGridList) 
        guiGridListSetItemText(carGridList,row,1,v[1],false,false) 
        guiGridListSetItemText(carGridList,row,2,v[2],false,false) 
        guiGridListSetItemData(carGridList,row,2,v[2]) 
        guiGridListSetItemData(carGridList,row,1,v[3]) 
end 
  
addEventHandler('onClientGUIClick',root,function() 
    if source == buyButton then 
        if guiGridListGetSelectedItem(carGridList) ~= -1 then 
            local car = guiGridListGetItemData ( carGridList,guiGridListGetSelectedItem ( carGridList ), 1) 
            local money = guiGridListGetItemData ( carGridList,guiGridListGetSelectedItem ( carGridList ), 2) 
                triggerServerEvent('CreateCarForPlayer',localPlayer,car,money) 
    elseif source == closeButton then  
        guiSetVisible (carshopWindow, false)  
            showCursor (false) 
        end 
    end 
end) 

-- Server Side # 
local vehicle = {} 
  
addEvent('CreateCarForPlayer',true) 
addEventHandler('CreateCarForPlayer',root,function(model,money) 
    if getPlayerMoney(source) >= tonumber(money) then 
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) vehicle[source] = nil end 
            local x,y,z = getElementPosition(source) 
                vehicle[source] = createVehicle(tonumber(model),x,y,z) 
                    warpPedIntoVehicle(source,vehicle[source]) 
                        takePlayerMoney(source,tonumber(money)) 
        end 
    end 
) 
  
addEventHandler('onPlayerQuit',root,function() 
    if isElement(vehicle[source]) then  
        destroyElement(vehicle[source])  
            vehicle[source] = nil  
        end 
    end 
) 

معد صرت احتاجه بس مشككككككككوور

edit #2:

بس ممكن لما اختار Row يسوي createVehicle

يعني لو حددت على اي سيارة تظهر قدامي ولو غيرت Row

تختفي السابقة وتجي المحددة

وكود تغيير مكان الكاميرا

edit #3:

وين رحتو

Edited by Guest
Link to comment

على كيفك مو لازم تريقر ؟

Note: Vehicles (and other elements) created client-side are only seen by the client that created them, aren't synced and players cannot enter them. They are essentially for display only.

-- Client Side # 
addEventHandler('onClientGUIClick',carGridList,function() 
    if guiGridListGetSelectedItem ( source ) ~= -1 then 
        local car = guiGridListGetItemData( source ,guiGridListGetSelectedItem ( source ), 1) 
            triggerServerEvent('_createVehicle',localPlayer,car) 
        end 
    end,false 
) 

طبعا لازم تسوي داتا للرو , شوف كودي فوق وسوي مثله,

وكمل السيرفر سوي جدول وتحققات ,, برضو شوف كودي الي فوق

Link to comment
على كيفك مو لازم تريقر ؟

Note: Vehicles (and other elements) created client-side are only seen by the client that created them, aren't synced and players cannot enter them. They are essentially for display only.

-- Client Side # 
addEventHandler('onClientGUIClick',carGridList,function() 
    if guiGridListGetSelectedItem ( source ) ~= -1 then 
        local car = guiGridListGetItemData( source ,guiGridListGetSelectedItem ( source ), 1) 
            triggerServerEvent('_createVehicle',localPlayer,car) 
        end 
    end,false 
) 

طبعا لازم تسوي داتا للرو , شوف كودي فوق وسوي مثله,

وكمل السيرفر سوي جدول وتحققات ,, برضو شوف كودي الي فوق

طيب ممكن كودسيرفر لاني معرف التحققات والخ......

ممكن كود تغيير مكان الكاميرا plz :D

Edited!!!

Edited by Guest
Link to comment

الرد شباب +شوفو آخر تعديل

edit:

شباب انا سويت الكود بس فيه مشكلة

كلنت

addEventHandler('onClientGUIClick',root,function() 
    if source == buyButton then 
        if guiGridListGetSelectedItem(carGridList) then 
            local Name = guiGridListGetItemText ( carGridList,guiGridListGetSelectedItem ( carGridList ), 1) 
            local id = guiGridListGetItemData ( carGridList,guiGridListGetSelectedItem ( carGridList ), 1) 
            local Cost = guiGridListGetItemText ( carGridList,guiGridListGetSelectedItem ( carGridList ), 2) 
                triggerServerEvent("carShopCarBuy",localPlayer,Name,id,Cost) 
        end 
    elseif source == carGridList then 
        if guiGridListGetSelectedItem(carGridList) then 
            local car = guiGridListGetItemData ( carGridList,guiGridListGetSelectedItem ( carGridList ), 1) 
            triggerServerEvent("CreateV",localPlayer,car) 
        end 
    elseif source == closeButton then 
local eg = getLocalPlayer() 
    setCameraTarget(eg) 
        guiSetVisible (carshopWindow, false) 
            showCursor (false) 
    end 
end) 

سيرفر

addEvent ("CreateV", true) 
function ss (car) 
cr = createVehicle ( car, 549.94281005859, -1265.0211181641, 17.2421875 ) 
if isElement(cr) then 
destroyElement(cr) 
createVehicle ( car, 549.94281005859, -1265.0211181641, 17.2421875 ) 
end 
end 
addEventHandler ("CreateV", getRootElement(), ss) 

Link to comment

-- Server Side # 
local car = {} 
  
addEvent ('CreateV', true) 
addEventHandler ('CreateV',function (cCar) 
    if isElement(car[source]) then destroyElement(car[source]) car[source] = nil end 
        car[source] = createVehicle( tonumber(cCar), 549.94281005859, -1265.0211181641, 17.2421875 ) 
  
    end 
) 
Link to comment

كودك ماشتغل ليش؟؟؟؟

لما اجي اضغط واحدد ماتجي السيارة تأكد من الكود

edit:

المشكلة حليتها بس في كود اضفته لما يلمس الماركر لازم يكون لاعب+ لازم يكون عنده داتا معيين

اوك

الكود:

addEvent ("viewGUI", true) 
function markerHit (hitPlayer, matchingDimension) 
 if (getAccountData(hitPlayer,"pent") == "yes") then 
 if getElementType (hitPlayer) == "player" then 
  if (source == carShopMarker) or (source == carShopMarker2) or (source == carShopMarker3) or (source == carShopMarker4) or (source == carShopMarker5) then 
    triggerClientEvent ("viewGUI", hitPlayer) 
    setCameraMatrix ( hitPlayer, 548.46484375, -1267.1435546875, 26.682792663574, 496.4482421875,-1342.6044921875,-13.315231323242, 0, 0) 
    setElementDimension(hitPlayer,755) 
    end 
  end 
 else 
       outputChatBox ("ليس لديك ؟؟؟", hitPlayer, 255, 0, 0, false) 
end 
end 
addEventHandler ("onMarkerHit", getRootElement(), markerHit) 

edit #2:

شباب احد يرد وربي طفشت

Edited by Guest
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...