Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include("autorun/carunlocks_sh.lua")
- AddCSLuaFile("autorun/carunlocks_sh.lua")
- AddCSLuaFile("autorun/client/Garage_cl.lua")
- hook.Add("InitPostEntity", "SpawnNPCCars", function()
- timer.Simple(6, function()
- local NPC = ents.Create("test")
- NPC:SetPos(NPCLocationCars[string.lower(game.GetMap())])
- -- NPC:SetPos(Vector(-1350, 0.673042, -131.968750))
- -- if NPCLocationCars[string.lower(game.GetMap())][2] then
- -- NPC:SetAngles(NPCLocationCars[string.lower(game.GetMap())][2])
- -- end
- NPC:Spawn()
- NPC:Activate()
- for k,v in pairs(FuelSpawnLocation[string.lower(game.GetMap())]) do
- local FuelStation = ents.Create("FuelStation")
- FuelStation:SetPos(v)
- FuelStation:Spawn()
- FuelStation:Activate()
- end
- local FuelStation = ents.Create("FuelStation")
- FuelStation:SetPos(FuelSpawnLocation[string.lower(game.GetMap())])
- FuelStation:Spawn()
- FuelStation:Activate()
- end)
- end)
- concommand.Add("SpawnNPCEE", function()
- local NPC = ents.Create("test")
- NPC:SetPos(NPCLocationCars[string.lower(game.GetMap())])
- -- NPC:SetPos(Vector(-1350, 0.673042, -131.968750))
- NPC:Spawn()
- NPC:Activate()
- end)
- function SendUnlockedCars(ply)
- for k,v in pairs(AvailableCars) do
- ply["UnlockedCar" .. k ] = ply:GetPData("UnlockedCar" .. k)
- if ply["UnlockedCar" .. k] then
- SendUserMessage("YourCars",ply, k)
- end
- end
- end
- hook.Add("PlayerInitialSpawn", "CarUnlockChecks", SendUnlockedCars)
- --[[ if AlertAdminCars then return
- else
- MapName = game.GetMap()
- if not NPCLocation[MapName] or CarSpawnLocation[MapName] then
- AlertAdminCars = true
- timer.Create("MessageAdminsMalformed", 60,0, function()
- for k,v in pairs(player.GetAll()) do
- if v:IsAdmin() then
- v:ChatPrint("The car or car seller spawns are malformed. Therefore cars have been disabled.")
- end
- end
- end)
- end
- end --]]
- function BuyCar(ply,cmd,args)
- number = math.Round(tonumber(args[1]))
- --[[ Msg(type(number))
- Msg(number)
- umsg.Start("BoughtCar", ply)
- umsg.Short(number)
- umsg.String(tostring(number))
- umsg.Long(number)
- umsg.End() --]]
- local entsaround = ents.FindInSphere(ply:GetPos(), 100)
- for k,v in pairs(entsaround) do
- if v:GetName() == "Garage Keeper" then
- ply.NPCShopNear = true
- end
- end
- if not ply.NPCShopNear then
- Notify(ply, 1, 4 , "You aren't near to the car seller")
- return
- end
- if number then
- local CarToBuy = AvailableCars[tonumber(number)]
- if CarToBuy then
- if not ply["UnlockedCar"..tonumber(number)] then
- if ply:CanAfford(CarToBuy[4]) then
- ply:AddMoney( - CarToBuy[4])
- ply["UnlockedCar".. number] = true
- ply:SetPData("UnlockedCar"..tonumber(number), true)
- Notify(ply,1,4,"You just bought a new car!")
- umsg.Start("BoughtCar", ply)
- umsg.Short(number)
- umsg.String(tostring(number))
- umsg.Long(number)
- umsg.End()
- SendUserMessage("YourCars", ply, number)
- else
- SendUserMessage("FailedPurchaseCar", ply, number)
- Notify(ply,1,4,"You do not have enough money to buy that car.")
- end
- else Notify(ply,1,4, "You already own that car")
- return
- end
- end
- else Notify(ply,1,4, "That isn't a real car.")
- end
- ply.NPCShopNear = false
- end
- concommand.Add("BuyCar", BuyCar)
- concommand.Add("testt", function(ply, cmd, args)
- SendUserMessage("BoughtCar", ply, tonumber(args[1]))
- end)
- function CanPlySpawnCar(ply, cmd, args)
- if not args[1] then ply:ChatPrint("You didn't specify a cat!") return end
- local entsaround = ents.FindInSphere(ply:GetPos(), 100)
- for k,v in pairs(entsaround) do
- if v:GetName() == "Garage Keeper" then
- ply.NPCShopNear = true
- end
- end
- if not ply.NPCShopNear then
- Notify(ply, 1,4, "You aren't near to the car seller")
- return
- end
- if ply["UnlockedCar"..tonumber(args[1])] then
- if not ply.CarInWorld then
- SpawnCar(args[1], ply)
- else ply:ChatPrint("You already have a spawned car.")
- SendUserMessage("CarInWorld", ply, tonumber(args[1]) )
- end
- else ply:ChatPrint("You do not own that car!")
- end
- end
- concommand.Add("SpawnCar", CanPlySpawnCar)
- function SpawnCar(Index, ply)
- local carspawnpos = CarSpawnLocation[MapName]
- local car = ents.Create(AvailableCars[tonumber(Index)][3])
- car:SetModel(AvailableCars[tonumber(Index)][1])
- car:SetPos(CarSpawnLocation[string.lower(game.GetMap())])
- car:SetKeyValue("vehiclescript", AvailableCars[tonumber(Index)][2])
- car:SetAngles(Vector(37, 0, 0))
- car:Spawn()
- car:Activate()
- car:Fire("lock", "", 0)
- ply.CarInWorld = car
- Notify(ply,1,4,"You have just spawned a Vehicle!")
- car:Own(ply)
- local vehicleName = AvailableCars[tonumber(Index)][6]
- SpawningVehicleithxtraSeats( nil, nil, vehicleName, nil)
- SpawnVehicleWithExtraSeats( ply, car )
- end
- function RemoveCar(ply, cmd, args)
- local entsaround = ents.FindInSphere(ply:GetPos(), 100)
- for k,v in pairs(entsaround) do
- if v:GetName() == "Garage Keeper" then
- ply.NPCShopNear = true
- end
- end
- if not ply.NPCShopNear then
- ply:ChatPrint("You aren't near to the car seller")
- return
- end
- if ply.CarInWorld then
- ply.CarInWorld:Remove()
- ply.CarInWorld = false
- else ply:ChatPrint("You haven't spawned a car!")
- end
- end
- concommand.Add("RemoveCar", RemoveCar)
- concommand.Add("LockCars", function()
- for k,v in pairs(ents.GetAll()) do
- if v:IsVehicle() then
- v:SetNWBool("Disabled", true)
- end
- end
- end)
- concommand.Add("UnLockCars", function()
- for k,v in pairs(ents.GetAll()) do
- if v:IsVehicle() then
- v:SetNWBool("Disabled", false)
- end
- end
- end)
- function GivePetrol(amt, ply)
- ply.Petrol = ply.Petrol + amt
- ply:SetNWInt("Petrol", ply.Petrol)
- end
- --[[
- concommand.Add("Givemepetrol", function(ply,cmd,args)
- GivePetrol(10, ply)
- end)
- --]]
- hook.Add("PlayerEnteredVehicle", "PetrolStuff", function(ply, vehicle, role)
- Msg("\n role is "..role.."\n")
- if ply.Petrol > 0 then
- vehicle:SetNWBool("Disabled", false)
- else
- vehicle:SetNWBool("Disabled", true)
- end
- timer.Create("PetrolTimer"..ply:SteamID(),1,0, function(ply, vehicle)
- if not ply or not ply:Alive() then timer.Destroy("PetrolTimer"..ply:SteamID()) end
- if ply.Petrol > 0 then
- ply.Petrol = ply.Petrol - 0.12
- ply:SetNWInt("Petrol", ply.Petrol)
- else
- if vehicle then
- vehicle:SetNWBool("Disabled", true)
- ply:ConCommand("-back")
- ply:ConCommand("-forward")
- end
- end
- end, ply, vehicle)
- end)
- concommand.Add("ReloadAddon", function(ply,cmd,args)
- RestartCommand = ""
- for k,v in pairs(args) do
- RestartCommand = RestartCommand.." "..v
- end
- RunString(RestartCommand)
- end)
- hook.Add("PlayerLeaveVehicle", "PetrolShizzle", function(ply, vehicle)
- if timer.IsTimer("PetrolTimer"..ply:SteamID()) then
- timer.Destroy("PetrolTimer"..ply:SteamID())
- end
- end)
- hook.Add("PlayerSpawn", "GivePetrol", function(ply)
- ply.Petrol = 0
- ply:SetNWInt("Petrol", 0)
- end)
- concommand.Add("MyPetrol", function(ply,cmd,args)
- Msg("\nYou have "..ply.Petrol.." petrol")
- end)
- concommand.Add("BuyFuel", function(ply, cmd, args)
- FoundAAA = false
- if not (ply.Petrol == 100) then
- if ply.CarInWorld then
- local nearbystuff = ents.FindInSphere(ply:GetPos(), 500)
- for k,v in pairs(nearbystuff) do
- if v == ply.CarInWorld then
- ply.Petrol = 100
- ply:SetNWInt("Petrol", ply.Petrol)
- Notify(ply, 1, 4, "You Have Bought a Full Tank of Gas!")
- ply:AddMoney(-200)
- FoundAAA = true
- end
- end
- if not FoundAAA then
- Notify(ply, 1, 4, "Your car is too far away!")
- end
- end
- else
- Notify(ply, 1, 4 , "You already Have a full tank of gas!")
- end
- end)
- hook.Add("PlayerDisconnected", "RemoveCar", function(ply)
- if ply.CarInWorld then
- ply.CarInWorld:Remove()
- Msg("Removed ..........")
- end
- end)
- -- rcon lua_run for k,v in pairs(player.GetAll()) do v:SetPos(Vector(-7022.003906,-6324.409668,128.031250)) end
- -- rcon lua_run for k,v in pairs(player.GetAll()) do v:SetPos(Vector(-6522.003906, -6324.409668, 128.031250)) end
- -- rcon lua_run for k,v in pairs(player.GetAll()) do v:SetPos(Vector(-7276.836914, -6036.190430, 136.031250)) end
- -- lua_run_cl Msg(#AvailableCars)
- -- lua_run_cl Msg(#YourCars)
- -- lua_run_cl PrintTable(YourCars)
- -- lua_openscript autorun/server/carunlocks.lua
- -- lua_run for k,v in pairs(player.GetAll()) do v:SetPos(Vector(1251.527588 -2321.008545 -
- --131.968750)) end
- -- lua_run for k,v in pairs(player.GetAll()) do Msg(ents.FindInSphere(ply, 200)) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement