[QUOTE=G4MB!T;47453849]
Also I cant see you setting SWEP.WorldModel in that snippet?[/QUOTE]
SWEP Constructive kit lets you get away with no world model afaik
[QUOTE=LUModder;47454196]How can I get if an entity is not inside a box
(the opposite of this)
[code]for id,ply in pairs(ents.FindInBox(DMDefine.Locations.pos1,DMDefine.Locations.pos2)) do[/code]
Trying to make a defined deathmatch area but want it to god people outside of the area
(this is in a think hook so)[/QUOTE]
In entitytakedamage hook return damage if they are in circle (use distance, don't do the for loop), else return no DMG
Wayyyy more efficient
[QUOTE=AnonTakesOver;47454225]In playerhurt hook return damage if they are in circle (use distance, don't do the for loop), else return false
Wayyyy more efficient[/QUOTE]
Will this effect godmode options at all?
EDIT: Also would like an example because this isn't working how I have it. (sorry for asking for spoonfeeding)
[QUOTE=LUModder;47454240]Will this effect godmode options at all?
EDIT: Also would like an example because this isn't working how I have it. (sorry for asking for spoonfeeding)[/QUOTE]
Ye Anon, does it? I mean.. Really? To the point, its a bit tricky but not impossible. You have a few options here. The first is to use godmode and god everyone who isnt in the box and revoke it to anyone who enters (Not hard, just not the best). The second is to do what you are doing. The way I would approach it is when an entity takes damage, get all entities in the box. If the list contains both players, then both players are inside the box. Its a tiny bit expensive since every time a player takes damage you need to do the check but the performance difference should be negligible.
[QUOTE=G4MB!T;47454479]Ye Anon, does it? I mean.. Really? To the point, its a bit tricky but not impossible. You have a few options here. The first is to use godmode and god everyone who isnt in the box and revoke it to anyone who enters (Not hard, just not the best). The second is to do what you are doing. The way I would approach it is when an entity takes damage, get all entities in the box. If the list contains both players, then both players are inside the box. Its a tiny bit expensive since every time a player takes damage you need to do the check but the performance difference should be negligible.[/QUOTE]
Which is why instead for looping if everyone is in the sphere, when a player is attacked, check if the player taking damage is within a distance from the origin of the sphere, if yes, allow damage, else don't allow damage. Also, if you want it so both players have to be in the sphere to take damage(which I assume, its logical), just do the same distance check with the attacker
This might work. I'm on my phone so can't test
[code]local sphere = { ["pos"] = Vector(100,100,0), ["size"] = 50 }
hook.Add("EntityTakeDamage", "LUModder", function( vic, dmg )
local pos = sphere.pos
local size = sphere.size
if math.abs(vic:GetPos():Distance(pos)) <= size then
local att = dmg:GetAttacker()
if math.abs(att:GetPos():Distance(pos)) <= size then
return true
end
end
end[/code]
For a box the size would be x length + y length + z length(I think? Bad at geometry), and the sphere size is the radius
That way you don't need to use god mode functions as this creates a 'god mode', and you aren't for looping through unnecessarily items, that'll be expensive, considering the amount of times its going to be called. And the function is only being called when it needs a definite result, instead of using think which will keep running constantly even if the result won't matter at the current tick.
Where is the source code for ents.FindInSphere and similar functions? I'm checking the github but I can't find it and I'm on my phone so its harder to look.
[QUOTE=thegrb93;47451748]COLLISION_GROUP_PLAYER should work
Maybe it only works on brushes.[/QUOTE]
I think COLLISION_GROUP_PLAYER represents the collision group that is applied to players. Which would collide with other players and props.
[lua]] _lua print(Drake():GetCollisionGroup()==COLLISION_GROUP_PLAYER)
true
[/lua]
[QUOTE=mcd1992;47454065]Hiding it will not prevent people from spawning the props inside.[/QUOTE]
Yeah i know, but it would look better for what i'm trying to make
Hey, i own a murder and i'm trying to custom the gamemode, i added some addon but i have a problem with the new knife that i want to add : When the murderer chase his victim, he can hit him but the victim don't lose any health and don't die.
Anyone know what should i add/change in the code to make it work?
PS: Sorry for my english, i'm french ^^
[QUOTE=alex223;47455786]
Anyone know what should i add/change in the code to make it work?[/QUOTE]
Nope. You are providing nothing to help us help you. Provide code or something.
[QUOTE=G4MB!T;47455835]Nope. You are providing nothing to help us help you. Provide code or something.[/QUOTE]
The code is REALLY REALLY long that's why i didn't posted it.
[code]if (SERVER) then
AddCSLuaFile( "shared.lua" )
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
local ActIndex = {}
ActIndex[ "knife" ] = ACT_HL2MP_IDLE_KNIFE //I wouldn't touch this.
function SWEP:SetWeaponHoldType( t ) //Or this.
local index = ActIndex[ t ] //Or any of this. Okay you get the point.
if (index == nil) then
return
end
self.ActivityTranslate = {}
self.ActivityTranslate [ ACT_HL2MP_IDLE ] = index
self.ActivityTranslate [ ACT_HL2MP_WALK ] = index + 1
self.ActivityTranslate [ ACT_HL2MP_RUN ] = index + 2
self.ActivityTranslate [ ACT_HL2MP_IDLE_CROUCH ] = index + 3
self.ActivityTranslate [ ACT_HL2MP_WALK_CROUCH ] = index + 4
self.ActivityTranslate [ ACT_HL2MP_GESTURE_RANGE_ATTACK ] = index + 5
self.ActivityTranslate [ ACT_HL2MP_GESTURE_RELOAD ] = index + 6
self.ActivityTranslate [ ACT_HL2MP_JUMP ] = index + 7
self.ActivityTranslate [ ACT_RANGE_ATTACK1 ] = index + 8
//Because we need animations
self:SetupWeaponHoldTypeForAI( t )
end
end
if ( CLIENT ) then
SWEP.PrintName = "Crescent Rose" //Name of the SWEP
SWEP.DrawAmmo = false //Knives don't use ammo!
SWEP.DrawCrosshair = false //Because we already got one.
SWEP.ViewModelFOV = 60 //Field of View, lower is closer, higher is farther.
SWEP.ViewModelFlip = false //Flip the model? Generally used for CS:S models but that's obsolete now.
SWEP.CSMuzzleFlashes = false //Does a knife have a gun barrel? I think not.
SWEP.Slot = 1 //Where does this weapon go? Where the crowbar goes, that's where!
SWEP.SlotPos = 1 //Place it at slot 1, if possible.
SWEP.IconLetter = "j" //What letter this uses for a killicon. Don't touch this, unless you know what letters are bound to what guns.
killicon.AddFont("weapon_rubyrose_scythe", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 )) //Sexy KillIcon. Too bad I don't know how to make a custom one work.
surface.CreateFont("CSKillIcons", {font = "csd", size = ScreenScale(30), weight = 500, antialias = true, additive = true})
surface.CreateFont("CSSelectIcons", {font = "csd", size = ScreenScale(60), weight = 500, antialias = true, additive = true})
end
SWEP.Category = "RWBY" //Where the SWEP is in the spawn menu.
SWEP.HoldType = "melee2" //How we hold this weapon.
SWEP.Spawnable = true //Can anyone spawn it?
SWEP.AdminSpawnable = true //Can admins only spawn it?
SWEP.ViewModel = "models/weapons/cstrike/c_knife_t.mdl" //The model shown on your screen in first person.
SWEP.WorldModel = "models/weapons/w_knife_t.mdl" //The model everyone else sees on screen. No point changing this, the model is replaced on obtaining this weapon.
SWEP.UseHands = true //Use C Models, basically hands that look like your model's hands. Custom models require custom hands.
SWEP.ShowViewModel = true //Show the view model? KEEP THIS TRUE AT ALL TIMES, IF DISABLED, ON WEAPON SWITCH ALL VIEWMODELS, INCLUDING EVERY GUN, WILL BE INVISIBLE!!
SWEP.ShowWorldModel = false //Show the world model?
SWEP.Weight = 5 //How tough this weapon is, for auto weapon switching. No point enabling this, autoswitch to and from is disabled.
SWEP.AutoSwitchTo = false //Switch to this weapon if weight is higher then the one we have in hand?
SWEP.AutoSwitchFrom = false //Allow other weapons to auto switch this gun, if it's weight is higher?
SWEP.Primary.ClipSize = -1 //This is a knife. No need for ammo.
SWEP.Primary.Damage = 75 //Don't touch this, instead goto line 144.
SWEP.Primary.DefaultClip = -1 //This is a knife, how could it hold clips?
SWEP.Primary.Automatic = true //Instead of clicking like a maniac, you can hold the mouse button.
SWEP.Primary.Ammo ="none" //Once again, this is a knife...
SWEP.WElements = {
["element_name"] = { type = "Model", model = "models/rubyscythe.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(2.596, 0, 0), angle = Angle(180, -180, 0), size = Vector(1.149, 1.149, 1.149), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
//WElements puts the scythe on the world model, so others see it.
SWEP.VElements = {
["scythe"] = { type = "Model", model = "models/rubyscythe.mdl", bone = "v_weapon.Knife_Handle", rel = "", pos = Vector(-0.151, -1, -1), angle = Angle(0, -90, 0), size = Vector(0.699, 0.699, 0.699), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
//VElements puts the scythe on the view model, so you can see it.
SWEP.Secondary.ClipSize = -1 //These are all obsolete, so don't fiddle with these.
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Damage = 200
SWEP.Secondary.Automatic = false
SWEP.MissSound = Sound("weapons/knife/knife_slash1.wav") //Play this sound when we miss.
SWEP.WallSound = Sound("weapons/knife/knife_hitwall1.wav") //Play this sound when we hit a wall. No, knives can't break down walls, silly.
SWEP.DeploySound = Sound("weapons/knife/knife_deploy1.wav") //Play this sound when we take out this bad boy!
/*---------------------------------------------------------
Think does nothing
---------------------------------------------------------*/
function SWEP:Think()
end
/*---------------------------------------------------------
Deploy plays the animation and draw sound
---------------------------------------------------------*/
function SWEP:Deploy()
self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
self.Weapon:SetNextPrimaryFire(CurTime() + 1) //Delay using this weapon for one second so we can play the animation.
self.Weapon:EmitSound( self.DeploySound, 50, 100 )
return true
end
/*---------------------------------------------------------
PrimaryAttack activated when we attack!
---------------------------------------------------------*/
function SWEP:PrimaryAttack()
vm = self.Owner:GetViewModel() //This is in place so we can always do a slashing animation. Do you want to hit an enemy with the back side of your scythe? I don't think so.
local tr = {}
tr.start = self.Owner:GetShootPos()
tr.endpos = self.Owner:GetShootPos() + ( self.Owner:GetAimVector() * 90 ) //90 is our range, higher means farther, lower is closer.
tr.filter = self.Owner
tr.mask = MASK_SHOT
local trace = util.TraceLine( tr )
self.Weapon:SetNextPrimaryFire(CurTime() + 0.70) //Add delay when we swing. If this wasn't in place, we'd swing 64 times a second, one per tick!
self.Owner:SetAnimation( PLAYER_ATTACK1 ) //Plays the attack animation on the player's thirdperson model.
if ( trace.Hit ) then
if trace.Entity:IsPlayer() or string.find(trace.Entity:GetClass(),"npc") or string.find(trace.Entity:GetClass(),"prop_ragdoll") then //Find what we're hitting. If it matches any of these, run this snippet of code.
self.Weapon:SendWeaponAnim( ACT_VM_IDLE ) //Act all idle and stuff.
vm:SetSequence(vm:LookupSequence("midslash2")) //Slash at it!
bullet = {}
bullet.Num = 1
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector(0, 0, 0)
bullet.Tracer = 0
bullet.Force = 1000
bullet.Damage = 120 //Damage it!
self.Owner:FireBullets(bullet)
self.Weapon:EmitSound( "weapons/knife/knife_hit" .. math.random(1, 4) .. ".wav" ) //Play the slash sound!
else
self.Weapon:SendWeaponAnim( ACT_VM_IDLE )
vm:SetSequence(vm:LookupSequence("midslash2"))
bullet = {}
bullet.Num = 1
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector(0, 0, 0)
bullet.Tracer = 0
bullet.Force = 1000
bullet.Damage = 95
self.Owner:FireBullets(bullet)
self.Weapon:EmitSound( self.WallSound )
util.Decal("ManhackCut", trace.HitPos + trace.HitNormal, trace.HitPos - trace.HitNormal) //Paint a nic
Hello.
I made a swep which isn't ment for shooting, but for configuring things, and when ever i use that swep to shoot or reload, it spams the left click and spams the reload key, do you have any ideas how to solve this?
I am using a Curtime variable, but because it spams instantly, multiple times, it has trouble working.
Post it in lua tags not quote.
[editline]4th April 2015[/editline]
[QUOTE=tzahush;47455909]Hello.
I made a swep which isn't ment for shooting, but for configuring things, and when ever i use that swep to shoot or reload, it spams the left click and spams the reload key, do you have any ideas how to solve this?
I am using a Curtime variable, but because it spams instantly, multiple times, it has trouble working.[/QUOTE]
Code... Seriously..
Problems That Don't Need Their Own Thread v3.0: Post the fucking code.
That should be the title for the next thread.
Posting your code is just an unwritten rule. Maybe it should be written though, with how many can't understand it.
Is there an easy way of encoding special characters into ASCII references for URLs without doing a shit-ton of gsubs? If you don't understand what I mean:
[url]http://www.w3schools.com/tags/ref_urlencode.asp[/url]
[QUOTE=r0uge;47456807]Is there an easy way of encoding special characters into ASCII references for URLs without doing a shit-ton of gsubs? If you don't understand what I mean:
[url]http://www.w3schools.com/tags/ref_urlencode.asp[/url][/QUOTE]
[lua]
str = string.gsub(str, "([&=+%c])", function (c) return string.format("%%%02X", string.byte(c)) end)
str = string.gsub(str, " ", "+")
[/lua]
[QUOTE=Drakehawke;47456856][lua]
str = string.gsub(str, "([&=+%c])", function (c) return string.format("%%%02X", string.byte(c)) end)
str = string.gsub(str, " ", "+")
[/lua][/QUOTE]
Thanks, one problem though, it seems to work for some symbols but not all of them. Is there any way to get it to work for the whole table?
Is there a way to get the UV coordinates of the texture hit using LocalPlayer():GetEyeTrace().
[QUOTE=r0uge;47456914]Thanks, one problem though, it seems to work for some symbols but not all of them. Is there any way to get it to work for the whole table?[/QUOTE]
Try
[lua]
out = in:gsub( "(%W)", function( c ) return string.format( "%%%02X", c:byte() ) end ):gsub( " ", "+" )
[/lua]
[QUOTE=r0uge;47456914]Thanks, one problem though, it seems to work for some symbols but not all of them. Is there any way to get it to work for the whole table?[/QUOTE]
"([&=+%c])" is the capture. If you want other symbols just add them in between the square brackets. In the solution Lixquid posted %W represents any non-alphanumeric character so that will probably work too.
So I never really got an answer to this but I'm working on a Ammo Hud and so far I have the ammo in the clip down. Yet I can't seem to find out how to call the total ammo count. I have tried Ammo1() and many other things but they always come up nil.
Hello, I'm making a SWEP and have a problem, here is the code
[LUA]quotes = {"sound/weapons/allu/allu_beer.mp3", "sound/weapons/allu/allu_daily_heroin.mp3", "sound/weapons/allu/allu_drank_beer.mp3", "sound/weapons/allu/allu_icecold_beer.mp3", "sound/weapons/allu/allu_pushit.mp3", "sound/weapons/allu/allu_redbull.mp3", "sound/weapons/allu/allu_steaks.mp3"}
SWEP.Primary.Sound = Sound( table.Random(quotes) )[/LUA]
What I want is whenever I fire the weapon it plays a random .mp3 file from the quotes, the problem I have is making it random. It always plays the same sound whenever I shoot my weapon. I do a map change on single player, a different sound plays but it doesn't change, it only plays one sound.
Please help.
[QUOTE=FuzionUK;47458279]Hello, I'm making a SWEP and have a problem, here is the code
[LUA]quotes = {"sound/weapons/allu/allu_beer.mp3", "sound/weapons/allu/allu_daily_heroin.mp3", "sound/weapons/allu/allu_drank_beer.mp3", "sound/weapons/allu/allu_icecold_beer.mp3", "sound/weapons/allu/allu_pushit.mp3", "sound/weapons/allu/allu_redbull.mp3", "sound/weapons/allu/allu_steaks.mp3"}
SWEP.Primary.Sound = Sound( table.Random(quotes) )[/LUA]
What I want is whenever I fire the weapon it plays a random .mp3 file from the quotes, the problem I have is making it random. It always plays the same sound whenever I shoot my weapon. I do a map change on single player, a different sound plays but it doesn't change, it only plays one sound.
Please help.[/QUOTE]
The SWEP's lua file is initialised when the gamemode is loaded (after each map change), meaning that the SWEP.Primary.Sound = Sound( table.Random(quotes) ) is only called once. This means that the sound would be random, but the sound is only randomly chosen once after each map change.
Is there any way in which i can limit the amount of rope a player can spawn, would be great if i could avoid the use of other prop protection addons.
Would i use:
ply:GetCount("rope") - Does that even exist?
Confused on which hook i'd use
Hello,
I'm looking for a script to do a character creation menus a little like this:
[IMG]http://i.ytimg.com/vi/BqwDSNJaH3k/maxresdefault.jpg[/IMG]
It is possible or very hard to do, is there a tutorial or free script to download it?
Thank you.
Sorry if my english is bad, i'm french
I have put it in the SWEP:PrimaryAttack()
[LUA]function SWEP:PrimaryAttack()
quotes = {"sound/weapons/allu/allu_beer.mp3", "sound/weapons/allu/allu_daily_heroin.mp3", "sound/weapons/allu/allu_drank_beer.mp3", "sound/weapons/allu/allu_icecold_beer.mp3", "sound/weapons/allu/allu_pushit.mp3", "sound/weapons/allu/allu_redbull.mp3", "sound/weapons/allu/allu_steaks.mp3"}
self.Weapon:EmitSound( table.Random(quotes) )[/LUA]
I have played around with the self.Weapon:EmitSound( self.Primary.Sound ) and apparently keeping that in helps it, I still need help so if you could help me then that would be great :D
Is there any way I can get my Lua script to accept UTF-8 characters?
I want to use inputs with letters that have accents, but they are converted to the � symbol.