Jump to content

[Help]problems with CarSell


Dziugasc

Recommended Posts

So i have few problems so first of all i can't find how to fix error : [16:46:04] ERROR: carsell\utils.lua:11: attempt to concatenate a boolean value

next problem that i couldn't find how to make car worth according it's health and model for exampe infernus 100% health would give you 22k Shamal 100% would give you 30k rhino 100% 20k etc

so what i need is just what to use

code:

local sellMarker = createMarker( -1545.0999755859, 126.80000305176, 2.5, "cylinder", 22, 255, 0, 0, 120)
local myBlip = createBlip( -1545.0999755859, 126.80000305176, 3.5999999046326, 55, 1.5, 255, 0, 255, myPlayer ) 
function sellVehicle(player) 
    if (getElementType(player) == "player") then 
        if (not getPedOccupiedVehicle(player)) then outputChatBox("You need to be in a Vehicle to sell it.", player, 255, 0, 0) return end   
            end 
        end       
        local vehicle = getPedOccupiedVehicle(player) 
        local reward = math.random(100, 10000) --every -1% from car vehicle worth becomes 100$ smaller example 100%=10k 10%=1k
        givePlayerMoney(player, reward) 
        outputChatBox("You have sold the "..getVehicleName(vehicle).. " for "..reward.."!", player, 0, 255, 0) 
addEventHandler("onMarkerHit", sellMarker, sellVehicle)

thanks.

 

 

Link to comment
15 minutes ago, IIYAMA said:

you might want to put the code inside of the function and inside of the CODE BLOCK AT LINE 4.

Your function ends at line 7.

 

 

now i fixed bugs but now i made that it would destroy car but i want that it wouldn't destroy but kick me out of vehicle and respawn it

and other question how to make vehicle worth with table like this?

local Planes = {"Beagle","Shamal","Dodo","Nevada","Crop Dustler","Stuntplane"}

 

Link to comment

so i made that it would kick player out of vehicle and lock it and re spawn it to spawn point but it re spawns vehicle locked i want it to be unlocked when it respawns

code:

local sellMarker = createMarker( -1545.0999755859, 126.80000305176, 2.5, "cylinder", 22, 255, 0, 0, 120)
local myBlip = createBlip( -1545.0999755859, 126.80000305176, 3.5999999046326, 55, 1.5, 255, 0, 255, player ) 
function sellVehicle(player) 
    if (getElementType(player) == "player") then 
        if (not getPedOccupiedVehicle(player)) then outputChatBox("You need to be in a Vehicle to sell it.", player, 255, 0, 0) return end         
        local vehicle = getPedOccupiedVehicle(player) 
        local prices = math.random(4000, 10000) 
        givePlayerMoney(player, prices) 
        outputChatBox("You have sold the "..getVehicleName(vehicle).. " for "..prices.."!", player, 0, 255, 0 ) 
		setVehicleLocked ( vehicle, true )
		removePlayerFromVehicle ( player )
        setTimer(respawnVehicle, 5000, 1, vehicle )
       end 
    end
end
addEventHandler("onMarkerHit",sellMarker, sellVehicle, carRespawn)

 

Edited by Dziugasc
Link to comment
local sellMarker = createMarker( -1545.0999755859, 126.80000305176, 2.5, "cylinder", 22, 255, 0, 0, 120)
local myBlip = createBlip( -1545.0999755859, 126.80000305176, 3.5999999046326, 55, 1.5, 255, 0, 255, player ) 
function sellVehicle(player) 
    if (getElementType(player) == "player") then 
        if (not getPedOccupiedVehicle(player)) then outputChatBox("You need to be in a Vehicle to sell it.", player, 255, 0, 0) return end         
        local vehicle = getPedOccupiedVehicle(player) 
        local prices = math.random(4000, 10000) 
        givePlayerMoney(player, prices) 
        outputChatBox("You have sold the "..getVehicleName(vehicle).. " for "..prices.."!", player, 0, 255, 0 ) 
		setVehicleLocked ( vehicle, true )
		removePlayerFromVehicle ( player )
        setTimer(function(veh)
        	respawnVehicle(veh)
        	setVehicleLocked(veh,false)
      		end,5000,1,vehicle)
       end 
    end
end
addEventHandler("onMarkerHit",sellMarker, sellVehicle, carRespawn)

 

  • Thanks 1
Link to comment
1 hour ago, Mr.Loki said:

local sellMarker = createMarker( -1545.0999755859, 126.80000305176, 2.5, "cylinder", 22, 255, 0, 0, 120)
local myBlip = createBlip( -1545.0999755859, 126.80000305176, 3.5999999046326, 55, 1.5, 255, 0, 255, player ) 
function sellVehicle(player) 
    if (getElementType(player) == "player") then 
        if (not getPedOccupiedVehicle(player)) then outputChatBox("You need to be in a Vehicle to sell it.", player, 255, 0, 0) return end         
        local vehicle = getPedOccupiedVehicle(player) 
        local prices = math.random(4000, 10000) 
        givePlayerMoney(player, prices) 
        outputChatBox("You have sold the "..getVehicleName(vehicle).. " for "..prices.."!", player, 0, 255, 0 ) 
		setVehicleLocked ( vehicle, true )
		removePlayerFromVehicle ( player )
        setTimer(function(veh)
        	respawnVehicle(veh)
        	setVehicleLocked(veh,false)
      		end,5000,1,vehicle)
       end 
    end
end
addEventHandler("onMarkerHit",sellMarker, sellVehicle, carRespawn)

 

Thanks :) okay topic locked (all problems was solved)

Edited by Dziugasc
if someone want to help me with free-roam server pm i have many great ideas and i need help :)
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...