Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.38 KB | None | 0 0
  1. include("autorun/carunlocks_sh.lua")
  2. AddCSLuaFile("autorun/carunlocks_sh.lua")
  3. AddCSLuaFile("autorun/client/Garage_cl.lua")
  4.  
  5. hook.Add("InitPostEntity", "SpawnNPCCars", function()
  6. timer.Simple(6, function()
  7. local NPC = ents.Create("test")
  8. NPC:SetPos(NPCLocationCars[string.lower(game.GetMap())])
  9. -- NPC:SetPos(Vector(-1350, 0.673042, -131.968750))
  10. -- if NPCLocationCars[string.lower(game.GetMap())][2] then
  11. -- NPC:SetAngles(NPCLocationCars[string.lower(game.GetMap())][2])
  12. -- end
  13. NPC:Spawn()
  14. NPC:Activate()
  15. for k,v in pairs(FuelSpawnLocation[string.lower(game.GetMap())]) do
  16.  
  17. local FuelStation = ents.Create("FuelStation")
  18. FuelStation:SetPos(v)
  19. FuelStation:Spawn()
  20. FuelStation:Activate()
  21.  
  22. end
  23.  
  24. local FuelStation = ents.Create("FuelStation")
  25. FuelStation:SetPos(FuelSpawnLocation[string.lower(game.GetMap())])
  26. FuelStation:Spawn()
  27. FuelStation:Activate()
  28. end)
  29. end)
  30.  
  31. concommand.Add("SpawnNPCEE", function()
  32. local NPC = ents.Create("test")
  33. NPC:SetPos(NPCLocationCars[string.lower(game.GetMap())])
  34. -- NPC:SetPos(Vector(-1350, 0.673042, -131.968750))
  35. NPC:Spawn()
  36. NPC:Activate()
  37. end)
  38.  
  39.  
  40. function SendUnlockedCars(ply)
  41. for k,v in pairs(AvailableCars) do
  42. ply["UnlockedCar" .. k ] = ply:GetPData("UnlockedCar" .. k)
  43. if ply["UnlockedCar" .. k] then
  44. SendUserMessage("YourCars",ply, k)
  45. end
  46. end
  47. end
  48. hook.Add("PlayerInitialSpawn", "CarUnlockChecks", SendUnlockedCars)
  49.  
  50. --[[ if AlertAdminCars then return
  51. else
  52. MapName = game.GetMap()
  53. if not NPCLocation[MapName] or CarSpawnLocation[MapName] then
  54. AlertAdminCars = true
  55. timer.Create("MessageAdminsMalformed", 60,0, function()
  56. for k,v in pairs(player.GetAll()) do
  57. if v:IsAdmin() then
  58. v:ChatPrint("The car or car seller spawns are malformed. Therefore cars have been disabled.")
  59. end
  60. end
  61. end)
  62. end
  63. end --]]
  64.  
  65. function BuyCar(ply,cmd,args)
  66. number = math.Round(tonumber(args[1]))
  67. --[[ Msg(type(number))
  68. Msg(number)
  69. umsg.Start("BoughtCar", ply)
  70. umsg.Short(number)
  71. umsg.String(tostring(number))
  72. umsg.Long(number)
  73. umsg.End() --]]
  74. local entsaround = ents.FindInSphere(ply:GetPos(), 100)
  75. for k,v in pairs(entsaround) do
  76. if v:GetName() == "Garage Keeper" then
  77. ply.NPCShopNear = true
  78. end
  79. end
  80. if not ply.NPCShopNear then
  81. Notify(ply, 1, 4 , "You aren't near to the car seller")
  82. return
  83. end
  84. if number then
  85. local CarToBuy = AvailableCars[tonumber(number)]
  86. if CarToBuy then
  87. if not ply["UnlockedCar"..tonumber(number)] then
  88. if ply:CanAfford(CarToBuy[4]) then
  89. ply:AddMoney( - CarToBuy[4])
  90. ply["UnlockedCar".. number] = true
  91. ply:SetPData("UnlockedCar"..tonumber(number), true)
  92. Notify(ply,1,4,"You just bought a new car!")
  93. umsg.Start("BoughtCar", ply)
  94. umsg.Short(number)
  95. umsg.String(tostring(number))
  96. umsg.Long(number)
  97. umsg.End()
  98. SendUserMessage("YourCars", ply, number)
  99. else
  100. SendUserMessage("FailedPurchaseCar", ply, number)
  101. Notify(ply,1,4,"You do not have enough money to buy that car.")
  102. end
  103. else Notify(ply,1,4, "You already own that car")
  104. return
  105. end
  106. end
  107. else Notify(ply,1,4, "That isn't a real car.")
  108. end
  109. ply.NPCShopNear = false
  110. end
  111. concommand.Add("BuyCar", BuyCar)
  112.  
  113. concommand.Add("testt", function(ply, cmd, args)
  114. SendUserMessage("BoughtCar", ply, tonumber(args[1]))
  115. end)
  116.  
  117. function CanPlySpawnCar(ply, cmd, args)
  118. if not args[1] then ply:ChatPrint("You didn't specify a cat!") return end
  119. local entsaround = ents.FindInSphere(ply:GetPos(), 100)
  120. for k,v in pairs(entsaround) do
  121. if v:GetName() == "Garage Keeper" then
  122. ply.NPCShopNear = true
  123. end
  124. end
  125. if not ply.NPCShopNear then
  126. Notify(ply, 1,4, "You aren't near to the car seller")
  127. return
  128. end
  129. if ply["UnlockedCar"..tonumber(args[1])] then
  130. if not ply.CarInWorld then
  131. SpawnCar(args[1], ply)
  132. else ply:ChatPrint("You already have a spawned car.")
  133. SendUserMessage("CarInWorld", ply, tonumber(args[1]) )
  134. end
  135. else ply:ChatPrint("You do not own that car!")
  136. end
  137. end
  138. concommand.Add("SpawnCar", CanPlySpawnCar)
  139.  
  140. function SpawnCar(Index, ply)
  141. local carspawnpos = CarSpawnLocation[MapName]
  142. local car = ents.Create(AvailableCars[tonumber(Index)][3])
  143. car:SetModel(AvailableCars[tonumber(Index)][1])
  144. car:SetPos(CarSpawnLocation[string.lower(game.GetMap())])
  145. car:SetKeyValue("vehiclescript", AvailableCars[tonumber(Index)][2])
  146. car:SetAngles(Vector(37, 0, 0))
  147. car:Spawn()
  148. car:Activate()
  149. car:Fire("lock", "", 0)
  150. ply.CarInWorld = car
  151. Notify(ply,1,4,"You have just spawned a Vehicle!")
  152. car:Own(ply)
  153. local vehicleName = AvailableCars[tonumber(Index)][6]
  154. SpawningVehicleithxtraSeats( nil, nil, vehicleName, nil)
  155. SpawnVehicleWithExtraSeats( ply, car )
  156. end
  157.  
  158. function RemoveCar(ply, cmd, args)
  159. local entsaround = ents.FindInSphere(ply:GetPos(), 100)
  160. for k,v in pairs(entsaround) do
  161. if v:GetName() == "Garage Keeper" then
  162. ply.NPCShopNear = true
  163. end
  164. end
  165. if not ply.NPCShopNear then
  166. ply:ChatPrint("You aren't near to the car seller")
  167. return
  168. end
  169. if ply.CarInWorld then
  170. ply.CarInWorld:Remove()
  171. ply.CarInWorld = false
  172. else ply:ChatPrint("You haven't spawned a car!")
  173. end
  174. end
  175. concommand.Add("RemoveCar", RemoveCar)
  176.  
  177. concommand.Add("LockCars", function()
  178. for k,v in pairs(ents.GetAll()) do
  179. if v:IsVehicle() then
  180. v:SetNWBool("Disabled", true)
  181. end
  182. end
  183. end)
  184.  
  185. concommand.Add("UnLockCars", function()
  186. for k,v in pairs(ents.GetAll()) do
  187. if v:IsVehicle() then
  188. v:SetNWBool("Disabled", false)
  189. end
  190. end
  191. end)
  192.  
  193. function GivePetrol(amt, ply)
  194. ply.Petrol = ply.Petrol + amt
  195. ply:SetNWInt("Petrol", ply.Petrol)
  196. end
  197. --[[
  198. concommand.Add("Givemepetrol", function(ply,cmd,args)
  199. GivePetrol(10, ply)
  200. end)
  201. --]]
  202. hook.Add("PlayerEnteredVehicle", "PetrolStuff", function(ply, vehicle, role)
  203. Msg("\n role is "..role.."\n")
  204. if ply.Petrol > 0 then
  205. vehicle:SetNWBool("Disabled", false)
  206. else
  207. vehicle:SetNWBool("Disabled", true)
  208. end
  209. timer.Create("PetrolTimer"..ply:SteamID(),1,0, function(ply, vehicle)
  210. if not ply or not ply:Alive() then timer.Destroy("PetrolTimer"..ply:SteamID()) end
  211. if ply.Petrol > 0 then
  212. ply.Petrol = ply.Petrol - 0.12
  213. ply:SetNWInt("Petrol", ply.Petrol)
  214. else
  215. if vehicle then
  216. vehicle:SetNWBool("Disabled", true)
  217. ply:ConCommand("-back")
  218. ply:ConCommand("-forward")
  219. end
  220. end
  221. end, ply, vehicle)
  222. end)
  223.  
  224.  
  225. concommand.Add("ReloadAddon", function(ply,cmd,args)
  226. RestartCommand = ""
  227. for k,v in pairs(args) do
  228. RestartCommand = RestartCommand.." "..v
  229. end
  230. RunString(RestartCommand)
  231. end)
  232.  
  233. hook.Add("PlayerLeaveVehicle", "PetrolShizzle", function(ply, vehicle)
  234. if timer.IsTimer("PetrolTimer"..ply:SteamID()) then
  235. timer.Destroy("PetrolTimer"..ply:SteamID())
  236. end
  237. end)
  238.  
  239. hook.Add("PlayerSpawn", "GivePetrol", function(ply)
  240. ply.Petrol = 0
  241. ply:SetNWInt("Petrol", 0)
  242. end)
  243.  
  244. concommand.Add("MyPetrol", function(ply,cmd,args)
  245. Msg("\nYou have "..ply.Petrol.." petrol")
  246. end)
  247.  
  248. concommand.Add("BuyFuel", function(ply, cmd, args)
  249. FoundAAA = false
  250. if not (ply.Petrol == 100) then
  251. if ply.CarInWorld then
  252. local nearbystuff = ents.FindInSphere(ply:GetPos(), 500)
  253. for k,v in pairs(nearbystuff) do
  254. if v == ply.CarInWorld then
  255. ply.Petrol = 100
  256. ply:SetNWInt("Petrol", ply.Petrol)
  257. Notify(ply, 1, 4, "You Have Bought a Full Tank of Gas!")
  258. ply:AddMoney(-200)
  259. FoundAAA = true
  260. end
  261. end
  262. if not FoundAAA then
  263. Notify(ply, 1, 4, "Your car is too far away!")
  264. end
  265. end
  266. else
  267. Notify(ply, 1, 4 , "You already Have a full tank of gas!")
  268. end
  269. end)
  270.  
  271.  
  272. hook.Add("PlayerDisconnected", "RemoveCar", function(ply)
  273. if ply.CarInWorld then
  274. ply.CarInWorld:Remove()
  275. Msg("Removed ..........")
  276. end
  277. end)
  278.  
  279. -- rcon lua_run for k,v in pairs(player.GetAll()) do v:SetPos(Vector(-7022.003906,-6324.409668,128.031250)) end
  280. -- rcon lua_run for k,v in pairs(player.GetAll()) do v:SetPos(Vector(-6522.003906, -6324.409668, 128.031250)) end
  281. -- rcon lua_run for k,v in pairs(player.GetAll()) do v:SetPos(Vector(-7276.836914, -6036.190430, 136.031250)) end
  282.  
  283. -- lua_run_cl Msg(#AvailableCars)
  284. -- lua_run_cl Msg(#YourCars)
  285. -- lua_run_cl PrintTable(YourCars)
  286. -- lua_openscript autorun/server/carunlocks.lua
  287. -- lua_run for k,v in pairs(player.GetAll()) do v:SetPos(Vector(1251.527588 -2321.008545 -
  288. --131.968750)) end
  289. -- 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