Jump to content

Help Me With Vehicle Spawn


Recommended Posts

Posted

In the lua below, it says dataToFindPlayersJob, and I want that changed to player team, witch i don't know how to do, because it has hard, and below where it says Roles = "FBI" thats for the team so someone please change this to team please and if server or client side needed just ask, thank you

------------------------------------------------------------------------------------ 
-- PROJECT: N/A 
-- DEVELOPERS:  Sebbe 
-- RIGHTS:  All rights reserved by developers 
------------------------------------------------------------------------------------ 
  
dataToFindPlayersJob = "Occupation" 
  
vehicles =  
    { 
         
        {Roles = "FBI", vehicles = {427, 596}, x = 1592.8000488281, y = -1606.9000244141, z = 13.39999961853, rotation = 25, r = 250, g = 250, b = 250, vehR = 0, vehG = 0, vehB = 255},  
    } 
  

EDIT: If you'd like, I want the wiki thing that will or need to be used so I can atleast try myself please tell me them.

Posted
You don't have to change that, you have to change the script which compares the element data to team.

But in game when i try it, it says these vehicles are reserved for the "FBI" and I'm using your gang system can you help me atleast change it up because im using your gang system and i want this to work with your gang system.

Posted
Then change this:
dataToFindPlayersJob = "Occupation" 

to:

dataToFindPlayersJob = "gang" 

ok thanks it works, 1 more thing, how do I make another row of the thing below.

        {Roles = "FBI", vehicles = {427, 596}, x = 1592.8000488281, y = -1606.9000244141, z = 13.39999961853, rotation = 25, r = 250, g = 250, b = 250, vehR = 0, vehG = 0, vehB = 255}, 
  

I want to make another one idk how to do it.

Posted
------------------------------------------------------------------------------------ 
-- PROJECT: N/A 
-- DEVELOPERS:  Sebbe 
-- RIGHTS:  All rights reserved by developers 
------------------------------------------------------------------------------------ 
  
dataToFindPlayersJob = "gang" 
  
vehicles = 
    { 
        {Roles = "FBI", vehicles = {427, 596}, x = 1592.8000488281, y = -1606.9000244141, z = 13.39999961853, rotation = 25, r = 250, g = 250, b = 250, vehR = 0, vehG = 0, vehB = 255}, 
        {Roles = "FBI", vehicles = {427, 596}, x = 1592.8000488281, y = -1606.9000244141, z = 13.39999961853, rotation = 25, r = 250, g = 250, b = 250, vehR = 0, vehG = 0, vehB = 255}, 
    } 
  

Posted
------------------------------------------------------------------------------------ 
-- PROJECT: N/A 
-- DEVELOPERS:  Sebbe 
-- RIGHTS:  All rights reserved by developers 
------------------------------------------------------------------------------------ 
  
dataToFindPlayersJob = "gang" 
  
vehicles = 
    { 
        {Roles = "FBI", vehicles = {427, 596}, x = 1592.8000488281, y = -1606.9000244141, z = 13.39999961853, rotation = 25, r = 250, g = 250, b = 250, vehR = 0, vehG = 0, vehB = 255}, 
        {Roles = "FBI", vehicles = {427, 596}, x = 1592.8000488281, y = -1606.9000244141, z = 13.39999961853, rotation = 25, r = 250, g = 250, b = 250, vehR = 0, vehG = 0, vehB = 255}, 
    } 
  

ok thanks but something else. I want something else to. I want user only alowed to get the vehicle if there in the Team "Police"

Posted

will I have to change:

dataToFindPlayersJob = "gang" 

To: (on another script same thing but different file to make more sense is this correct?

dataToFindPlayersJob = "team" 

Posted
No, you'll have to add another value to the table, then edit the script to use that value.

Will you show me how?

Another problem please help

I want the vehicle from looking at the picture to spawn Right side --> how do I do that please help me!

25s5zzd.png

Posted
On the script where it creates the spawners, there you have to edit it.

For your other problem, change "rotation" value.

To how much, and in the configuration or server/client?

Posted

Server Side: Now where do i change it please tell me?

local vehicle = {} 
  
function isVehicleSpawned(vehicle) 
    return getElementData(vehicle, "jobvehicle") 
end 
  
function doesPlayerHaveVehicleSpawned(player) 
    if (isElement(vehicle[player])) then  
        return true 
    else 
        return false 
    end 
end 
  
function destroyVehicle(vehicle, player) 
    if (isElement(vehicle[player])) then 
        destroyElement(vehicle[player]) 
    end 
end 
  
function createTheJobVehicles() 
    for index, table in ipairs(vehicles) do 
        marker = createMarker(table.x, table.y, table.z, "cylinder", 2, table.r, table.g, table.b) 
        setElementData(marker, "vehiclemarker-role", table.Roles) 
        setElementData(marker, "vehiclemarker-vehicles", table.vehicles) 
        setElementData(marker, "vehiclemarker-rotation", table.rotation) 
        vehicle[marker] = table.Roles 
        local position = table.x..", "..table.y..", "..table.z..", "..", "..table.rotation 
        local color = table.vehR..", "..table.vehG..", "..table.vehB..", " 
        setElementData(marker, "vehiclemarker-position", position) 
        setElementData(marker, "vehiclemarker-color", color) 
        addEventHandler("onMarkerHit", marker, onPlayerVehicleMarkerHit) 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, createTheJobVehicles) 
  
function onPlayerVehicleMarkerHit(player) 
    local role = getElementData(source, "vehiclemarker-role") 
    local vehicles = getElementData(source, "vehiclemarker-vehicles") 
    local rotation = getElementData(source, "vehiclemarker-rotation") 
    if (getElementType(player) == "player") then 
        if (getElementData(player, dataToFindPlayersJob) == role or role == "ALL") then 
            if (isPedInVehicle(player)) then return end 
            local position = getElementData(source, "vehiclemarker-position") 
            local color = getElementData(source, "vehiclemarker-color") 
            local posX, posY, posZ, rotation = unpack(split(position, ",")) 
            local r, g, b = unpack(split(color, ",")) 
            triggerClientEvent(player, "jobvehicles.showVehicleGUI", root, vehicles, rotation, posX, posY, posZ, rotation, r, g, b) 
        else 
            outputChatBox("This marker is reserved for '"..role.."'", player, 250, 0, 0) 
        end 
    end 
end 
  
  
function onPlayerSpawnVehicle(vid, vx, vy, vz, rotation, r, g, b) 
    if (isElement(vehicle[client])) then  
        destroyElement(vehicle[client]) 
    end 
    vehicle[client] = createVehicle(vid, vx, vy, vz) 
    setElementData(vehicle[client], "jobvehicle", true) 
    warpPedIntoVehicle(client, vehicle[client]) 
    setElementRotation(vehicle[client], 0, 0, rotation) 
    outputDebugString(getPlayerName(client).. " has spawned a '"..getVehicleNameFromModel(vid)) 
    outputServerLog(getPlayerName(client).. " has spawned a '"..getVehicleNameFromModel(vid).."'") 
    if (r) then 
        setVehicleColor(vehicle[client], r, g, b) 
    end 
end 
addEvent("jobvehicles.onPlayerSpawnVehicle", true) 
addEventHandler("jobvehicles.onPlayerSpawnVehicle", root, onPlayerSpawnVehicle) 
  
function destroyPlayerVehicle() 
    if (isElement(vehicle[source])) then 
        destroyElement(vehicle[source]) 
    end 
end 
addEventHandler("onPlayerWasted", root, destroyPlayerVehicle) 
addEventHandler("onPlayerLogout", root, destroyPlayerVehicle) 
addEventHandler("onPlayerQuit", root, destroyPlayerVehicle) 
  
function destroyMyOwnVehicle(player) 
    if (isElement(vehicle[player])) then  
        outputChatBox("You have succesfully destroyed your "..getVehicleNameFromModel(getElementModel(vehicle[player])).."!", player, 0, 255, 10) 
        destroyElement(vehicle[player]) 
    elseif (not isElement(vehicle[player])) then 
        outputChatBox("You currently do not have a job vehicle spawned to destroy!", player, 250, 0, 0) 
    end 
end 
addCommandHandler("destroyv", destroyMyOwnVehicle) 
  
  
function destroyVehicleOnExplode() 
    if (getElementData(source, "jobvehicle")) then 
        destroyElement(source) 
    end 
end 
addEventHandler("onVehicleExplode", root, destroyVehicleOnExplode) 
  
function onAdminDestroyJobVehicle(admin, cmd, target) 
    local accountname = getAccountName(getPlayerAccount(admin)) 
    if (hasObjectPermissionTo("user."..accountname, "function.kickPlayer") and target) then 
        local player = getPlayerFromName(target) 
        if (isElement(vehicle[player]) and player) then 
            outputChatBox("You have destroyed "..getPlayerName(player).."' s "..getVehicleNameFromModel(getElementModel(vehicle[player])).." (jobvehicle)", admin, 0, 255, 10) 
            outputChatBox(getPlayerName(admin).." has destroyed your "..getVehicleNameFromModel(getElementModel(vehicle[player])).." (jobvehicle)", player, 255, 10, 0) 
            destroyElement(vehicle[player]) 
        elseif (not isElement(vehicle[player]) and player) then 
            outputChatBox(getPlayerName(player).. " does not currently have any job vehicle spawned.", admin, 255, 10, 0) 
        else 
            outputChatBox("The player do not exist!", admin, 250, 0, 0) 
        end 
    end 
end 
addCommandHandler("dv", onAdminDestroyJobVehicle) 

Posted

Well, now you must add a new value to your table, then set it as element data when the marker is created ( like the roles ), then you compare the new value with the player team.

getPlayerTeam 
getTeamName 

Posted
No, you'll have to add another value to the table, then edit the script to use that value.

Another problem please help

I want the vehicle from looking at the picture to spawn Right side --> how do I do that please help me!

25s5zzd.png

Ok now I'm talking about this.

Posted
------------------------------------------------------------------------------------ 
-- PROJECT: N/A 
-- DEVELOPERS:  Sebbe 
-- RIGHTS:  All rights reserved by developers 
------------------------------------------------------------------------------------ 
  
dataToFindPlayersJob = "gang" 
  
vehicles = 
    { 
        {Roles = "FBI", vehicles = {427, 596}, x = 1592.8000488281, y = -1606.9000244141, z = 13.39999961853, rotation = 25, r = 250, g = 250, b = 250, vehR = 0, vehG = 0, vehB = 255}, 
        {Roles = "FBI", vehicles = {427, 596}, x = 1592.8000488281, y = -1606.9000244141, z = 13.39999961853, rotation = 25, r = 250, g = 250, b = 250, vehR = 0, vehG = 0, vehB = 255}, 
    } 
  

There, you can read "ROTATION".

Posted
------------------------------------------------------------------------------------ 
-- PROJECT: N/A 
-- DEVELOPERS:  Sebbe 
-- RIGHTS:  All rights reserved by developers 
------------------------------------------------------------------------------------ 
  
dataToFindPlayersJob = "gang" 
  
vehicles = 
    { 
        {Roles = "FBI", vehicles = {427, 596}, x = 1592.8000488281, y = -1606.9000244141, z = 13.39999961853, rotation = 25, r = 250, g = 250, b = 250, vehR = 0, vehG = 0, vehB = 255}, 
        {Roles = "FBI", vehicles = {427, 596}, x = 1592.8000488281, y = -1606.9000244141, z = 13.39999961853, rotation = 25, r = 250, g = 250, b = 250, vehR = 0, vehG = 0, vehB = 255}, 
    } 
  

There, you can read "ROTATION".

I've tried it, I've done 90, it faces the way in picture, I've done 180, same position. :L

Posted
I don't know how much, change it until it suits your needs.

Server side script file.

I've tried but just would face that 1 way and everytime i change it, it wouldnt move 1 Single bit!

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