[QUOTE=benji131201;48878032]The test 1 and Test 2 are working but not the Test 3 and Test 4 and I have this error :
[code]
Local file is overriding addon's file! gamemodes/darkrp/gamemode/modules/chatsounds.lua (DarkRP)
10/11/2015 10:40:19: Lua Error
[ERROR] gamemodes/darkrp/gamemode/modules/chatsounds.lua:37: attempt to call method 'IsCP' (a nil value)
1. v - gamemodes/darkrp/gamemode/modules/chatsounds.lua:37
2. unknown - gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua:138
[ERROR] gamemodes/darkrp/gamemode/modules/chatsounds.lua:37: attempt to call method 'IsCP' (a nil value)
1. v - gamemodes/darkrp/gamemode/modules/chatsounds.lua:37
2. unknown - gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua:138
[/code][/QUOTE]
Change IsCP to isCP.
[url]http://wiki.darkrp.com/index.php/Functions/Player/Shared/isCP[/url]
It's working ! Thank you all of you !
It worked yesterday but it's not working anymore, here's the new code :
[code]
local sounds = {
[ "Appliquer" ] = { "npc/metropolice/takedown.wav" },
[ "11-99" ] = { "npc/metropolice/vo npc/metropolice/vwo/11-99officerneedsassistance.wav" },
[ "Administrer" ] = { "npc/metropolice/vo/administer.wav" },
[ "Affirmatif" ] = { "npc/metropolice/vo/affirmative.wav" },
[ "10-2" ] = { "npc/metropolice/vo/affirmative.wav", "npc/metropolice/vo/copy.wav" },
[ "Circuler" ] = { "npc/metropolice/vo/allrightyoucango.wav" },
[ "Amputer" ] = { "npc/metropolice/vo/amputate.wav" },
[ "Anticitoyen" ] = { "npc/metropolice/vo/anticitizen.wav" },
[ "647e" ] = { "npc/metropolice/vo/anyonepickup647e.wav" },
[ "Bloquer" ] = { "npc/metropolice/vo/block.wav" },
[ "B-10" ] = { "npc/metropolice/vo/block.wav" },
[ "Insectes" ] = { "npc/metropolice/vo/bugs.wav" },
[ "10-70" ] = { "npc/metropolice/vo/bugs.wav" },
[ "Haha" ] = { "npc/metropolice/vo/chuckle.wav" },
[ "Citoyen" ] = { "npc/metropolice/vo/citizen.wav" },
[ "Citoyen contraint à conscription volontaire" ] = { "npc/metropolice/vo/citizensummoned.wav" },
[ "Sujet Décédé" ] = { "npc/metropolice/vo/classifyasdbthisblockready.wav" },
[ "Code 100" ] = { "npc/metropolice/vo/clearandcode100.wav" },
[ "Confirmation Data" ] = { "npc/metropolice/vo/confirmadw.wav" },
[ "Reçu" ] = { "npc/metropolice/vo/copy.wav" },
[ "Verdict Final" ] = { "npc/metropolice/vo/finalverdictadministered.wav" },
[ "Dernier Avertissement" ] = { "npc/metropolice/vo/finalwarning.wav" },
[ "Passif" ] = { "npc/metropolice/vo/ispassive.wav" },
[ "10-5" ] = { "npc/metropolice/vo/ispassive.wav" },
[ "Roi" ] = { "npc/metropolice/vo/king.wav" },
[ "404" ] = { "npc/metropolice/vo/possible404here.wav" },
[ "Jugement Civil" ] = { "npc/metropolice/vo/prepareforjudgement.wav" },
[ "Merde" ] = { "npc/metropolice/vo/shit.wav" },
[ "Steriliser" ] = { "npc/metropolice/vo/sterilize.wav" },
[ "505" ] = { "npc/metropolice/vo/subjectis505.wav" },
[ "Union" ] = { "npc/metropolice/vo/union.wav" },
[ "Tout est sociostable ici ?" ] = { "npc/metropolice/vo/wearesociostablethislocation.wav" },
[ "Documenter" ] = { "npc/metropolice/vo/document.wav" },
[ "Milice" ] = { "npc/combine_soldier/vo/overwatch.wav" }
}
hook.Add("PlayerSay", "ChatSoundsForCP", function(ply, text)
local prefix = string.sub(text, 0, 1)
if prefix == "/" or prefix == "!" or prefix == "@" then return end
if not ply:isCP() then return end
for k, v in pairs(sounds) do
local res1, res2 = string.find(string.lower(text), k)
if res1 and (not text[res1 - 1] or text[res1 - 1] == "" or text[res1 - 1] == " ") and (not text[res2 + 1] or text[res2 + 1] == "" or text[res2 + 1] == " ") then
ply:EmitSound(table.Random(v), 80, 100)
break
end
end
end)
[/code]
[editline]13th October 2015[/editline]
It worked yesterday but it's not working anymore, here's the new code :
[code]
local sounds = {
[ "Appliquer" ] = { "npc/metropolice/takedown.wav" },
[ "11-99" ] = { "npc/metropolice/vo npc/metropolice/vwo/11-99officerneedsassistance.wav" },
[ "Administrer" ] = { "npc/metropolice/vo/administer.wav" },
[ "Affirmatif" ] = { "npc/metropolice/vo/affirmative.wav" },
[ "10-2" ] = { "npc/metropolice/vo/affirmative.wav", "npc/metropolice/vo/copy.wav" },
[ "Circuler" ] = { "npc/metropolice/vo/allrightyoucango.wav" },
[ "Amputer" ] = { "npc/metropolice/vo/amputate.wav" },
[ "Anticitoyen" ] = { "npc/metropolice/vo/anticitizen.wav" },
[ "647e" ] = { "npc/metropolice/vo/anyonepickup647e.wav" },
[ "Bloquer" ] = { "npc/metropolice/vo/block.wav" },
[ "B-10" ] = { "npc/metropolice/vo/block.wav" },
[ "Insectes" ] = { "npc/metropolice/vo/bugs.wav" },
[ "10-70" ] = { "npc/metropolice/vo/bugs.wav" },
[ "Haha" ] = { "npc/metropolice/vo/chuckle.wav" },
[ "Citoyen" ] = { "npc/metropolice/vo/citizen.wav" },
[ "Citoyen contraint à conscription volontaire" ] = { "npc/metropolice/vo/citizensummoned.wav" },
[ "Sujet Décédé" ] = { "npc/metropolice/vo/classifyasdbthisblockready.wav" },
[ "Code 100" ] = { "npc/metropolice/vo/clearandcode100.wav" },
[ "Confirmation Data" ] = { "npc/metropolice/vo/confirmadw.wav" },
[ "Reçu" ] = { "npc/metropolice/vo/copy.wav" },
[ "Verdict Final" ] = { "npc/metropolice/vo/finalverdictadministered.wav" },
[ "Dernier Avertissement" ] = { "npc/metropolice/vo/finalwarning.wav" },
[ "Passif" ] = { "npc/metropolice/vo/ispassive.wav" },
[ "10-5" ] = { "npc/metropolice/vo/ispassive.wav" },
[ "Roi" ] = { "npc/metropolice/vo/king.wav" },
[ "404" ] = { "npc/metropolice/vo/possible404here.wav" },
[ "Jugement Civil" ] = { "npc/metropolice/vo/prepareforjudgement.wav" },
[ "Merde" ] = { "npc/metropolice/vo/shit.wav" },
[ "Steriliser" ] = { "npc/metropolice/vo/sterilize.wav" },
[ "505" ] = { "npc/metropolice/vo/subjectis505.wav" },
[ "Union" ] = { "npc/metropolice/vo/union.wav" },
[ "Tout est sociostable ici ?" ] = { "npc/metropolice/vo/wearesociostablethislocation.wav" },
[ "Documenter" ] = { "npc/metropolice/vo/document.wav" },
[ "Milice" ] = { "npc/combine_soldier/vo/overwatch.wav" }
}
hook.Add("PlayerSay", "ChatSoundsForCP", function(ply, text)
print("Test1")
local prefix = string.sub(text, 0, 1)
if prefix == "/" or prefix == "!" or prefix == "@" then return end
print("Test2")
if not ply:isCP() then return end
print("Test3")
for k, v in pairs(sounds) do
local res1, res2 = string.find(string.lower(text), k)
if res1 and (not text[res1 - 1] or text[res1 - 1] == "" or text[res1 - 1] == " ") and (not text[res2 + 1] or text[res2 + 1] == "" or text[res2 + 1] == " ") then
print("Test4")
ply:EmitSound(table.Random(v), 80, 100)
break
end
end
end)
[/code]
And the Test4 isn't showing up in th console
Try every command to see if its failing completely or it is just one command.
If it does fail with only one command, it may be the pattern search.
Mhmm maybe it's dumb but check your indexed sounds and verify you put "/" and not "\" in your path.
[QUOTE=Bric0vicH;48899904]Mhmm maybe it's dumb but check youi ndexed sounds verify and you put "/" and not "\" in your path.[/QUOTE]
I only find one error but I fix it, still not working.
[QUOTE]Try every command to see if its failing completely or it is just one command.
If it does fail with only one command, it may be the pattern search.[/QUOTE]
Only 647e, 404 and 505 are working
Yup.
Its the pattern searching
[editline]14th October 2015[/editline]
Wait.
No, its case sensitive.
On the sounds, change all the mayus to minus.
Example:
From "Union" to "union"
It lowers the input text (what player says in chat) but not that text
It's not working and I have tih error :
[code]
10/16/2015 18:19:13: Lua Error
[ERROR] gamemodes/darkrp/gamemode/modules/chatsounds.lua:51: ')' expected (to close '(' at line 43) near 'print'
1. unknown - gamemodes/darkrp/gamemode/modules/chatsounds.lua:0
[ERROR] gamemodes/darkrp/gamemode/modules/chatsounds.lua:51: ')' expected (to close '(' at line 43) near 'print'
1. unknown - gamemodes/darkrp/gamemode/modules/chatsounds.lua:0
[/code]
Theres an end before print("Test3")
Remove it
Try not to think of it as "it is not working" or "it is working".
Try to understand what is happening on each line.
How to install the script?
Sorry, you need to Log In to post a reply to this thread.