Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.47 KB | None | 0 0
  1. AddCSLuaFile( "cl_init.lua" )
  2. AddCSLuaFile( "shared.lua" )
  3.  
  4.  
  5. include( "shared.lua" )
  6. include( 'config.lua' )
  7.  
  8. util.AddNetworkString( "openDuelMenu" )
  9. util.AddNetworkString( "sendDuelInfo" )
  10. util.AddNetworkString( "sendRequestDuelInfo" )
  11. util.AddNetworkString( "noLongerBeingDuelCh" )
  12. util.AddNetworkString( "sendVariablesDuel" )
  13. util.AddNetworkString( "DuelSE1" )
  14. util.AddNetworkString( "DuelSE2" )
  15.  
  16. --!!!
  17. --DO NOT EDIT ANYTHING UNDER THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
  18. --!!!
  19.  
  20. local function FindPlayers( name )
  21. local matches = {}
  22. for k,v in pairs(player.GetAll()) do
  23. if (v:GetName():lower():match( name:lower() ) ) then
  24. table.insert(matches,v)
  25. end
  26. end
  27. if (table.Count( matches ) == 0 ) then
  28. print( 'Found no matches!' )
  29. return false
  30. end
  31.  
  32. if ( table.Count( matches ) > 1 ) then
  33. print( 'Found multiple matches. Specify more.' )
  34. return false
  35. end
  36.  
  37. return matches[1]
  38. end
  39.  
  40. net.Receive( "noLongerBeingDuelCh", function( length, client )
  41. for k,v in pairs(player.GetAll()) do
  42. v:SetNWBool( 'hasDuelTimeLeft', false )
  43. end
  44. end )
  45.  
  46. net.Receive( "sendDuelInfo", function( length, client )
  47. local challengedPlyDuel = net.ReadString()
  48. local challengedWepDuel = net.ReadString()
  49. local challengedWagDuel = net.ReadString()
  50. local challengedPlyData = net.ReadEntity()
  51. local dueelWeppNum = net.ReadInt( 3 )
  52.  
  53. if tonumber(challengedWagDuel) < 0 then
  54. client:Kick()
  55. end
  56.  
  57.  
  58. curChallengedPly = challengedPlyduel
  59. curChallenger = client:Nick()
  60. curWeaponUse = challengedWepDuel
  61. curWager = challengedWagDuel
  62. dueelWeppNum = duelWeppNum
  63. local challenged = challengedPlyData
  64.  
  65. if challenged == client then
  66. client:Kick()
  67. end
  68.  
  69.  
  70. for k,v in pairs(player.GetAll()) do
  71. v:ChatPrint( "[Duels] "..client:Nick().." has challenged "..challengedPlyDuel.." to a duel for $"..challengedWagDuel.." using "..challengedWepDuel.."!" )
  72. end
  73.  
  74. MenuChallengerDuel = client:Nick()
  75. MenuWeaponDuel = challengedWepDuel
  76. MenuWagerDuel = challengedWagDuel
  77. net.Start( "sendVariablesDuel" )
  78. net.WriteString( MenuChallengerDuel )
  79. net.WriteString( MenuWeaponDuel )
  80. net.WriteString( MenuWagerDuel )
  81. net.Send( challenged )
  82.  
  83. challenged:SetNWBool( "isInDuel", true )
  84.  
  85. if duelUseChatInstead == true then
  86. challenged:ChatPrint( "You were challenged! Type /acceptduel within 30 seconds to accept!" )
  87. else
  88. net.Start( "sendRequestDuelInfo" )
  89. net.Send( challenged )
  90. end
  91.  
  92. challenged:SetNWBool( "hasDuelTimeLeft", true )
  93. challenged:SetNWEntity( "curChlngr", client )
  94.  
  95.  
  96. timer.Create( "duelAcceptTimer", 30, 1, function()
  97. if duelUseChatInstead == true then
  98. if challenged:GetNWBool( "hasDuelTimeLeft" ) == true then
  99. challenged:SetNWBool( "hasDuelTimeLeft", false )
  100. challenged:ChatPrint( "[Duels] Your time to accept the challenge is up!" )
  101. end
  102. end
  103. end )
  104.  
  105. end )
  106.  
  107. function DuelStart()
  108. for k,v in pairs(player.GetAll()) do
  109. v:ChatPrint( "A duel has started between "..curChallenger.." and "..curChallengedPly.."!" )
  110. end
  111. end
  112.  
  113. hook.Add( 'PlayerShouldTakeDamage', 'noOtherDmgInDuel', function(ply, attacker)
  114. if ply:GetNWBool( "isCurDueling" ) != attacker:GetNWBool( "isCurDueling" ) then
  115. return false
  116. end
  117. end )
  118.  
  119. hook.Add( "canDropWeapon", 'NoDropInDuel2', function( ply, weapon )
  120. if ply:GetNWString( "isCurDueling" ) == true then
  121. return false
  122. end
  123. end )
  124.  
  125.  
  126. hook.Add( 'PlayerSay', 'NoHolsterInDuel', function( ply, text, isteam )
  127. text = string.lower( text )
  128. if (string.sub(text,0,11) == "/invholster") then
  129. if ply:GetNWBool( "isCurDueling" ) == true then
  130. DarkRP.notify(ply, 0, 6, "You can't holster weapons while dueling.")
  131. return false
  132. end
  133. end
  134. end )
  135.  
  136. hook.Add( 'PlayerSpawnProp', 'NoPropsInDuel', function( ply, model )
  137. if ply:GetNWBool( 'isCurDueling' ) == true then
  138. DarkRP.notify( ply, 0, 6, "You can't spawn props during a duel." )
  139. return false
  140. end
  141. end)
  142.  
  143. if !file.Exists("duelinginfo", "DATA") then
  144. file.CreateDir("duelinginfo")
  145. end
  146.  
  147. if !file.Exists("duelinginfo/plyduels.txt", "DATA") then
  148. file.Write("duelinginfo/plyduels.txt", "{}")
  149. end
  150.  
  151.  
  152. if !file.Exists("duelinginfo/nextresetdate.txt", "DATA") then
  153. file.Write("duelinginfo/nextresetdate.txt", os.time()+86400)
  154. end
  155.  
  156. timer.Create("checkforweekthingduels", 5, 0, function()
  157. if tonumber(file.Read("duelinginfo/nextresetdate.txt")) < os.time() then
  158. print("new day XD!")
  159. file.Write("duelinginfo/nextresetdate.txt", os.time()+86400)
  160. file.Write("duelinginfo/plyduels.txt", "{}")
  161. end
  162. end)
  163.  
  164.  
  165. hook.Add( 'PlayerSay', 'kaegare', function(ply, text, isteam)
  166. text = string.lower( text )
  167. if (string.sub(text,0,11) == "/acceptduel") then
  168. text = string.Explode( " ", text )
  169.  
  170. if ply:GetNWBool( "hasDuelTimeLeft" ) == true then
  171. ply:ChatPrint( "[Duels] You accepted the challenge." )
  172. ply:SetNWBool( "hasDuelTimeLeft", false )
  173.  
  174. for k,v in pairs(player.GetAll()) do
  175. v:SetNWBool( "isCurDueling", false )
  176. end
  177.  
  178. duelAvailable = false
  179. duelAvailableText = "unavailable"
  180.  
  181. local dueler1 = ply:GetNWEntity( "curChlngr" )
  182. local dueler2 = ply
  183. if dueler1:InVehicle() then
  184. dueler1:ExitVehicle()
  185. end
  186. if dueler2:InVehicle() then
  187. dueler2:ExitVehicle()
  188. end
  189.  
  190. dueler1:SetNWBool( "isCurDueling", true )
  191. dueler2:SetNWBool( "isCurDueling", true )
  192.  
  193.  
  194. dueler1:SetNWVector( "b4DuelPlace", dueler1:GetPos() )
  195. dueler2:SetNWVector( "b4DuelPlace", dueler2:GetPos() )
  196.  
  197. if !dueler1:Alive() then
  198. dueler1:Spawn()
  199. end
  200. if !dueler2:Alive() then
  201. dueler2:Spawn()
  202. end
  203.  
  204. dueler1:SetPos( dueler1ArenaLocation )
  205. dueler1:SetEyeAngles( dueler1ArenaAngle )
  206. dueler2:SetPos( dueler2ArenaLocation )
  207. dueler2:SetEyeAngles( dueler2ArenaAngle )
  208.  
  209. dueler1:StripWeapons()
  210. dueler2:StripWeapons()
  211.  
  212. dueler1:SetHealth( 500 )
  213. dueler2:SetHealth( 500 )
  214.  
  215.  
  216.  
  217. if curWeaponUse == "Fists" then
  218. dueler1:Give( "weapon_fists" )
  219. dueler2:Give( "weapon_fists" )
  220. elseif curWeaponUse == "Sword" then
  221. dueler1:Give( "m9k_damascus" )
  222. dueler2:Give( "m9k_damascus" )
  223. elseif curWeaponUse == "Lightsaber" then
  224. dueler1:Give( "weapon_lightsaber_wos_jedisaber" )
  225. dueler2:Give( "weapon_lightsaber_wos_jedisaber" )
  226. elseif curWeaponUse == "DC-15a" then
  227. dueler1:Give( "tfa_swch_dc15a" )
  228. dueler2:Give( "tfa_swch_dc15a" )
  229. elseif curWeaponUse == "Stunstick" then
  230. dueler1:Give( "stunstick" )
  231. dueler2:Give( "stunstick" )
  232. elseif curWeaponUse == "Flame Thrower" then
  233. dueler1:Give( "wrist_flame" )
  234. dueler2:Give( "wrist_flame" )
  235. elseif curWeaponUse == "DC17M-AT" then
  236. dueler1:Give( "tfa_swch_dc17m_at" )
  237. dueler2:Give( "tfa_swch_dc17m_at" )
  238. elseif curWeaponUse == "Weststar 34" then
  239. dueler1:Give( "tfa_swch_alphablaster" )
  240. dueler2:Give( "tfa_swch_alphablaster" )
  241. elseif curWeaponUse == "DC17M-BR" then
  242. dueler1:Give( "tfa_swch_dc17m_br" )
  243. dueler2:Give( "tfa_swch_dc17m_br" )
  244. elseif curWeaponUse == "Random" then --Feel free to edit the table! Gives each player a random weapon from randomWeapons.
  245. local randomWeapons = { "weapon_fists", "weapon_crowbar", "stunstick", "weapon_rebcannon", "weapon_752_dc17dual", "m9k_damascus", "m9k_machete", "tfa_swch_dc15a", "weapon_lightsaber_wos_jedisaber", "tfa_swch_dc15a"}
  246. dueler1:Give( table.Random( randomWeapons ) )
  247. dueler2:Give( table.Random( randomWeapons ) )
  248. /*PUT YOUR CUSTOM WEAPONS HERE. Here's an example:
  249. elseif curWeaponUse == "Stupid Weapon" then
  250. dueler1:Give( "weapon_imstupid" )
  251. dueler2:Give( "weapon_imstupid" )
  252. */
  253. end
  254.  
  255. dueler1:Freeze( true )
  256. dueler2:Freeze( true )
  257. teihnvn = 3
  258. timer.Create( "countdownDuel", 1, 4, function()
  259.  
  260. if teihnvn > 0 then
  261. dueler1:ChatPrint( "[Duel] "..teihnvn )
  262. dueler2:ChatPrint( "[Duel] "..teihnvn )
  263. net.Start( "DuelSE1" )
  264. net.Send( dueler1 )
  265. net.Start( "DuelSE1" )
  266. net.Send( dueler2 )
  267. teihnvn = teihnvn - 1
  268. else
  269. net.Start( "DuelSE2" )
  270. net.Send( dueler1 )
  271. net.Start( "DuelSE2" )
  272. net.Send( dueler2 )
  273. dueler1:ChatPrint( "DUEL START!" )
  274. dueler2:ChatPrint( "DUEL START!" )
  275. dueler1:Freeze( false )
  276. dueler2:Freeze( false )
  277. end
  278. end )
  279.  
  280. hook.Add( 'PlayerDeath', 'playerdeathinDuel', function( ply, wep, killer )
  281. if ply:GetNWBool( "isCurDueling" ) then
  282. local victorrr = ""
  283. local vEnt = 0
  284. for k,v in pairs(player.GetAll()) do
  285. if (ply == v) then continue end
  286. if v:GetNWBool( "isCurDueling" ) then
  287. timer.Create( "victoryTimer", 3, 1, function()
  288. v:SetPos( v:GetNWVector( "b4DuelPlace" ) )
  289. v:addMoney( curWager )
  290. v:KillSilent()
  291. duelAvailable = true
  292. duelAvailableText = "available" end )
  293. victorrr = v:Nick()
  294. vEnt = v
  295. end
  296. v:ChatPrint( "[Duels] "..ply:Nick().." was just defeated in a duel!" )
  297. v:SetNWBool( "isCurDueling", false )
  298. end
  299. ply:ChatPrint( "[Duels] "..ply:Nick().." was just defeated in a duel!" )
  300. ply:SetPos( ply:GetNWVector( "b4DuelPlace" ) )
  301. ply:addMoney( -curWager )
  302. if ply:getDarkRPVar( "money" ) < 0 then
  303. ply:setSelfDarkRPVar( "money", 0 )
  304. end
  305. dueler1:SetNWBool( "isCurDueling", false )
  306. dueler2:SetNWBool( "isCurDueling", false )
  307. // saving json
  308. local duelNow = util.JSONToTable(file.Read("duelinginfo/plyduels.txt"))
  309. if !duelNow[ply:SteamID()] then
  310. duelNow[ply:SteamID()] = {name = ply:Nick(), wins = 1}
  311. file.Write("duelinginfo/plyduels.txt", util.TableToJSON(duelNow, true))
  312. else
  313. duelNow[ply:SteamID()] = {name = ply:Nick(), wins = duelNow[ply:SteamID()].wins + 1}
  314. file.Write("duelinginfo/plyduels.txt", util.TableToJSON(duelNow, true))
  315. end
  316. end
  317. end )
  318.  
  319. else
  320. ply:ChatPrint( "[Duels] You are not being challenged." )
  321. end
  322.  
  323. return ""
  324. end
  325. end )
  326.  
  327. util.AddNetworkString("paperlacksduelthing")
  328. resource.AddSingleFile("materials/topduelerthing/scrollhwrp.png")
  329.  
  330. /*
  331. for k, v in pairs(player.GetAll()) do
  332. local ply = v
  333. local duelNow = util.JSONToTable(file.Read("duelinginfo/plyduels.txt"))
  334. duelNow[ply:SteamID()] = {name = ply:Nick(), wins = 66}
  335. file.Write("duelinginfo/plyduels.txt", util.TableToJSON(duelNow, true))
  336. end
  337. */
  338.  
  339. local duelXPBoostAmount = 2/2 // give them an extra 10 percent of whatever amount of xp they got given, if this was 2, they would get 200% or 2 times the amount.
  340. // this is for the weekly person thing
  341.  
  342. local function findbysteamid(id)
  343. for k, v in pairs(player.GetAll()) do
  344. if v:SteamID() == id then return v end
  345. end
  346. return false
  347. end
  348.  
  349. timer.Create("paperlacksduelcaching", 5, 0, function()
  350. local biggestPly = false
  351. local plyEnt = 0
  352. for k, v in SortedPairsByMemberValue(util.JSONToTable(file.Read("duelinginfo/plyduels.txt")), "wins", true) do
  353. biggestPly = {name = v.name, wins = v.wins}
  354. plyEnt = findbysteamid(k)
  355. break
  356. end
  357. if istable(biggestPly) then
  358. net.Start("paperlacksduelthing")
  359. net.WriteTable(biggestPly)
  360. net.Broadcast()
  361. DuelingWeeklyWinner = biggestPly
  362. DuelingWeeklyWinner.ent = plyEnt
  363. end
  364.  
  365. end)
  366.  
  367. hook.Add("PaperlacksXPBoostDueling", "boostshitdueling", function(ply, amount)
  368. if DuelingWeeklyWinner.ent != false then
  369. if ply == DuelingWeeklyWinner.ent then
  370. ply:addXP(amount * duelXPBoostAmount, false, true)
  371. end
  372. end
  373. end)
  374.  
  375. function ENT:Initialize( )
  376.  
  377. self:SetModel( "models/player/barney.mdl" )
  378. self:SetHullType( HULL_HUMAN )
  379. self:SetHullSizeNormal( )
  380. self:SetNPCState( NPC_STATE_SCRIPT )
  381. self:SetSolid( SOLID_BBOX )
  382. self:CapabilitiesAdd( bit.bor( CAP_ANIMATEDFACE, CAP_TURN_HEAD ) )
  383. self:SetUseType( SIMPLE_USE )
  384. self:DropToFloor()
  385.  
  386. self:SetMaxYawSpeed( 90 )
  387.  
  388. end
  389.  
  390. function ENT:OnTakeDamage()
  391. return false
  392. end
  393.  
  394. function ENT:AcceptInput( name, activator, caller )
  395. if name == "Use" and caller:IsPlayer() then
  396. net.Start( "openDuelMenu", caller)
  397. net.Send( caller )
  398. end
  399. end
  400.  
  401. concommand.Add( "whosdueling", function( ply )
  402. for k,v in pairs(player.GetAll()) do
  403. if v:GetNWBool( "isCurDueling" ) == true then
  404. ply:ChatPrint(v:Nick())
  405. end
  406. end
  407. end )
  408.  
  409. concommand.Add( "rg5ry54grewgerger", function( ply )
  410. for k,v in pairs(player.GetAll()) do
  411. v:SetNWBool( "isCurDueling", false )
  412. end
  413. end )
  414.  
  415. hook.Add( "InitPostEntity", "duelnpcspawn", function()
  416. local myEnt = ents.Create("npc_duel")
  417. myEnt:SetModel( "models/odessa.mdl" )
  418. myEnt:SetAngles(angleofDuelNPC)
  419. myEnt:SetPos(locationofDuelNPC)
  420. myEnt:Spawn()
  421. end )
  422.  
  423. hook.Add( "PlayerDisconnected", "endduelondc", function( ply )
  424. if ply:GetNWBool( "isCurDueling" ) == true then
  425. for k,v in pairs(player.GetAll()) do
  426. v:ChatPrint( "[Duels] "..ply:Nick().." left, so the duel ended in a draw." )
  427. if v:GetNWBool( "isCurDueling" ) == true then
  428. v:SetNWBool( "isCurDueling", false )
  429. v:KillSilent()
  430. duelAvailable = true
  431. duelAvailableText = "available"
  432. end
  433. end
  434. end
  435. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement