Jump to content

[HELP]Group Vehicle


Best-Killer1

Recommended Posts

how i can make vehicle group system with colors ? not the marker but i want change color car of the group

example SWAT Cars Blue (not the marker)

Codes

Server-Side :

local rootElement = getRootElement() 
local markers = {} 
local playerVehicles = {} 
local playerTrailers = {} 
local lawTeams = {["Law Enforcement"] = true, ["SWAT"] = true, ["Military"] = true, ["Staff"] = true} 
  
--teamName, posX, posY, posZ, R, G, B, Alpha, Vehicle IDs, Rotation, Element data name 
local vehiclesTable = { 
----- MILITARY 
    {{"Military"}, 206.99, 1931.85, 22,0, 0, 255, 150, {487, 425, 520 }, 3, "Group"}, ---- LV HQ BASE AIRCRAFT 
---SWAT 
    {{"SWAT"}, 848.93, -2117.51, 1.95,0, 0, 255, 150, {411, 522, 544 }, 90, "Group"}, ----- LS HG Base Cars 
    {{"SWAT"}, 825.98, -2087.69, 43.38,0, 0, 255, 150, {520, 519, 476 }, 1, "Group"},   ----- LS HG Base AirCraft 
    {{"SWAT"}, 836.14, -2020.34, 13.11,0, 0, 255, 150, {411, 522, 544 }, 1, "Group"}, --------- LS HG Base Cars 
  
} 
  
addEventHandler("onResourceStart", resourceRoot, 
function () 
for i,v in pairs(vehiclesTable) do 
local marker = createMarker(tostring(v[2]), tostring(v[3]), tostring(v[4])-1, "cylinder", 2.5, tostring(v[5]), tostring(v[6]), tostring(v[7]), tostring(v[8]), rootElement) 
if marker then 
markers[marker] = {v[1], v[9], v[10], v[11], v[12]} 
addEventHandler("onMarkerHit", marker, onSpawnerMarkerHit) 
setElementData(marker,"teamMarker",true) 
    end 
  end 
end) 
  
function onSpawnerMarkerHit(hitPlayer, matchingDimension) 
if not matchingDimension then return end 
if getElementType(hitPlayer) == "player" then 
if isPedInVehicle(hitPlayer) then return end 
local markerTeam = getElementData(source,"teamMarker") 
if not markerTeam then return end 
local teamName = getElementData(hitPlayer,tostring(markers[source][4])) 
if not teamName then return end 
for i,v in pairs(markers[source][1]) do 
if v == teamName then 
triggerClientEvent(hitPlayer,"show_vehicle_selector",hitPlayer,markers[source][2],source) 
      end 
    end 
  end 
end 
  
addEvent("vehicle_spawn",true) 
addEventHandler("vehicle_spawn",rootElement, 
function (player, vehicleID, marker) 
    if isElement(playerVehicles[player]) then destroyElement(playerVehicles[player]) end 
    if isElement(playerTrailers[player]) then destroyElement(playerTrailers[player]) end 
    local x, y, z = getElementPosition(marker) 
    playerVehicles[player] = createVehicle(vehicleID, x, y, z+3, 0, 0, markers[marker][3]) 
    warpPedIntoVehicle(player, playerVehicles[player]) 
    setElementData(playerVehicles[player],"allowedJobs",markers[marker][1]) 
    setElementData(playerVehicles[player],"allowedData",markers[marker][4]) 
    if markers[marker][5] then 
        playerTrailers[player] = createVehicle(markers[marker][4], x-9, y, z + 3, 0, 0, markers[marker][3]) 
        if playerTrailers[player] then 
            setElementData(playerVehicles[player],"trailer",playerTrailers[player]) 
            addEventHandler("onVehicleExplode",playerTrailers[player],function () if isElement(source) then destroyElement(source) end end)     
        end 
    end 
    addEventHandler("onVehicleExplode",playerVehicles[player],function () if isElement(source) then if getElementData(source,"trailer") and isElement(getElementData(source,"trailer")) then destroyElement(getElementData(source,"trailer")) end destroyElement(source) end end) 
end) 
  
function vehicleEnterCheck(player, seat, jacked) 
    if (seat ~= 0) then return end 
    local allowedJobs = getElementData(source, "allowedJobs") 
    if not allowedJobs or not type(allowedJobs) == "table" then return end 
    local allowedData = getElementData(source, "allowedData") 
    local teamName = getElementData(player, tostring(allowedData)) 
    if not teamName then return end 
    local tempTable = {} 
    for index, Job in ipairs(allowedJobs) do 
        tempTable[Job] = true 
    end 
    local driver = getVehicleController(source) 
    local wanted = 0 
    if (driver) then 
        wanted = getPlayerWantedLevel(driver) 
    end 
    if (tempTable[teamName] or lawTeams[getTeamName(getPlayerTeam(player))] and wanted < 6) then 
        return 
    else 
        cancelEvent() 
        outputChatBox(player, "You cannot enter this vehicle.",255,100,0) 
    end 
end 
addEventHandler("onVehicleStartEnter",root,vehicleEnterCheck) 
  
function onLogoutOrQuit() 
    if isElement(playerVehicles[source]) then destroyElement(playerVehicles[source]) end 
    if isElement(playerTrailers[source]) then destroyElement(playerTrailers[source]) end 
end 
addEventHandler("onPlayerLogout",root,onLogoutOrQuit) 
addEventHandler("onPlayerQuit",root,onLogoutOrQuit) 
  

Edited by Guest
Link to comment
I told u dont :o post/give my code to anyone , remove it Any admin , its my group spawners

It's not your code or even his code ,why you lie?,This code is stolen from SAUR RPG already a code like it got removed by the owner of this code like a month ago or so , i don't think so you guys are allowed to use or edit them since the owner of those codes is still removing them!

I can't find the topic similer to this because the code is removed ,but here's a code from saur old version posted by you and removed by the owner of it, you can see it HERE and there are alot.

Read this TOPIC to know more about stolen resources.

try to learn like that you'll never succes you will always need to get leaked scripts or done scripts to edit them!

~Good luck

Link to comment
  • Moderators

Also stealing codes or entire resources and then asking for help to fix/modify it is just a joke. I can't believe some of the community members are doing that, it's a shame.

The solution to your question is obvious for all decent scripters (no need to be a Lua/MTA pro to know what to modify), and should be even more obvious for the one who really made this code.

As your question shows it: You are not the one who made this script, neither a good scripter.

It's time to do things by yourself and learn the basis of Lua/MTA. And you won't learn by posting 1 topic a day to ask for someone to do it for you.

Link to comment
I told u dont :o post/give my code to anyone , remove it Any admin , its my group spawners

It's not your code or even his code ,why you lie?,This code is stolen from SAUR RPG already a code like it got removed by the owner of this code like a month ago or so , i don't think so you guys are allowed to use or edit them since the owner of those codes is still removing them!

I can't find the topic similer to this because the code is removed ,but here's a code from saur old version posted by you and removed by the owner of it, you can see it HERE and there are alot.

Read this TOPIC to know more about stolen resources.

try to learn like that you'll never succes you will always need to get leaked scripts or done scripts to edit them!

~Good luck

lol bluntz gave me it xD i don't stole it

Link to comment
  • 2 weeks later...

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