• What do you need help with V4
    639 replies, posted
  • Avatar of silenced deat
  • [QUOTE=Banana Lord.;35341713]why doesn't he just use the function PERP uses to give players money instead of updating a SQL row which will be overwritten when the player reconnects anyway[/QUOTE] And what function would that be? is it this [lua]function PLAYER:SetCash ( value, stopSendToClient) self:SetPrivateInt("cash", value, stopSendToClient); end[/lua]
  • Avatar of Hugabuga
  • [lua] local SoundPlayer = {} local Sounds = {} function SoundPlayer.AddSound(Text, Destination) table.insert(Sounds, {Text = Text, Destination = Destination}) end SoundPlayer.AddSound("lol", "vo/eli_lab/al_laugh02.wav") function SoundPlayer.ChatFunction( ply, text ) if ply:IsValid() then for k,v in pairs(Sounds) do if string.find( text, k ) then ply:EmitSound(Sounds[k], 500, 100) return text end end end end hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction) [/lua] It doesn't emit the sound. No clue what I'm doing wrong tho.
  • Avatar of brandonj4
  • [QUOTE=Persious;35349442][lua] local SoundPlayer = {} local Sounds = {} function SoundPlayer.AddSound(Text, Destination) table.insert(Sounds, {Text = Text, Destination = Destination}) end SoundPlayer.AddSound("lol", "vo/eli_lab/al_laugh02.wav") function SoundPlayer.ChatFunction( ply, text ) if ply:IsValid() then for k,v in pairs(Sounds) do if string.find( text, k ) then ply:EmitSound(Sounds[k], 500, 100) return text end end end end hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction) [/lua] It doesn't emit the sound. No clue what I'm doing wrong tho.[/QUOTE] 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]
  • Avatar of brandonj4
  • 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..
  • Avatar of _nonSENSE
  • [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]
  • Avatar of Fantym420
  • [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.
  • Avatar of Krizzu
  • 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?
  • Avatar of Hugabuga
  • [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]
  • Avatar of brandonj4
  • [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.
  • Avatar of Krizzu
  • [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.
  • Avatar of pennerlord
  • [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]
  • Avatar of Krizzu
  • [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?
  • Avatar of _nonSENSE
  • [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.
  • Avatar of Hugabuga
  • [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.
  • Avatar of brandonj4
  • 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.
  • Avatar of Krizzu
  • [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
  • Avatar of Hugabuga
  • 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.
  • Avatar of Hugabuga
  • 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]
  • Avatar of Hugabuga
  • 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")
  • Avatar of Hugabuga
  • 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.
  • Avatar of Drakehawke
  • [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]
  • Avatar of Hugabuga
  • I'll try that, thanks. [editline]31st March 2012[/editline] Hook 'SoundPlayer.ChatFunction' Failed: bad argument #1 to 'pairs' (table expected, got nil)
  • Avatar of Drakehawke
  • [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" )
  • Avatar of TheTeekz
  • 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.
  • Avatar of pennerlord
  • [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.