• Trying to revive sandbox chatsounds, need help with old code
    5 replies, posted
Chatsounds Errors: [CODE][ERROR] addons/chatsounds/lua/autorun/server/chatsounds.lua:1045: attempt to call global 'ValidEntity' (a nil value) 1. unknown - addons/chatsounds/lua/autorun/server/chatsounds.lua:1045 Timer Failed! [Simple][@addons/chatsounds/lua/autorun/server/chatsounds.lua (line 1070)][/CODE] If I can get help to fix this, I can give out the files if anyone wants this addon. Since I've looked around for this and I can only find it for DarkRP or just old broken code like this. I remember I almost had it working before many months ago, but I think I just forgot about it or gave up. I also kind of want to fix the "ravebreak" addon if anyone remembers that. It's having these errors: [CODE][ERROR] bad argument #1 to '?' (string expected, got no value) 1. unknown - [C]:-1 Timer Failed! [Simple][@addons/ravebreak/lua/autorun/rave.lua (line 61)][/CODE] I would appreciate help, thanks for looking.
We need code. Replace all instances of ValidEntity with IsValid
[QUOTE=code_gs;47550320]We need code. Replace all instances of ValidEntity with IsValid[/QUOTE] That is the only part of code where I found a suggestion, and I tried that exact thing. There is only 1 instance of ValidEntity, and when I replace it with IsValid the addon appears to go away. Meaning when I try to type a chatsound I don't even get errors or anything like the addon doesn't exist. And here's the lines of code with errors, let me know if you want more (or the whole thing). My mistake. chatsounds.lua: [CODE]1044 local function DoSound( ply, snd, num ) 1045 if IsValid(ply) then 1046 if MutedPlayers[ply:UniqueID( )] then return; end 1047 num = num or 0 1048 local pitch = math.random( 94, 102 ) 1049 for i = 1, num+1 do 1050 ply:EmitSound(Sound(snd), 90, pitch) 1051 end 1052 end 1053 end 1054 1055 local function PlayerSay( ply, text ) 1056 if MutedPlayers[ply:UniqueID( )] then return; end 1057 local TextList = GetList(text) 1058 1059 if #TextList > 1 then 1060 table.sort(TextList, function(a, b) return a[1] < b[1] end) 1061 end 1062 1063 local _, num = string.gsub(text, "[!]", "") 1064 local Time = 0 1065 for k,v in pairs(TextList) do 1066 local sound = SoundList[v[2]][math.random(#SoundList[v[2]])] 1067 if not sound then return; end 1068 if sound[2] and sound[2] ~= "" then 1069 local i 1070 timer.Simple(Time, DoSound, ply, sound[2], num) 1071 end 1072 Time = Time + sound[1] 1073 end 1074 end[/CODE] rave.lua: [CODE]1 if SERVER then 2 AddCSLuaFile("autorun/rave.lua") 3 4 function InitRave() 5 resource.AddFile("sound/ravebreak.mp3") 6 end 7 hook.Add("Initialize", "RaveInit", InitRave) 8 9 function RaveBreakSay( pl, text, teamonly ) 10 if (text == "!ravebreak") then 11 pl:ConCommand("ravebreak_now") 12 return text 13 end 14 end 15 hook.Add("PlayerSay", "RaveBreakSay", RaveBreakSay) 16 17 function RaveCommand( pl, cmd, args ) 18 if pl:IsAdmin() then 19 if not Raving then 20 RaveBreak() 21 else 22 pl:ChatPrint("You're already raving dude!") 23 end 24 end 25 end 26 concommand.Add("ravebreak_now",RaveCommand) 27 28 function RaveBreak() 29 umsg.Start("RaveBreak") 30 umsg.End() 31 32 Raving = true 33 34 // 1 second buildup 35 timer.Simple(1,function() 36 hook.Add("Think","RaveThink",RaveThink) 37 end) 38 39 timer.Simple(24,function() 40 hook.Remove("Think","RaveThink") 41 umsg.Start("RaveEnd") 42 umsg.End() 43 Raving = false 44 end) 45 46 end 47 48 function RaveThink() 49 for k, v in pairs(player.GetAll()) do 50 v:PrintMessage(HUD_PRINTCENTER,"RAVE BREAK!") 51 end 52 end 53 54 else 55 56 RAVESOUND = "ravebreak.mp3" 57 58 function RaveBreak(um) 59 RunConsoleCommand("stopsounds") 60 61 timer.Simple(0.01,surface.PlaySound,RAVESOUND) 62 timer.Simple(1,function() 63 hook.Add("RenderScreenspaceEffects", "RaveDraw",RaveDraw) 64 end) 65 end [/CODE]
bump
[url=https://docs.google.com/document/d/157blpvgS7-TzierM0WehBGa5W65HGG8ITXcxpYfY2G4/edit]Here's how to port old code.[/url]
[QUOTE=LegoGuy;47554322][url=https://docs.google.com/document/d/157blpvgS7-TzierM0WehBGa5W65HGG8ITXcxpYfY2G4/edit]Here's how to port old code.[/url][/QUOTE] Hey thanks, I have seen that before but didn't really try because I don't know the slightest thing about Lua/coding. However, I was able to fix chatsounds. Except sometimes when I type the word, it will be won't active until I do another word. This seemed to be common on the "Hello!" sound. Also I was not able to fix ravebreak since I'm not even sure what that first error means. I didn't know how to fix the timer either because it was different than that chatsounds one. Do you think you would know anything about those errors?
Sorry, you need to Log In to post a reply to this thread.