Jump to content

[HELPx13]Roadblock system


||BuLLeT||

Recommended Posts

Hey guys i have got roadblock system,you see all is fine, all working but, i have only command /rblocks or /remblocks to remove all roadblocks you have created, i want it have /rblocks for remove all roadblocks and /rblock for only last one you created....

client.lua

------------------------------------------------------------------------------------ 
--  v1.0 
--  Roadblocks for law 
--  Charlie 
------------------------------------------------------------------------------------ 
  
local tRBNames = false 
triggerServerEvent("roadblock.getTable", localPlayer) 
  
rbsWindow = guiCreateWindow(0.3391,0.2832,0.3125,0.4688,"Roadblock System",true) 
guiWindowSetSizable(rbsWindow,false) 
acceptButton = guiCreateButton(0.1075,0.8813,0.3225,0.0854,"Accept",true,rbsWindow) 
closeButton = guiCreateButton(0.57,0.8813,0.3225,0.0854,"Close",true,rbsWindow) 
rbsMenu = guiCreateGridList(0.11,0.1292,0.785,0.725,true,rbsWindow) 
guiGridListSetSelectionMode(rbsMenu,2) 
guiGridListAddColumn(rbsMenu,"Roadblocks",0.90) 
guiSetVisible(rbsWindow, false) 
function cGUI() 
    if (getPedOccupiedVehicle(localPlayer)) then return false end 
    if (getTeamName(getPlayerTeam(localPlayer)) ~= "Military Unit" and getTeamName(getPlayerTeam(localPlayer)) ~= "San Andreas Workers" and getTeamName(getPlayerTeam(localPlayer)) ~= "San Andreas Sports Council" and getTeamName(getPlayerTeam(localPlayer)) ~= "Staff" ) then return false end 
    guiSetVisible(rbsWindow, true) 
    showCursor(true) 
end 
addCommandHandler ("barrier", cGUI) 
  
function closeWindow() 
    guiSetVisible(rbsWindow, false) 
    showCursor(false) 
end 
addEventHandler("onClientGUIClick", closeButton, closeWindow, false) 
  
function makeBlock() 
    local chk = guiGridListGetItemText(rbsMenu, guiGridListGetSelectedItem(rbsMenu), 1) 
    if (chk) then   
        triggerServerEvent("roadblock.makeObj", localPlayer, chk) 
        closeWindow() 
        return true 
    end 
end 
addEventHandler("onClientGUIClick", acceptButton, makeBlock, false) 
  
function recvTable(t) 
    tRBNames = t 
    for _, sObject in pairs(tRBNames) do 
        if (rbsMenu) then 
            local row = guiGridListAddRow(rbsMenu) 
            guiGridListSetItemText(rbsMenu, row, 1, sObject["name"], false, false) 
        end 
    end 
end 
addEvent("roadblock.sendTable", true) 
addEventHandler("roadblock.sendTable", localPlayer, recvTable) 
  

server.lua

------------------------------------------------------------------------------------ 
--  v1.0 
--  Roadblocks for law 
--  Charlie 
------------------------------------------------------------------------------------ 
  
local tRBNames = { 
    ["roadright"] = {name="Small roadblock", id=978}, 
    ["helix_barrier"] = {name="Large Roadblock", id=981}, 
    ["roadworkbarrier1"] = {name="Warning fence", id=1459}, 
    ["roadbarrier4"] = {name="Barrier", id=1423}, 
    ["roadbarrier3"] = {name="Detour sign", id=1425}, 
    ["roadbarrier6"] = {name="Sidewalk block", id=1424}, 
    ["DockBarr1_LA"] = {name="Yellow fence", id=3578}, 
    ["cn2_roadblock01"] = {name="Bridge roadblock", id=16436}, 
    ["sfse_roadblock5"] = {name="Medium roadblock", id=4526}, 
    ["trafficcone"] = {name="Traffic Cone", id=1238}, 
    ["Barrierm"] = {name="Small warning fence with light", id=1282}, 
    ["DYN_ROADBARRIER_5"] = {name="Ugly small fence", id=1422}, 
    ["imy_track_barrier"] = {name="Vehicles ->", id=3091}, 
    ["cn2_savgardr1_"] = {name="Wall", id=16500}, 
    ["cn2_savgardr2_"] = {name="Wall 2", id=16501}, 
    ["shbbyhswall11_lvs"] = {name="Wall 3", id=8659}, 
    ["Gen_doorINT01"] = {name="Door", id=1491}, 
    ["TwrCrane_M_01"] = {name="Crane", id=1384}, 
    ["TwrCrane_M_04"] = {name="Crane stand", id=1383}, 
    ["demolish1_SFXRF"] = {name="Demolished building", id=3866}, 
    ["demolish4_SFXRF"] = {name="Demolished building two", id=3887}, 
    ["circusconstruct07"] = {name="Construction Fence", id=7017}, 
    ["DYN_MESH_1"] = {name="Electric fence", id=1411}, 
    ["drydock2_SFSe"] = {name="Dry Dock", id=10830}, 
    ["drydock1_SFSe"] = {name="Dock Gate", id=10828}, 
    ["laebuildsit01a"] = {name="Half built glass", id=5644}, 
    ["laebuildsit01"] = {name="Half built", id=5463}, 
    ["des_quarry_hopper01"] = {name="Concrete maker", id=16083}, 
    ["des_quarrybelt07"] = {name="Conveyor", id=16075}, 
    ["laxrf_scrapbox"] = {name="Trash container", id=3722}, 
    ["gnhtelgrnd_lvs"] = {name="Field platform", id=8661}, 
    ["a51_ventsouth"] = {name="Construction platform", id=8661}, 
    ["Esc_step8"] = {name="Catwalk", id=1698}, 
    ["odrampbit"] = {name="Large stairs", id=5816}, 
    ["vrockstairs"] = {name="Vrock stairs", id=7096}, 
    ["imcompstrs02"] = {name="Stairs double", id=5130}, 
    ["cos_sbanksteps02"] = {name="SF bank steps", id=12839}, 
    ["cos_sbanksteps04"] = {name="SF bank steps 2", id=13011}, 
    ["des_quarryplatform"] = {name="Quarry Platform", id=16082}, 
    ["DYN_SCAFFOLD"] = {name="Scaffold 1", id=1426}, 
    ["DYN_SCAFFOLD_2"] = {name="Scaffold 2", id=1436}, 
    ["DYN_SCAFFOLD_4"] = {name="Scaffold 3", id=1465}, 
    ["ws_scaffolding_SFX"] = {name="Big scaffold", id=3867}, 
} 
local spawnedObjects = {} 
  
function mObj(chk) 
    if (getElementInterior(client) ~= 0) then 
        outputChatBox("You cannot use barriers in interiors", client, 0, 255, 0) 
        return false 
    end 
    local use = false 
    for a,b in pairs(tRBNames) do 
        if (b["name"] == chk) then 
            use = b 
            break 
        end 
    end 
    if (not use) then return false end 
    toggleAllControls(source, true) 
    showCursor(source, false) 
    local nX, nY, nZ = getElementPosition(source) 
    local nX2, nY2 = 0, 0 
    local nZ2 = getPedRotation(source) 
    local obj = createObject(use["id"], nX, nY, nZ - 0.5, nX2, nY2, nZ2) 
    setElementPosition(client, nX, nY, nZ + 5) 
    if (not spawnedObjects[client]) then 
        spawnedObjects[client] = {} 
    end 
    spawnedObjects[client][obj] = true 
    return true 
end 
addEvent("roadblock.makeObj", true) 
addEventHandler("roadblock.makeObj", root, mObj) 
  
function reqT() 
    triggerClientEvent(client, "roadblock.sendTable", client, tRBNames) 
end 
addEvent("roadblock.getTable", true) 
addEventHandler("roadblock.getTable", root, reqT) 
  
function remObj(cl) 
    local source = source or cl 
    if (spawnedObjects[source]) then 
        for a,b in pairs(spawnedObjects[source]) do 
            if (isElement(a)) then 
                destroyElement(a) 
            end 
        end 
    end 
end 
addEventHandler("onPlayerQuit", root, remObj) 
addCommandHandler("remblocks", remObj) 
addCommandHandler("rblocks", remObj) 

Link to comment
------------------------------------------------------------------------------------ 
--  v1.0 
--  Roadblocks for law 
--  Charlie 
------------------------------------------------------------------------------------ 
  
local tRBNames = { 
    ["roadright"] = {name="Small roadblock", id=978}, 
    ["helix_barrier"] = {name="Large Roadblock", id=981}, 
    ["roadworkbarrier1"] = {name="Warning fence", id=1459}, 
    ["roadbarrier4"] = {name="Barrier", id=1423}, 
    ["roadbarrier3"] = {name="Detour sign", id=1425}, 
    ["roadbarrier6"] = {name="Sidewalk block", id=1424}, 
    ["DockBarr1_LA"] = {name="Yellow fence", id=3578}, 
    ["cn2_roadblock01"] = {name="Bridge roadblock", id=16436}, 
    ["sfse_roadblock5"] = {name="Medium roadblock", id=4526}, 
    ["trafficcone"] = {name="Traffic Cone", id=1238}, 
    ["Barrierm"] = {name="Small warning fence with light", id=1282}, 
    ["DYN_ROADBARRIER_5"] = {name="Ugly small fence", id=1422}, 
    ["imy_track_barrier"] = {name="Vehicles ->", id=3091}, 
    ["cn2_savgardr1_"] = {name="Wall", id=16500}, 
    ["cn2_savgardr2_"] = {name="Wall 2", id=16501}, 
    ["shbbyhswall11_lvs"] = {name="Wall 3", id=8659}, 
    ["Gen_doorINT01"] = {name="Door", id=1491}, 
    ["TwrCrane_M_01"] = {name="Crane", id=1384}, 
    ["TwrCrane_M_04"] = {name="Crane stand", id=1383}, 
    ["demolish1_SFXRF"] = {name="Demolished building", id=3866}, 
    ["demolish4_SFXRF"] = {name="Demolished building two", id=3887}, 
    ["circusconstruct07"] = {name="Construction Fence", id=7017}, 
    ["DYN_MESH_1"] = {name="Electric fence", id=1411}, 
    ["drydock2_SFSe"] = {name="Dry Dock", id=10830}, 
    ["drydock1_SFSe"] = {name="Dock Gate", id=10828}, 
    ["laebuildsit01a"] = {name="Half built glass", id=5644}, 
    ["laebuildsit01"] = {name="Half built", id=5463}, 
    ["des_quarry_hopper01"] = {name="Concrete maker", id=16083}, 
    ["des_quarrybelt07"] = {name="Conveyor", id=16075}, 
    ["laxrf_scrapbox"] = {name="Trash container", id=3722}, 
    ["gnhtelgrnd_lvs"] = {name="Field platform", id=8661}, 
    ["a51_ventsouth"] = {name="Construction platform", id=8661}, 
    ["Esc_step8"] = {name="Catwalk", id=1698}, 
    ["odrampbit"] = {name="Large stairs", id=5816}, 
    ["vrockstairs"] = {name="Vrock stairs", id=7096}, 
    ["imcompstrs02"] = {name="Stairs double", id=5130}, 
    ["cos_sbanksteps02"] = {name="SF bank steps", id=12839}, 
    ["cos_sbanksteps04"] = {name="SF bank steps 2", id=13011}, 
    ["des_quarryplatform"] = {name="Quarry Platform", id=16082}, 
    ["DYN_SCAFFOLD"] = {name="Scaffold 1", id=1426}, 
    ["DYN_SCAFFOLD_2"] = {name="Scaffold 2", id=1436}, 
    ["DYN_SCAFFOLD_4"] = {name="Scaffold 3", id=1465}, 
    ["ws_scaffolding_SFX"] = {name="Big scaffold", id=3867}, 
} 
local spawnedObjects = {} 
  
function mObj(chk) 
    if (getElementInterior(client) ~= 0) then 
        outputChatBox("You cannot use barriers in interiors", client, 0, 255, 0) 
        return false 
    end 
    local use = false 
    for a,b in pairs(tRBNames) do 
        if (b["name"] == chk) then 
            use = b 
            break 
        end 
    end 
    if (not use) then return false end 
    toggleAllControls(source, true) 
    showCursor(source, false) 
    local nX, nY, nZ = getElementPosition(source) 
    local nX2, nY2 = 0, 0 
    local nZ2 = getPedRotation(source) 
    local obj = createObject(use["id"], nX, nY, nZ - 0.5, nX2, nY2, nZ2) 
    setElementPosition(client, nX, nY, nZ + 5) 
    if (not spawnedObjects[client]) then 
        spawnedObjects[client] = {} 
    end 
    table.insert ( spawnedObjects [ client ], obj ) 
    return true 
end 
addEvent("roadblock.makeObj", true) 
addEventHandler("roadblock.makeObj", root, mObj) 
  
function reqT() 
    triggerClientEvent(client, "roadblock.sendTable", client, tRBNames) 
end 
addEvent("roadblock.getTable", true) 
addEventHandler("roadblock.getTable", root, reqT) 
  
function remObj(cl) 
    local source = source or cl 
    if (spawnedObjects[source]) then 
        for _, a in ipairs(spawnedObjects[source]) do 
            if (isElement(a)) then 
                destroyElement(a) 
            end 
        end 
        spawnedObjects [ source ] = { } 
    end 
end 
addEventHandler("onPlayerQuit", root, remObj) 
addCommandHandler("remblocks", remObj) 
addCommandHandler("rblocks", remObj) 
  
function remLastObj ( thePlayer ) 
    local objects = spawnedObjects [ thePlayer ] 
    if ( objects ) then 
        local object = objects [ #objects ] 
        if ( isElement ( object ) ) then 
            destroyElement ( object ) 
            table.remove ( spawnedObjects [ thePlayer ], #objects ) 
        end 
    end 
end 
addCommandHandler ( "rblock", remLastObj ) 

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...