Jump to content

I'm looking for a script ..


nk0zkh0z

Recommended Posts

I'm looking for a script ..

This scenario helps players manage vehicle.

The functions:

1. Manage vehicle

2. Send car

3. Tele car

My server was RP

I needed it, thanks very much :D

Plus this script is not so hard, people need to realized that you need to stand on your own feet

Link to comment

This is the client. Need a File Server?

local backupPlayer = nil 
local backupPlayer1 = nil
local localPlayer = getLocalPlayer()
 
local vehElements = {}
local petss = {}
wImpound1mycar, bClose1mycar, gCars1mycar, bRelease1mycar, bRelease1mycar1, bRelease1mycar2, IDcolumn1mycar = nil
 
function showAllMycar(vehElementsret, pets)
    if not wImpound1mycar then
        local width, height = 650, 300
        local scrWidth, scrHeight = guiGetScreenSize()
        local x = scrWidth/2 - width/2
        local y = scrHeight/2 - height/2
       
        if (getElementData(getLocalPlayer(), "vehmenu") or 0) == 0 then
        wImpound1mycar = guiCreateWindow(x, y, width, height, "Số slot xe của bạn: "..(getElementData(getLocalPlayer(), "maxvehicles") or 0).."", false)
        else
        wImpound1mycar = guiCreateWindow(x, y, width, height, "Số slot xe của Gang: "..(#vehElementsret + #pets).."/"..(getElementData(getPlayerTeam(getLocalPlayer()), "Facvehs") or 0).."", false)
        end
       
        guiWindowSetSizable(wImpound1mycar, false)
       
        bClose1mycar = guiCreateButton(0.825, 0.85, 0.2, 0.1, "Thoát", true, wImpound1mycar)
        bRelease1mycar = guiCreateButton(0.6, 0.85, 0.2, 0.1, "Gửi xe", true, wImpound1mycar)
        bRelease1mycar1 = guiCreateButton(0.375, 0.85, 0.2, 0.1, "Tele xe", true, wImpound1mycar)
        addEventHandler("onClientGUIClick", bClose1mycar, hideImpoundUI1mycarr, false)
        addEventHandler("onClientGUIClick", bRelease1mycar, releaseCar1mycarr, false)
        addEventHandler("onClientGUIClick", bRelease1mycar1, releaseCar1mycarr1, false)
       
        if (getElementData(getLocalPlayer(), "vehmenu") or 0) == 0 then
        bRelease1mycar2 = guiCreateButton(0.150, 0.85, 0.2, 0.1, "Bán xe (1/2)$", true, wImpound1mycar)
        addEventHandler("onClientGUIClick", bRelease1mycar2, releaseCar1mycarr2, false)
        end
       
 
        gCars1mycar = guiCreateGridList(0.05, 0.1, 0.9, 0.65, true, wImpound1mycar)
        --addEventHandler("onClientGUIClick", gCars1mycar, updateCar1, false)
        local col = guiGridListAddColumn(gCars1mycar, "ID", 0.12)
        IDcolumn1mycar = guiGridListAddColumn(gCars1mycar, "Xe", 0.35)
        local col1 = guiGridListAddColumn(gCars1mycar, "Gửi xe", 0.1)
        local col2 = guiGridListAddColumn(gCars1mycar, "Tịch thu", 0.1)
        local col4 = guiGridListAddColumn(gCars1mycar, "Vị trí", 0.25)
        local vdbid = getElementData(getLocalPlayer(), "marriedto")
        vehElements = vehElementsret
        for key, value in ipairs(vehElements) do
            local row = guiGridListAddRow(gCars1mycar)
            local dbid = getElementData(value, "dbid")
            local owner = getElementData(value, "owner")
            local shit = ""
            local shit1 = ""  
            local vk = ""  
            if vdbid == owner then
            vk = "Kết hôn"
            end
            if (getElementData(value, "Guixe") or 0) == 1 then
            shit = "Có"
            elseif (getElementData(value, "Guixe") or 0) == 0 then  
            shit = "Không"
            end
            if (getElementData(value, "Market") or 0) >= 1 then
            shit = "/carmarket"
            end
            if (getElementData(value, "Impounded") or 0) > 0 then
            shit1 = "Có"
            elseif (getElementData(value, "Impounded") or 0) <= 0 then
            shit1 = "Không"
            end
            if (getElementData(value, "Market") or 0) >= 1 then
            shit1 = "/carmarket"
            end
            local playerX, playerY, playerZ = getElementPosition( value )  -- Get player's coordinates.
            local streetname = getZoneName( playerX, playerY, playerZ )
            if vk == "" then
            guiGridListSetItemText(gCars1mycar, row, col, dbid, false, false)
            else
            guiGridListSetItemText(gCars1mycar, row, col, vk, false, false)
            guiGridListSetItemColor(gCars1mycar, row, col, 0,255,0)
            end
            guiGridListSetItemText(gCars1mycar, row, IDcolumn1mycar, exports.global:getGVRVehicleName(value), false, false)
            guiGridListSetItemText(gCars1mycar, row, col1, shit, false, false)
            guiGridListSetItemText(gCars1mycar, row, col2, shit1, false, false)
            if streetname == "Unknown" then
            guiGridListSetItemText(gCars1mycar, row, col4, "Không rõ", false, false)
            guiGridListSetItemColor(gCars1mycar, row, col4, 0,0,0)
            else
            guiGridListSetItemText(gCars1mycar, row, col4, streetname, false, false)
            end
           
            guiGridListSetItemData(gCars1mycar, row, IDcolumn1mycar, dbid)
            if isElement(value) then
            guiGridListSetItemData(gCars1mycar, row, col, value)
            end
        end 
        petss = pets
        for key, value in pairs(pets) do
            local row = guiGridListAddRow(gCars1mycar)
            local pID = tonumber(pets[key][1])
            local model = tonumber(pets[key][2])
            local vk = ""
            if vdbid == tonumber(pets[key][3]) then
            vk = "Kết hôn"
            end
            if vk == "" then
            guiGridListSetItemText(gCars1mycar, row, col, pID, false, false)
            else
            guiGridListSetItemText(gCars1mycar, row, col, vk, false, false)
            guiGridListSetItemColor(gCars1mycar, row, col, 0,255,0)
            end
            guiGridListSetItemText(gCars1mycar, row, IDcolumn1mycar, exports.global:getGVRVehicleNameFromModel(model), false, false)
            guiGridListSetItemText(gCars1mycar, row, col1, "Có", false, false)
            guiGridListSetItemText(gCars1mycar, row, col2, "Không", false, false)
            guiGridListSetItemText(gCars1mycar, row, col4, "Nhà xe", false, false)
           
            guiGridListSetItemData(gCars1mycar, row, IDcolumn1mycar, pID)
            guiGridListSetItemData(gCars1mycar, row, col, pID)
        end
        guiGridListSetSelectedItem(gCars1mycar, 0, 1)
       
        guiSetInputEnabled(true)
    end
end
 
function releaseCar1mycarr(button)
    if (button=="left") then
        local row = guiGridListGetSelectedItem(gCars1mycar)
        local IdPet = tostring(guiGridListGetItemData(gCars1mycar, row, 2))
        local VehPET = guiGridListGetItemData(gCars1mycar, row, 1)
        hideImpoundUI1mycarr()
        if isElement(VehPET) then
        triggerServerEvent("GuiMycar", getLocalPlayer(), VehPET)
        else
        triggerServerEvent("GuiMycar", getLocalPlayer(), IdPet)
        end
        triggerServerEvent("ShowMyCar1", getLocalPlayer(), VehPET)
    end
end
 
function releaseCar1mycarr1(button)
    if (button=="left") then
        local row = guiGridListGetSelectedItem(gCars1mycar)
        local IdPet = tostring(guiGridListGetItemData(gCars1mycar, row, 2))
        local VehPET = guiGridListGetItemData(gCars1mycar, row, 1)
        hideImpoundUI1mycarr()
        if isElement(VehPET) then
        triggerServerEvent("GetMycar", getLocalPlayer(), VehPET)
        else
        triggerServerEvent("loadOneVehicle", getLocalPlayer(), IdPet)
        triggerServerEvent("GetMycar", getLocalPlayer(), IdPet)
        end
        triggerServerEvent("ShowMyCar1", getLocalPlayer(), VehPET)
    end
end
 
function releaseCar1mycarr2(button)
    if (button=="left") then
        local row = guiGridListGetSelectedItem(gCars1mycar)
        local IdPet = tostring(guiGridListGetItemData(gCars1mycar, row, 2))
        local VehPET = guiGridListGetItemData(gCars1mycar, row, 1)
        hideImpoundUI1mycarr()
        if isElement(VehPET) then
        triggerServerEvent("SellMycar", getLocalPlayer(), VehPET)
        else
        triggerServerEvent("loadOneVehicle", getLocalPlayer(), IdPet)
        triggerServerEvent("SellMycar", getLocalPlayer(), IdPet)
        end
        triggerServerEvent("ShowMyCar1", getLocalPlayer(), VehPET)
    end
end
 
function hideImpoundUI1mycarr()
    destroyElement(bClose1mycar)
    bClose1mycar = nil
   
    destroyElement(bRelease1mycar)
    bRelease1mycar = nil
   
    destroyElement(bRelease1mycar1)
    bRelease1mycar1 = nil
   
    if isElement(bRelease1mycar2) then
    destroyElement(bRelease1mycar2)
    bRelease1mycar2 = nil
    end
   
    destroyElement(wImpound1mycar)
    wImpound1mycar = nil
 
    guiSetInputEnabled(false)
end
 
addEvent("ShowMyCar", true)
addEventHandler("ShowMyCar", getRootElement(), showAllMycar)
 
addEventHandler("onClientVehicleEnter", getRootElement(),
    function(thePlayer, seat)
        if thePlayer == getLocalPlayer() then
            local source = getPedOccupiedVehicle(thePlayer)
            for i=2,5 do
            if isElement(source) then
            if getVehicleDoorOpenRatio ( source, i ) ~= 0 then
            setVehicleDoorOpenRatio ( source, i, 0, 0 )
            end
            end
            end
            setTimer(function()
            for i=2,5 do
            if isElement(source) then
            if getVehicleDoorOpenRatio ( source, i ) ~= 0 then
            setVehicleDoorOpenRatio ( source, i, 0, 0 )
            end
            end
            end
            end, 5000, 3)
            end
        end
)
 
addEvent("SoundEngine", true)
addEventHandler("SoundEngine", localPlayer,
    function(vehveh)
    if vehveh then
    local x, y, z = getElementPosition(vehveh)
    playSound3D("Vehicle/grind.wav", x, y, z)
    end
    end
)      
 
addEvent("SoundLock", true)
addEventHandler("SoundLock", localPlayer,
    function(vehveh)
    if vehveh then
    local x, y, z = getElementPosition(vehveh)
    if isVehicleLocked(vehveh) then
    playSound3D("Vehicle/unlock.mp3", x, y, z)
    else
    playSound3D("Vehicle/lock.mp3", x, y, z)
    end
    end
    end
)
 
local sound = nil
addEvent("SoundDoorLock", true)
addEventHandler("SoundDoorLock", localPlayer,
    function(vehveh)
    if vehveh then
    local x, y, z = getElementPosition(vehveh)
    if isVehicleLocked(vehveh) then
    if sound then
   
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...