How would I create a ragdoll to be the model in a SENT? I've tried before and it does this weird hull dragging thing..
[QUOTE=brandonj4;35353306]I have a question, why do you use k and then Sounds[k]? shouldnt it be the variables k and v since you are using the loop?
[lua]
if string.find( text, k ) then
ply:EmitSound(Sounds[k], 500, 100)
return text
[/lua][/QUOTE]
He can use either. He does need to add .Destination, though:
[lua]
if ply:IsValid() then
for k,v in pairs(Sounds) do
if string.find( text, k ) then
ply:EmitSound(Sounds[k].Destination, 500, 100) -- or v.Destination
return text
end
end
end
[/lua]
[QUOTE=brandonj4;35354549]How would I create a ragdoll to be the model in a SENT? I've tried before and it does this weird hull dragging thing..[/QUOTE]
yea, i've tried this before too and all I got was the ragdoll in a T pose, I think the functions to fix this are in the beta. But since I don't have the beta I can't test it.
I think these functions are it:
[b] from beta update 14 list [/b]
Added Ent:SetHitboxSet( i | string )
Added Ent:GetHitboxSet() (returns i, str)
Added Ent:GetHitboxSetCount()
Added Ent:GetHitboxBone()
Added Ent:GetBoneController( i ) (returns float)
Added Ent:SetBoneController( i, float )
at least I hope so because ragdoll SENTs would be fun to mess with.
I can't see firstperson reload animations!
[LUA]
self.Owner:SetAnimation( PLAYER_RELOAD) --firstperson, not working
self.Weapon:SendWeaponAnim( ACT_VM_RELOAD ) --thirdperson, working
[/LUA]
any idea how to repair it?
[QUOTE=_nonSENSE;35354597]He can use either. He does need to add .Destination, though:
[lua]
if ply:IsValid() then
for k,v in pairs(Sounds) do
if string.find( text, k ) then
ply:EmitSound(Sounds[k].Destination, 500, 100) -- or v.Destination
return text
end
end
end
[/lua][/QUOTE]
Thanks both. I thought I missed something like that.
[editline]30th March 2012[/editline]
Hm, still isn't emiting the sound.
[lua]
function SoundPlayer.ChatFunction( ply, text )
if ply:Alive() then
for k,v in pairs(Sounds) do
if string.find( text, k ) then
ply:EmitSound(Sounds[k].Destination, 500, 100) -- or v.Destination
return text
end
end
end
end
hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction)
[/lua]
[lua]
function ItemPickUpMenu()
local ItemPickUpFrame = vgui.Create( "DFrame" ) -- Creates the frame itself
ItemPickUpFrame:SetPos( 50,50 ) -- Position on the players screen
ItemPickUpFrame:SetSize( 200, 100 ) -- Size of the frame
ItemPickUpFrame:SetTitle( "" ) -- Title of the frame
ItemPickUpFrame:SetVisible( true )
ItemPickUpFrame:SetDraggable( true ) -- Draggable by mouse?
ItemPickUpFrame:ShowCloseButton( true ) -- Show the close button?
ItemPickUpFrame:MakePopup() -- Show the frame
ItemPickUpFrame:Center()
local ItemPickUpPList = vgui.Create("DPanelList", ItemPickUpFrame)
ItemPickUpPList:SetPos(2,24)
ItemPickUpPList:SetSize(200-4,100-26)
ItemPickUpPList:SetPadding(5)
Icon = vgui.Create("SpawnIcon") --Create the icon
Icon:SetPos(20, 20)
Icon:SetModel("models/FoodNHouseholdItems/bacon_2.mdl")
Icon.OnMousePressed = function()--This is the function to use.
Icon:Remove()--return false to disable the pressing effect
LocalPlayer():ChatPrint("Icon Removed")
LocalPlayer():AddMoney(10)
LocalPlayer():ChatPrint("10bucks")
end
ItemPickUpPList:AddItem(Icon)
end
concommand.Add("dotu_item_pickup", ItemPickUpMenu)
[/lua]
Any idea how I would add 10 bucks to their player when they press it?
[lua]
Icon:Remove()--return false to disable the pressing effect
LocalPlayer():ChatPrint("Icon Removed")
LocalPlayer():AddMoney(10)
LocalPlayer():ChatPrint("10bucks")
[/lua]
The addmoney command is serverside i cant run clientside unless i use console commands.
[LUA]
local ItemPickUpPList = vgui.Create("DPanelList", ItemPickUpFrame)
ItemPickUpPList:SetPos(2,24)
ItemPickUpPList:SetSize(200-4,100-26)
ItemPickUpPList:SetPadding(5)
Icon = vgui.Create("SpawnIcon") --Create the icon
Icon:SetPos(20, 20)
Icon:SetModel("models/FoodNHouseholdItems/bacon_2.mdl")
Icon.OnMousePressed = function()--This is the function to use.
Icon:Remove()--return false to disable the pressing effect
LocalPlayer():ChatPrint("Icon Removed")
if SERVER then
self.Owner:AddMoney(10)
end
LocalPlayer():ChatPrint("10bucks")
end
ItemPickUpPList:AddItem(Icon)
end
concommand.Add("dotu_item_pickup", ItemPickUpMenu)
[/LUA]
Maybe something like this.
[QUOTE=Krizzu;35357058]I can't see firstperson reload animations!
[LUA]
self.Owner:SetAnimation( PLAYER_RELOAD) --firstperson, not working
self.Weapon:SendWeaponAnim( ACT_VM_RELOAD ) --thirdperson, working
[/LUA]
any idea how to repair it?[/QUOTE]
[lua]self.Weapon:DefaultReload(ACT_VM_RELOAD)[/lua]
[QUOTE=pennerlord;35361092]
self.Weapon:DefaultReload(ACT_VM_RELOAD)[/QUOTE]
It's only for thirdperson? because In FPP I see nothing :/
And it's there any DropCurrentWeapon() ?
How how to drop current holding weapon?
[QUOTE=Persious;35358508]
Hm, still isn't emiting the sound.
[/QUOTE]
[lua]
function SoundPlayer.ChatFunction( ply, text )
if ply:Alive() then
for _, sound in pairs(Sounds) do
if string.find( text, sound.Text ) then
ply:EmitSound(sound.Destination, 500, 100)
return text
end
end
end
end
hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction)
[/lua]
There, now it makes sense. While k and v are typically used, you should try to give those variables a descriptive name and use _ when you do not need one of them.
snip I can't believe I was 50 minutes late
[QUOTE=_nonSENSE;35361708][lua]
function SoundPlayer.ChatFunction( ply, text )
if ply:Alive() then
for _, sound in pairs(Sounds) do
if string.find( text, sound.Text ) then
ply:EmitSound(sound.Destination, 500, 100)
return text
end
end
end
end
hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction)
[/lua]
There, now it makes sense. While k and v are typically used, you should try to give those variables a descriptive name and use _ when you do not need one of them.[/QUOTE]
Ah, thank you.
Thanks for trying to help but this is not a shared.lua file this is client only.
[lua]
if SERVER then
self.Owner:AddMoney(10)
end
[/lua]
You cant use that.
[QUOTE=brandonj4;35364171]Thanks for trying to help but this is not a shared.lua file this is client only.
[lua]
if SERVER then
self.Owner:AddMoney(10)
end
[/lua]
You cant use that.[/QUOTE]
That's why I use only shared.lua, instead of cl_init.lua and init.lua :D
So I tried allowing my SoundPlayer.AddSound to support multiple words, but had no idea what the fuck I was doing.
[lua]
SoundPlayer = {}
Sounds = {}
function SoundPlayer.AddSound(Text, Destination)
table.insert(Sounds, {{Text = Text}, Destination = Destination})
end
function SoundPlayer.ChatFunction( ply, text )
if ply:Alive() then
for _, sound in pairs(Sounds) do
if string.lower(text) == sound.Text then
ply:EmitSound(sound.Destination, 500, 100)
return text
end
end
end
end
hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction)
[/lua]
As you see, the table should support a table of more than one word.
I assume returning something stops the loop.
Well, it worked fine when I used my old one, aka
[lua]
SoundPlayer = {}
Sounds = {}
function SoundPlayer.AddSound(Text, Destination)
table.insert(Sounds, {Text = Text, Destination = Destination}) -- This one
end
function SoundPlayer.ChatFunction( ply, text )
if ply:Alive() then
for _, sound in pairs(Sounds) do
if string.lower(text) == sound.Text then
ply:EmitSound(sound.Destination, 500, 100)
return text
end
end
end
end
hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction)
[/lua]
What's wrong with the "old one"?
Nothing, the old one worked just fine, until I wanted each SoundPlayer.AddSound to allow multiple words, example SoundPlayer.AddSound({"hi", "hello", "fag"}, "sound directory here")
Check if Sounds is a table, if it is then loop through it.
Sounds is valid, I did loop through it, but still doesn't play the sound when I type one of the words in the table.
[lua]SoundPlayer = {}
Sounds = {}
function SoundPlayer.AddSound(Text, Destination)
table.insert(Sounds, {Text = Text, Destination = Destination}) -- This one
end
function SoundPlayer.ChatFunction( ply, text )
if ply:Alive() then
for _, sound in pairs(Sounds) do
if table.HasValue( sound.Text, text ) then
ply:EmitSound(sound.Destination, 500, 100)
return text
end
end
end
end
hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction)[/lua]
I'll try that, thanks.
[editline]31st March 2012[/editline]
Hook 'SoundPlayer.ChatFunction' Failed: bad argument #1 to 'pairs' (table expected, got nil)
does the table Sounds exist?
[QUOTE=Persious;35372477]I'll try that, thanks.
[editline]31st March 2012[/editline]
Hook 'SoundPlayer.ChatFunction' Failed: bad argument #1 to 'pairs' (table expected, got nil)[/QUOTE]
Are you trying to add some sounds as single words and some as multiple words?
If so, you can either fiddle around with checking type(sound.Text) or just change your single word ones so they are enclosed in {}
eg SoundPlayer.AddSound( { "hi" }, "directory" )
Hey, I know this is in the example questions for the thread, and I've searched around the site a little to find an answer, but came up empty.
So, is there a way to stop a player opening the console while they're on our server? Basically our users are spawning items with giveplayeritem rather than buying them from the in-game store, and we obviously want to prevent this.
Thanks,
Tom.
[QUOTE=TheTeekz;35374038]Hey, I know this is in the example questions for the thread, and I've searched around the site a little to find an answer, but came up empty.
So, is there a way to stop a player opening the console while they're on our server? Basically our users are spawning items with giveplayeritem rather than buying them from the in-game store, and we obviously want to prevent this.
Thanks,
Tom.[/QUOTE]
Never trust a player. Validate the command serverside and your problems are gone.
"..and how would we go about doing this? :smile:"
he asked, feeling like a lua noob. :suicide:
Does your/his shop uses the "giveplayeritem" command or another one?
It uses giveplayeritem, as far as we can tell. I could probably find the code again and post it, if it would help? We're currently running the GoFish mod.
Sorry, you need to Log In to post a reply to this thread.