Besoin d'aide restreindre le Chatsound (job)

  • Initiateur de la discussion
Blackghost9

Blackghost9

Geek suprême
Messages
211
Score réaction
55
Points
130
Bonjour, fan de metro police je me suis poser la question et j'ai vue que c'etait pas mal rechercher

Savez vous comment restreindre le "Chatsound" Sa veut dire les commandes "nice", "ok" , "ammo"
dans un job particulier ? Style marchand d'armes ou quoi pour leur donner des voix uniques (question d'améliorer le rp ?)

Bein je me le demande aussi et avec beaucoup de recherche j'ai trouver sa :

Je l'ai mis dans
"/srcds/garrysmod/lua/autorun" cela n'a pas fonctionner
j'ai donc décider de le mettre dans
"/srcds/garrysmod/addons/darkrpmodification/lua/darkrp_modules/restrict_chatsound"
pareil sa ne fonctionne pas

local soundscfg = {}
local function InitSoundTables() --Obligé pour init les jobs team après le chargement du gamemode
soundscfg = {
["/pc"] = { --La commande à taper pour émettre le son
sound = "vo/npc/male01/ammo03.wav", --Le son émis
allowedjobs = { --Les jobs autorisés à taper cette commande : [TEAM_NAME] = true,
[TEAM_PCB] = true,
}
},
["/nouveauson"] = {
sound = "vo/npc/male01/ammo02.wav",
allowedjobs = {
[TEAM_PCB] = true,
}
}
}
end
hook.Add("Initialize", "initsoundtables", InitSoundTables)
local function PlaySound(p, t)
for cmd, cfg in pairs(soundscfg) do
if t == cmd then
if !cfg.allowedjobs[p:Team()] then DarkRP.notify(p, 0, 5, "Mauvais métier !") return "" end
p:EmitSound(cfg.sound)
return ""
end
end
end
hook.Add("PlayerSay", "playsound", PlaySound)

(source : https://mtxserv.com/forums/threads/aide-pour-le-fichier-chatsounds-lua-half-life.37363/)

Du coup vous avez une idée car moi la solution ne fonctionne pas :/
je voudrais faire en sorte que les combines policiers peuvent faire ces commandes mais seulement eux :)

voici le chatsound de mon serveur
(il vien d'un copier coller d'un autre site dont je n'est plus la source)
"/srcds/garrysmod/gamemodes/darkrp/gamemode/modules"

-- Scripted by puregaming
-- This module will make voice sounds play when certain words are typed in the chat
-- You can add/remove sounds as you wish using DarkRP.setChatSound, just follow the format used here
-- To disable them completely, set GM.Config.chatsounds to false
-- TODO: Add female sounds & detect gender of model, and use combine sounds for CPs
-- DaCoolboy: I sorted the entries alphabetically for better overview
local sounds = {}
sounds[ "404" ] = { "npc/metropolice/vo/possible404here.wav" }
sounds[ "505" ] = { "npc/metropolice/vo/subjectis505.wav" }
sounds[ "citoyen" ] = { "npc/metropolice/vo/citizen.wav" }
sounds[ "code 100" ] = { "npc/metropolice/vo/code100.wav" }
sounds[ "recherche de suspect" ] = { "npc/metropolice/hiding02.wav" }
sounds[ "bloquer"] = { "npc/metropolice/vo/lock.wav" }
sounds[ "isolez" ] = { "npc/metropolice/vo/isolate.wav" }
sounds[ "appliquer" ] = { "npc/metropolice/takedown.wav" }
sounds[ "zone 404" ] = { "npc/metropolice/vo/404zone.wav" }
sounds[ "visuel" ] = { "npc/metropolice/vo/acquiringonvisual.wav" }
sounds[ "administrer" ] = { "npc/metropolice/vo/administer.wav" }
sounds[ "affirmative" ] = { "npc/metropolice/vo/affirmative.wav" }
sounds[ "Ghost patrouille aerienne 505" ] = { "npc/metropolice/vo/airwatchsubjectis505.wav" }
sounds[ "circulez" ] = { "npc/metropolice/vo/allrightyoucango.wav" }
sounds[ "tous sur le suspect" ] = { "npc/metropolice/vo/allun" }
sounds[ "allez au qg" ] = { "npc/metropolice/vo/allunitsmovein.wav" }
sounds[ "localisez le suspect" ] = { "npc/metropolice/vo/allunitsreportlocationsuspect.wav" }
sounds[ "amputez" ] = { "npc/metropolice/vo/amputate.wav" }
sounds[ "anti citoyen" ] = { "npc/metropolice/vo/anticitizen.wav" }
sounds[ "urgence code 2" ] = { "npc/metropolice/vo/allunitscode2.wav" }
sounds[ "34s dans" ] = { "npc/metropolice/vo/allunitsbol34sat.wav" }
sounds[ "anti citoyen libre" ] = { "npc/metropolice/vo/anyonepickup647e.wav" }
sounds[ "appliquer" ] = { "npc/metropolice/vo/apply.wav" }
sounds[ "pdc" ] = { "npc/metropolice/vo/atcheckpoint.wav" }
sounds[ "insectes" ] = { "npc/metropolice/vo/bugs.wav"}
sounds[ "insectes libre" ] = { "npc/metropolice/vo/bugsontheloose.wav" }
sounds[ "channel" ] = { "npc/metropolice/vo/canal.wav" }
sounds[ "bip" ] = { "npc/metropolice/vo/catchthatbliponstabilization.wav"}
sounds[ "haha" ] = { "npc/metropolice/vo/chuckle.wav" }
sounds[ "session usine" ] = { "npc/metropolice/vo/citizensummoned.wav" }
sounds[ "sujet deceder" ] = { "npc/metropolice/vo/classifyasdbthisblockready.wav" }
sounds[ "zone bloquer" ] = { "npc/metropolice/vo/condemnedzone.wav" }
sounds[ "confirmation dataincarne sur le suspect 10-0" ] = { "npc/metropolice/vo/confirmadw.wav" }
sounds[ "recu" ] = { "npc/metropolice/vo/copy.wav" }
sounds[ "unite defaillante" ] = { "npc/metropolice/vo/cpiscompromised.wav" }
sounds[ "position unite" ] = { "npc/metropolice/vo/cprequestsallunitsreportin.wav" }
sounds[ "intrusion criminelle" ] = { "npc/metropolice/vo/criminaltrespass63.wav" }
sounds[ "nombre de mort" ] = { "npc/metropolice/vo/dbcountis.wav" }
sounds[ "intrusion suspect" ] = { "npc/metropolice/vo/dispreportssuspectincursion.wav" }
sounds[ "documentez" ] = { "npc/metropolice/vo/document.wav" }
sounds[ "pas un geste" ] = { "npc/metropolice/vo/dontmove.wav" }
sounds[ "examine" ] = { "npc/metropolice/vo/examine.wav" }
sounds[ "verdict final" ] = { "npc/metropolice/vo/finalverdictadministered.wav" }
sounds[ "dernier avertisement" ] = { "npc/metropolice/vo/finalwarning.wav" }
sounds[ "premier avertisement" ] = { "npc/metropolice/vo/firstwarningmove.wav" }
sounds[ "necrotique libre" ] = { "npc/metropolice/vo/freenecrotics.wav" }
sounds[ "a terre" ] = { "npc/metropolice/vo/getdown.wav" }
sounds[ "complice ici" ] = { "npc/metropolice/vo/gotoneaccomplicehere.wav" }
sounds[ "hero" ] = { "npc/metropolice/vo/hero.wav" }
sounds[ "stop sa" ] = { "npc/metropolice/vo/holditrightthere.wav" }
sounds[ "injecte" ] = { "npc/metropolice/vo/inject.wav" }
sounds[ "dit circulez" ] = { "npc/metropolice/vo/Isaidmovealong.wav" }
sounds[ "passive" ] = { "npc/metropolice/vo/ispassive.wav" }
sounds[ "refus obtemperer" ] = { "vo/npc/male01/whoops01.wav" }
sounds[ "roi" ] = { "npc/metropolice/vo/king.wav" }
sounds[ "refus test loyauter" ] = { "npc/metropolice/vo/loyaltycheckfailure.wav" }
sounds[ "hostile" ] = { "npc/metropolice/vo/malignant.wav" }
sounds[ "recule maintenant" ] = { "npc/metropolice/vo/movebackrightnow.wav" }
sounds[ "avancez" ] = { "npc/metropolice/vo/moveit.wav" }
sounds[ "necrotique" ] = { "npc/metropolice/vo/necrotics.wav" }
sounds[ "aide pour celui la" ] = { "npc/metropolice/vo/needanyhelpwiththisone.wav" }
sounds[ "code 3 10-20" ] = { "npc/metropolice/vo/officerdowncode3tomy10-20.wav" }
sounds[ "patrouille" ] = { "npc/metropolice/vo/patrol.wav" }
sounds[ "ramasse cette boite" ] = { "npc/metropolice/vo/pickupthecan1.wav" }
sounds[ "jugement civil" ] = { "npc/metropolice/vo/prepareforjudgement.wav" }
sounds[ "rendez vous pdc" ] = { "npc/metropolice/vo/proceedtocheckpoints.wav" }
sounds[ "met sa dans la poubelle" ] = { "npc/metropolice/vo/putitinthetrash1.wav" }
sounds[ "zone interdite" ] = {"npc/metropolice/vo/restrictedblock.wav" }
sounds[ "deuxieme avertisement" ] = { "npc/metropolice/vo/secondwarning.wav" }
sounds[ "merde" ] = { "npc/metropolice/vo/shit.wav" }
sounds[ "test loyauter" ] = { "npc/metropolice/vo/standardloyaltycheck.wav" }
sounds[ "sterelisez" ] = { "npc/metropolice/vo/sterilize.wav" }
sounds[ "confirmation data" ] = { "npc/metropolice/vo/confirmadw.wav" }
sounds[ "union" ] = { "npc/metropolice/vo/union.wav" }
sounds[ "ta renverse ramase" ] = { "npc/metropolice/vo/youknockeditover.wav" }
sounds[ "affirmative" ] = { "npc/combine_soldier/vo/affirmative.wav" }
sounds[ "debut" ] = { "npc/combine_soldier/vo/engaging.wav" }
sounds[ "foncez foncez" ] = { "npc/combine_soldier/vo/gosharpgosharp.wav" }
sounds[ "milice" ] = { "npc/combine_soldier/vo/overwatch.wav" }
DarkRP.hookStub{
name = "canChatSound",
description = "Whether a chat sound can be played.",
parameters = {
{
name = "ply",
description = "The player who triggered the chat sound.",
type = "Player"
},
{
name = "chatPhrase",
description = "The chat sound phrase that has been detected.",
type = "string"
},
{
name = "chatText",
description = "The whole chat text the player sent that contains the chat sound phrase.",
type = "string"
}
},
returns = {
{
name = "canChatSound",
description = "False if the chat sound should not be played.",
type = "boolean"
}
}
}
DarkRP.hookStub{
name = "onChatSound",
description = "When a chat sound is played.",
parameters = {
{
name = "ply",
description = "The player who triggered the chat sound.",
type = "Player"
},
{
name = "chatPhrase",
description = "The chat sound phrase that was detected.",
type = "string"
},
{
name = "chatText",
description = "The whole chat text the player sent that contains the chat sound phrase.",
type = "string"
}
},
returns = {
}
}
local function CheckChat(ply, text)
if not GAMEMODE.Config.chatsounds or ply.nextSpeechSound and ply.nextSpeechSound > CurTime() then return end
local prefix = string.sub(text, 0, 1)
if prefix == "/" or prefix == "!" or prefix == "@" then return end -- should cover most chat commands for various mods/addons
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
local canChatSound = hook.Call("canChatSound", nil, ply, k, text)
if canChatSound == false then return end
ply:EmitSound(table.Random(v), 80, 100)
ply.nextSpeechSound = CurTime() + GAMEMODE.Config.chatsoundsdelay -- make sure they don't spam HAX HAX HAX, if the server owner so desires
hook.Call("onChatSound", nil, ply, k, text)
break
end
end
end
hook.Add("PostPlayerSay", "ChatSounds", CheckChat)
DarkRP.getChatSound = DarkRP.stub{
name = "getChatSound",
description = "Get a chat sound (play a noise when someone says something) associated with the given phrase.",
parameters = {
{
name = "text",
description = "The text that triggers the chat sound.",
type = "string",
optional = false
}
},
returns = {
{
name = "soundPaths",
description = "A table of string sound paths associated with the given text.",
type = "table"
}
},
metatable = DarkRP
}
function DarkRP.getChatSound(text)
return sounds[string.lower(text or "")]
end
DarkRP.setChatSound = DarkRP.stub{
name = "setChatSound",
description = "Set a chat sound (play a noise when someone says something)",
parameters = {
{
name = "text",
description = "The text that should trigger the sound.",
type = "string",
optional = false
},
{
name = "sounds",
description = "A table of string sound paths.",
type = "table",
optional = false
}
},
returns = {
},
metatable = DarkRP
}
function DarkRP.setChatSound(text, sndTable)
sounds[string.lower(text or "")] = sndTable
end

Voila merci pour vos réponses :)
 
Discord d'entraide
Rejoignz-nous sur Discord