Jump to content

[HELP]Group Spawners 2x


BluntZ

Recommended Posts

Hello , Any one can help me ? My friend gave me this group spawner system but it is bugg too -.- , Any one can help me to fix it ?

Server Side

marker = {} 
vehicleCarSpawns = { 
-- Format: x, y, z, rotation, "Group", {cars} 
{297.18, 2049.94, 34.28, "Military", {596, 597, 598, 599, 579, 490, 528}}, 
{1523, -2847.8, 0, 180, "FBI", {472, 473, 595}} 
} 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for i,v in ipairs ( vehicleCarSpawns ) do 
            local x, y, z, rot, group, cars = unpack ( vehicleCarSpawns [ i ] ) 
            marker [ i ] = createMarker ( x, y, z - 1, "cylinder", 2.3, r, g, b, 150 ) 
            setElementData ( marker [ i ], "markerIndex", i, false ) 
            addEventHandler ( "onMarkerHit", marker [ i ], onSpawnerMarkerHit ) 
        end 
    end 
) 
  
function onSpawnerMarkerHit ( p ) 
    local index = getElementData ( source, "markerIndex" ) 
    local x, y, z, rot, group, cars = unpack ( vehicleCarSpawns [ index ] ) 
    if ( group == exports [ 'NGGroups' ]:getPlayerGroup ( v ) ) then 
        triggerClientEvent ( p, "showGroupVehicleSpawners", p, cars, x, y, z ) 
    else 
        triggerClientEvent(p,"message:centerText",p,"Your not in the "..getElementData(source,"markerType"), 5, 255, 0, 0) 
    end 
end 
  
vehicle = {} 
function onDestroyCustomCars() 
    if isElement(vehicle[source]) then 
        destroyElement(vehicle[source]) 
        vehicle[source] = nil 
    end 
end 
addEventHandler("onPlayerQuit", root, onDestroyCustomCars) 
addEvent("onDestroyCustomCars",true) 
addEventHandler("onDestroyCustomCars",root,onDestroyCustomCars) 
  
function onCreateGroupVehicle(id,x,y,z) 
    if (id) then 
        if (isElement(vehicle[source])) then 
            destroyElement(vehicle[source]) 
        end 
        triggerEvent("spawners:destroyOldCars",source) 
        if (tonumber(x) ~= nil) then 
            vehicle[source] = createVehicle(id, x, y, z, 0, 0, rot) 
        else 
            local rx,ry,rz = getElementPosition(source) 
            vehicle[source] = createVehicle(id, rx, ry, rz, 0, 0, 0) 
        end 
        warpPedIntoVehicle(source,vehicle[source]) 
        setElementData(vehicle[source],"vehOwner","spawners",true) 
        setVehicleColor(vehicle[source],r,g,b) 
    end 
end 
addEvent("onCreateGroupVehicle",true) 
addEventHandler("onCreateGroupVehicle",root,onCreateGroupVehicle) 

Client Side

local rx,ry = guiGetScreenSize() 
button = {} 
window = {} 
gridlist = {} 
  
window['groups'] = guiCreateWindow((rx/2-343/2),(rx/2-316/2),343,316,"",false) 
guiSetAlpha(window['groups'],1) 
guiWindowSetSizable(window['groups'],false) 
  
button['groupsSpawn'] = guiCreateButton(11,267,160,40,"Spawn",false,window['groups']) 
button['groupsClose'] = guiCreateButton(173,267,161,40,"Cancel",false,window['groups']) 
  
guiSetVisible( window['groups'], false ) 
  
gridlist['groups'] = guiCreateGridList(9,22,324,243,false,window['groups']) 
guiGridListAddColumn(gridlist['groups'],"Vehicle",0.4) 
guiGridListAddColumn(gridlist['groups'],"ID",0.4) 
  
function showGroupVehicleSpawners(cars,x,y,z) 
    x = x 
    y = y 
    z = z 
    guiSetVisible(window['groups'],true) 
    showCursor(true) 
    for i,v in ipairs (cars) do 
        local name = getVehicleNameFromModel(v)                                 -- BUGGED LINE 
        row = guiGridListAddRow(gridlist['groups']) 
        guiGridListSetItemText(gridlist['groups'], row, 1, name, false, false)  -- BUGGED LINE 
        guiGridListSetItemData(gridlist['groups'], row, 1, v) 
        guiGridListSetItemText(gridlist['groups'], row, 2, tostring(v), false, false) 
        guiGridListSetItemData(gridlist['groups'], row, 2, v) 
    end 
end 
addEvent("showGroupVehicleSpawners",true) 
addEventHandler("showGroupVehicleSpawners",root,showGroupVehicleSpawners) 
  
addEventHandler("onClientGUIClick",root, 
    function () 
        if (source==button['groupsClose']) then 
            guiGridListClear(gridlist['groups']) 
            guiSetVisible(window['groups'],false) 
            showCursor(false,false) 
        elseif (source==button['groupsSpawn']) then 
            local row, col = guiGridListGetSelectedItem(gridlist['groups']) 
            local id = guiGridListGetItemData(gridlist['groups'], row, 1) 
            triggerServerEvent("onCreateGroupVehicle",localPlayer,id,x,y,z) 
            guiGridListClear(gridlist['groups']) 
            guiSetVisible(window['groups'],false) 
            showCursor(false,false) 
        end 
    end 
) 

Any help ? its giving me error in Line number 25 of server side :(

Link to comment

paste in server

  
marker = {} 
vehicleCarSpawns = { 
-- Format: x, y, z, rotation, "Group", {cars} 
{297.18, 2049.94, 34.28, 0, "Military", {596, 597, 598, 599, 579, 490, 528}}, 
{1523, -2847.8, 0, 180, "FBI", {472, 473, 595}} 
} 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for i,v in ipairs ( vehicleCarSpawns ) do 
            local x, y, z, rot, group, cars = unpack ( vehicleCarSpawns [ i ] ) 
            marker [ i ] = createMarker ( x, y, z - 1, "cylinder", 2.3, r, g, b, 150 ) 
            setElementData ( marker [ i ], "markerIndex", i, false ) 
            addEventHandler ( "onMarkerHit", marker [ i ], onSpawnerMarkerHit ) 
        end 
    end 
) 
  
function onSpawnerMarkerHit ( p ) 
    local index = getElementData ( source, "markerIndex" ) 
    local x, y, z, rot, group, cars = unpack ( vehicleCarSpawns [ index ] ) 
    if ( group == exports [ 'NGGroups' ]:getPlayerGroup ( v ) ) then 
        triggerClientEvent ( p, "showGroupVehicleSpawners", p, cars, x, y, z ) 
    else 
        triggerClientEvent(p,"message:centerText",p,"Your not in the "..getElementData(source,"markerType"), 5, 255, 0, 0) 
    end 
end 
  
vehicle = {} 
function onDestroyCustomCars() 
    if isElement(vehicle[source]) then 
        destroyElement(vehicle[source]) 
        vehicle[source] = nil 
    end 
end 
addEventHandler("onPlayerQuit", root, onDestroyCustomCars) 
addEvent("onDestroyCustomCars",true) 
addEventHandler("onDestroyCustomCars",root,onDestroyCustomCars) 
  
function onCreateGroupVehicle(id,x,y,z) 
    if (id) then 
        if (isElement(vehicle[source])) then 
            destroyElement(vehicle[source]) 
        end 
        triggerEvent("spawners:destroyOldCars",source) 
        if (tonumber(x) ~= nil) then 
            vehicle[source] = createVehicle(id, x, y, z, 0, 0, rot) 
        else 
            local rx,ry,rz = getElementPosition(source) 
            vehicle[source] = createVehicle(id, rx, ry, rz, 0, 0, 0) 
        end 
        warpPedIntoVehicle(source,vehicle[source]) 
        setElementData(vehicle[source],"vehOwner","spawners",true) 
        setVehicleColor(vehicle[source],r,g,b) 
    end 
end 
addEvent("onCreateGroupVehicle",true) 
addEventHandler("onCreateGroupVehicle",root,onCreateGroupVehicle) 
  
  
  

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