Help with this code

i can spawn it, pick it up, and i try spawn it again and i get a message “Your vehicle is already in use” when its clearly not as iv picked it up.

[lua]
–[[
Name: “sh_car.lua”.
Product: “Cider (Roleplay)”.
–]]

if ( !cider.plugin.get(“Generic”) ) then return; end;

– Define the item table.
local ITEM = {};

– Set some information about the item.
ITEM.name = “Police car”;
ITEM.size = 5;
ITEM.cost = 70000;
ITEM.sellprice = 35000;
– ITEM.team = TEAM_REBELDEALER;
ITEM.model = “models/golf/golf.mdl”;
ITEM.batch = 1;
ITEM.store = true;
ITEM.plural = “Police car”;
ITEM.uniqueID = “copcar”;
ITEM.description = “An exclusive fast car police”;
ITEM.vehiclename = “copcar”
ITEM.vehiclescript = “scripts/vehicles/golf.txt”;
ITEM.vehiclebase = “prop_vehicle_jeep_old”;
ITEM.vehiclehorn = “lambohorn.wav”;



  • Called when a player uses the object.
    function ITEM:onUse(player)
    if (player:GetCount(“vehiculo”) == 1) then
    cider.player.notify(player, “! Your vehicle is already in use!”, 1);
  • Returns false because the player has reached the maximum number of vehicles.
    return false;

else

  • Check if the player is under heaven.
    local tr
    tr = { }
    tr.start = player:GetPos()
    tr.endpos = tr.start + Vector( 0, 0, 100000 )
    tr.filter = player
    tr = util.TraceLine( tr )
    if tr.HitSky then
    if (player:GetPos():Distance(player:GetEyeTrace().Hit Pos) < 350) then
    local car = ents.Create(ITEM.vehiclebase)

car:SetModel(ITEM.model)
car:SetKeyValue(“vehiclescript”,ITEM.vehiclescript )
car:SetPos(player:GetEyeTrace().HitPos)
car:SetNWEntity(“owner”,player)
car:SetNWEntity(“prizesell”,ITEM.sellprice)
car:SetNWEntity(“hornsound”,ITEM.vehiclehorn)
car:Spawn()
player:AddCount(“vehiculo”, car);
else
cider.player.notify(player, “! can not put your vehicle in a position so far!”, 1);
end
else
cider.player.notify(player, “! can not use your vehicle here!”, 1);
end
end
false return - The object is no longer cleared.
end

function ITEM:onPickup() end;

function ITEM:onSell() end;


– Register the item.
cider.item.register(ITEM);
[/lua]

I can’t help sorry but please use [lua] tags.

Your comments doesn’t really help when they are in spanish or whatever that is.

Edited

[LUA]
player:AddCount(“vehiculo”, car)
player:AddCleanup(“vehiculo”, car)
[/LUA]

that didnt seem to work

Oh I read the code wrong for some reason.

Well the code says if you pick an ITEM up then you can’t pick anymore up until your vehiculo is removed.

what the command to change that?

Jesus, you need to make a pickup command in sh_inventory.lua and sv_commands.lua…

There’s not a command to fix that. You have to remove a vehiculo after picking up one to use another one; that’s the fix or rather the intended use.