Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile( "cl_init.lua" )
- AddCSLuaFile( "shared.lua" )
- include( "shared.lua" )
- include( 'config.lua' )
- util.AddNetworkString( "openDuelMenu" )
- util.AddNetworkString( "sendDuelInfo" )
- util.AddNetworkString( "sendRequestDuelInfo" )
- util.AddNetworkString( "noLongerBeingDuelCh" )
- util.AddNetworkString( "sendVariablesDuel" )
- util.AddNetworkString( "DuelSE1" )
- util.AddNetworkString( "DuelSE2" )
- --!!!
- --DO NOT EDIT ANYTHING UNDER THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
- --!!!
- local function FindPlayers( name )
- local matches = {}
- for k,v in pairs(player.GetAll()) do
- if (v:GetName():lower():match( name:lower() ) ) then
- table.insert(matches,v)
- end
- end
- if (table.Count( matches ) == 0 ) then
- print( 'Found no matches!' )
- return false
- end
- if ( table.Count( matches ) > 1 ) then
- print( 'Found multiple matches. Specify more.' )
- return false
- end
- return matches[1]
- end
- net.Receive( "noLongerBeingDuelCh", function( length, client )
- for k,v in pairs(player.GetAll()) do
- v:SetNWBool( 'hasDuelTimeLeft', false )
- end
- end )
- net.Receive( "sendDuelInfo", function( length, client )
- local challengedPlyDuel = net.ReadString()
- local challengedWepDuel = net.ReadString()
- local challengedWagDuel = net.ReadString()
- local challengedPlyData = net.ReadEntity()
- local dueelWeppNum = net.ReadInt( 3 )
- if tonumber(challengedWagDuel) < 0 then
- client:Kick()
- end
- curChallengedPly = challengedPlyduel
- curChallenger = client:Nick()
- curWeaponUse = challengedWepDuel
- curWager = challengedWagDuel
- dueelWeppNum = duelWeppNum
- local challenged = challengedPlyData
- if challenged == client then
- client:Kick()
- end
- for k,v in pairs(player.GetAll()) do
- v:ChatPrint( "[Duels] "..client:Nick().." has challenged "..challengedPlyDuel.." to a duel for $"..challengedWagDuel.." using "..challengedWepDuel.."!" )
- end
- MenuChallengerDuel = client:Nick()
- MenuWeaponDuel = challengedWepDuel
- MenuWagerDuel = challengedWagDuel
- net.Start( "sendVariablesDuel" )
- net.WriteString( MenuChallengerDuel )
- net.WriteString( MenuWeaponDuel )
- net.WriteString( MenuWagerDuel )
- net.Send( challenged )
- challenged:SetNWBool( "isInDuel", true )
- if duelUseChatInstead == true then
- challenged:ChatPrint( "You were challenged! Type /acceptduel within 30 seconds to accept!" )
- else
- net.Start( "sendRequestDuelInfo" )
- net.Send( challenged )
- end
- challenged:SetNWBool( "hasDuelTimeLeft", true )
- challenged:SetNWEntity( "curChlngr", client )
- timer.Create( "duelAcceptTimer", 30, 1, function()
- if duelUseChatInstead == true then
- if challenged:GetNWBool( "hasDuelTimeLeft" ) == true then
- challenged:SetNWBool( "hasDuelTimeLeft", false )
- challenged:ChatPrint( "[Duels] Your time to accept the challenge is up!" )
- end
- end
- end )
- end )
- function DuelStart()
- for k,v in pairs(player.GetAll()) do
- v:ChatPrint( "A duel has started between "..curChallenger.." and "..curChallengedPly.."!" )
- end
- end
- hook.Add( 'PlayerShouldTakeDamage', 'noOtherDmgInDuel', function(ply, attacker)
- if ply:GetNWBool( "isCurDueling" ) != attacker:GetNWBool( "isCurDueling" ) then
- return false
- end
- end )
- hook.Add( "canDropWeapon", 'NoDropInDuel2', function( ply, weapon )
- if ply:GetNWString( "isCurDueling" ) == true then
- return false
- end
- end )
- hook.Add( 'PlayerSay', 'NoHolsterInDuel', function( ply, text, isteam )
- text = string.lower( text )
- if (string.sub(text,0,11) == "/invholster") then
- if ply:GetNWBool( "isCurDueling" ) == true then
- DarkRP.notify(ply, 0, 6, "You can't holster weapons while dueling.")
- return false
- end
- end
- end )
- hook.Add( 'PlayerSpawnProp', 'NoPropsInDuel', function( ply, model )
- if ply:GetNWBool( 'isCurDueling' ) == true then
- DarkRP.notify( ply, 0, 6, "You can't spawn props during a duel." )
- return false
- end
- end)
- if !file.Exists("duelinginfo", "DATA") then
- file.CreateDir("duelinginfo")
- end
- if !file.Exists("duelinginfo/plyduels.txt", "DATA") then
- file.Write("duelinginfo/plyduels.txt", "{}")
- end
- if !file.Exists("duelinginfo/nextresetdate.txt", "DATA") then
- file.Write("duelinginfo/nextresetdate.txt", os.time()+86400)
- end
- timer.Create("checkforweekthingduels", 5, 0, function()
- if tonumber(file.Read("duelinginfo/nextresetdate.txt")) < os.time() then
- print("new day XD!")
- file.Write("duelinginfo/nextresetdate.txt", os.time()+86400)
- file.Write("duelinginfo/plyduels.txt", "{}")
- end
- end)
- hook.Add( 'PlayerSay', 'kaegare', function(ply, text, isteam)
- text = string.lower( text )
- if (string.sub(text,0,11) == "/acceptduel") then
- text = string.Explode( " ", text )
- if ply:GetNWBool( "hasDuelTimeLeft" ) == true then
- ply:ChatPrint( "[Duels] You accepted the challenge." )
- ply:SetNWBool( "hasDuelTimeLeft", false )
- for k,v in pairs(player.GetAll()) do
- v:SetNWBool( "isCurDueling", false )
- end
- duelAvailable = false
- duelAvailableText = "unavailable"
- local dueler1 = ply:GetNWEntity( "curChlngr" )
- local dueler2 = ply
- if dueler1:InVehicle() then
- dueler1:ExitVehicle()
- end
- if dueler2:InVehicle() then
- dueler2:ExitVehicle()
- end
- dueler1:SetNWBool( "isCurDueling", true )
- dueler2:SetNWBool( "isCurDueling", true )
- dueler1:SetNWVector( "b4DuelPlace", dueler1:GetPos() )
- dueler2:SetNWVector( "b4DuelPlace", dueler2:GetPos() )
- if !dueler1:Alive() then
- dueler1:Spawn()
- end
- if !dueler2:Alive() then
- dueler2:Spawn()
- end
- dueler1:SetPos( dueler1ArenaLocation )
- dueler1:SetEyeAngles( dueler1ArenaAngle )
- dueler2:SetPos( dueler2ArenaLocation )
- dueler2:SetEyeAngles( dueler2ArenaAngle )
- dueler1:StripWeapons()
- dueler2:StripWeapons()
- dueler1:SetHealth( 500 )
- dueler2:SetHealth( 500 )
- if curWeaponUse == "Fists" then
- dueler1:Give( "weapon_fists" )
- dueler2:Give( "weapon_fists" )
- elseif curWeaponUse == "Sword" then
- dueler1:Give( "m9k_damascus" )
- dueler2:Give( "m9k_damascus" )
- elseif curWeaponUse == "Lightsaber" then
- dueler1:Give( "weapon_lightsaber_wos_jedisaber" )
- dueler2:Give( "weapon_lightsaber_wos_jedisaber" )
- elseif curWeaponUse == "DC-15a" then
- dueler1:Give( "tfa_swch_dc15a" )
- dueler2:Give( "tfa_swch_dc15a" )
- elseif curWeaponUse == "Stunstick" then
- dueler1:Give( "stunstick" )
- dueler2:Give( "stunstick" )
- elseif curWeaponUse == "Flame Thrower" then
- dueler1:Give( "wrist_flame" )
- dueler2:Give( "wrist_flame" )
- elseif curWeaponUse == "DC17M-AT" then
- dueler1:Give( "tfa_swch_dc17m_at" )
- dueler2:Give( "tfa_swch_dc17m_at" )
- elseif curWeaponUse == "Weststar 34" then
- dueler1:Give( "tfa_swch_alphablaster" )
- dueler2:Give( "tfa_swch_alphablaster" )
- elseif curWeaponUse == "DC17M-BR" then
- dueler1:Give( "tfa_swch_dc17m_br" )
- dueler2:Give( "tfa_swch_dc17m_br" )
- elseif curWeaponUse == "Random" then --Feel free to edit the table! Gives each player a random weapon from randomWeapons.
- 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"}
- dueler1:Give( table.Random( randomWeapons ) )
- dueler2:Give( table.Random( randomWeapons ) )
- /*PUT YOUR CUSTOM WEAPONS HERE. Here's an example:
- elseif curWeaponUse == "Stupid Weapon" then
- dueler1:Give( "weapon_imstupid" )
- dueler2:Give( "weapon_imstupid" )
- */
- end
- dueler1:Freeze( true )
- dueler2:Freeze( true )
- teihnvn = 3
- timer.Create( "countdownDuel", 1, 4, function()
- if teihnvn > 0 then
- dueler1:ChatPrint( "[Duel] "..teihnvn )
- dueler2:ChatPrint( "[Duel] "..teihnvn )
- net.Start( "DuelSE1" )
- net.Send( dueler1 )
- net.Start( "DuelSE1" )
- net.Send( dueler2 )
- teihnvn = teihnvn - 1
- else
- net.Start( "DuelSE2" )
- net.Send( dueler1 )
- net.Start( "DuelSE2" )
- net.Send( dueler2 )
- dueler1:ChatPrint( "DUEL START!" )
- dueler2:ChatPrint( "DUEL START!" )
- dueler1:Freeze( false )
- dueler2:Freeze( false )
- end
- end )
- hook.Add( 'PlayerDeath', 'playerdeathinDuel', function( ply, wep, killer )
- if ply:GetNWBool( "isCurDueling" ) then
- local victorrr = ""
- local vEnt = 0
- for k,v in pairs(player.GetAll()) do
- if (ply == v) then continue end
- if v:GetNWBool( "isCurDueling" ) then
- timer.Create( "victoryTimer", 3, 1, function()
- v:SetPos( v:GetNWVector( "b4DuelPlace" ) )
- v:addMoney( curWager )
- v:KillSilent()
- duelAvailable = true
- duelAvailableText = "available" end )
- victorrr = v:Nick()
- vEnt = v
- end
- v:ChatPrint( "[Duels] "..ply:Nick().." was just defeated in a duel!" )
- v:SetNWBool( "isCurDueling", false )
- end
- ply:ChatPrint( "[Duels] "..ply:Nick().." was just defeated in a duel!" )
- ply:SetPos( ply:GetNWVector( "b4DuelPlace" ) )
- ply:addMoney( -curWager )
- if ply:getDarkRPVar( "money" ) < 0 then
- ply:setSelfDarkRPVar( "money", 0 )
- end
- dueler1:SetNWBool( "isCurDueling", false )
- dueler2:SetNWBool( "isCurDueling", false )
- // saving json
- local duelNow = util.JSONToTable(file.Read("duelinginfo/plyduels.txt"))
- if !duelNow[ply:SteamID()] then
- duelNow[ply:SteamID()] = {name = ply:Nick(), wins = 1}
- file.Write("duelinginfo/plyduels.txt", util.TableToJSON(duelNow, true))
- else
- duelNow[ply:SteamID()] = {name = ply:Nick(), wins = duelNow[ply:SteamID()].wins + 1}
- file.Write("duelinginfo/plyduels.txt", util.TableToJSON(duelNow, true))
- end
- end
- end )
- else
- ply:ChatPrint( "[Duels] You are not being challenged." )
- end
- return ""
- end
- end )
- util.AddNetworkString("paperlacksduelthing")
- resource.AddSingleFile("materials/topduelerthing/scrollhwrp.png")
- /*
- for k, v in pairs(player.GetAll()) do
- local ply = v
- local duelNow = util.JSONToTable(file.Read("duelinginfo/plyduels.txt"))
- duelNow[ply:SteamID()] = {name = ply:Nick(), wins = 66}
- file.Write("duelinginfo/plyduels.txt", util.TableToJSON(duelNow, true))
- end
- */
- 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.
- // this is for the weekly person thing
- local function findbysteamid(id)
- for k, v in pairs(player.GetAll()) do
- if v:SteamID() == id then return v end
- end
- return false
- end
- timer.Create("paperlacksduelcaching", 5, 0, function()
- local biggestPly = false
- local plyEnt = 0
- for k, v in SortedPairsByMemberValue(util.JSONToTable(file.Read("duelinginfo/plyduels.txt")), "wins", true) do
- biggestPly = {name = v.name, wins = v.wins}
- plyEnt = findbysteamid(k)
- break
- end
- if istable(biggestPly) then
- net.Start("paperlacksduelthing")
- net.WriteTable(biggestPly)
- net.Broadcast()
- DuelingWeeklyWinner = biggestPly
- DuelingWeeklyWinner.ent = plyEnt
- end
- end)
- hook.Add("PaperlacksXPBoostDueling", "boostshitdueling", function(ply, amount)
- if DuelingWeeklyWinner.ent != false then
- if ply == DuelingWeeklyWinner.ent then
- ply:addXP(amount * duelXPBoostAmount, false, true)
- end
- end
- end)
- function ENT:Initialize( )
- self:SetModel( "models/player/barney.mdl" )
- self:SetHullType( HULL_HUMAN )
- self:SetHullSizeNormal( )
- self:SetNPCState( NPC_STATE_SCRIPT )
- self:SetSolid( SOLID_BBOX )
- self:CapabilitiesAdd( bit.bor( CAP_ANIMATEDFACE, CAP_TURN_HEAD ) )
- self:SetUseType( SIMPLE_USE )
- self:DropToFloor()
- self:SetMaxYawSpeed( 90 )
- end
- function ENT:OnTakeDamage()
- return false
- end
- function ENT:AcceptInput( name, activator, caller )
- if name == "Use" and caller:IsPlayer() then
- net.Start( "openDuelMenu", caller)
- net.Send( caller )
- end
- end
- concommand.Add( "whosdueling", function( ply )
- for k,v in pairs(player.GetAll()) do
- if v:GetNWBool( "isCurDueling" ) == true then
- ply:ChatPrint(v:Nick())
- end
- end
- end )
- concommand.Add( "rg5ry54grewgerger", function( ply )
- for k,v in pairs(player.GetAll()) do
- v:SetNWBool( "isCurDueling", false )
- end
- end )
- hook.Add( "InitPostEntity", "duelnpcspawn", function()
- local myEnt = ents.Create("npc_duel")
- myEnt:SetModel( "models/odessa.mdl" )
- myEnt:SetAngles(angleofDuelNPC)
- myEnt:SetPos(locationofDuelNPC)
- myEnt:Spawn()
- end )
- hook.Add( "PlayerDisconnected", "endduelondc", function( ply )
- if ply:GetNWBool( "isCurDueling" ) == true then
- for k,v in pairs(player.GetAll()) do
- v:ChatPrint( "[Duels] "..ply:Nick().." left, so the duel ended in a draw." )
- if v:GetNWBool( "isCurDueling" ) == true then
- v:SetNWBool( "isCurDueling", false )
- v:KillSilent()
- duelAvailable = true
- duelAvailableText = "available"
- end
- end
- end
- end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement