1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

Spawn vehicles from F4 menu with specific skins

Discussion in 'DarkRP Modding Questions & Help' started by mikakater, Sep 7, 2019.

  1. mikakater

    mikakater New Member

    Hello,

    is it possible to spawn certain vehicles from the F4 menu with specific skins?

    I tried a code line from an old thread i found on the forum "onBought = function(ply, vehTable, vehicleEnt) vehicleEnt:SetSkin() end," but it didnĀ“t work and i get this error message:

    [DarkRP] addons/darkrpmodification-master/lua/darkrp_customthings/vehicles.lua:26: attempt to index global 'vehicleEnt' (a nil value)
    1. onBought - addons/darkrpmodification-master/lua/darkrp_customthings/vehicles.lua:26
    2. callback - gamemodes/darkrp/gamemode/modules/base/sv_purchasing.lua:332
    3. callback - gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua:17
    4. RP_PlayerChat - gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua:78
    5. unknown - gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua:143

    My Code look like this:

    DarkRP.createVehicle({
    name = "forcrownvicpoltdm",
    model = "models/tdmcars/emergency/for_crownvic.mdl",
    price = 0,
    label = "ECPD Ford Crown Victoria",
    distance = 500,
    angle = Angle(0, 90, 0),
    category = "Job Vehicles",
    allowed = {TEAM_POLICE}
    onBought = function(ply, vehTable, vehicleEnt) vehicleEnt:SetSkin(14) end,

    Thanks
     
  2. Huey

    Huey New Member

    Its saying its trying to call vehicleEnt, which is a non existent value. I'm thinking maybe that could have to do with how you entered the function. Maybe this will work?

    DarkRP.createVehicle({
    name = "forcrownvicpoltdm",
    model = "models/tdmcars/emergency/for_crownvic.mdl",
    price = 0,
    label = "ECPD Ford Crown Victoria",
    distance = 500,
    angle = Angle(0, 90, 0),
    category = "Job Vehicles",
    allowed = {TEAM_POLICE}
    onBought = vehicleEnt:SetSkin(14) end,

    If not maybe
    DarkRP.createVehicle({
    name = "forcrownvicpoltdm",
    model = "models/tdmcars/emergency/for_crownvic.mdl",
    price = 0,
    label = "ECPD Ford Crown Victoria",
    distance = 500,
    angle = Angle(0, 90, 0),
    category = "Job Vehicles",
    allowed = {TEAM_POLICE}
    onBought = Entity:SetSkin(14) end,
     
  3. mikakater

    mikakater New Member

    Thanks for your reply, i think Photon is causing the problem.
    I tried "onBought = function(ply, vehTable, vehicleEnt) vehicleEnt:SetSkin(XX) end," on a normal vehicle without photon. Works without problems, the car spawns with the right skin and no errors whatsoever.
     

Share This Page