fairyoggy Posted July 7, 2019 Share Posted July 7, 2019 Can I change or delete voice for ped? Each skin has its own voice or group skins have one voice. I dont know about it. I mean when you hit a player or pushed ped. He starts talking. There is a possibility? Link to comment
fairyoggy Posted July 7, 2019 Author Share Posted July 7, 2019 (edited) @Investor How to change a voice to a specific skin? function voice1(player) local model = getElementModel(player) if model == 99 then setPedVoice(player, "PED_TYPE_GANG", "VOICE_GNG_MACCER") return end so right? Edited July 7, 2019 by slapz0r Link to comment
HassoN Posted July 7, 2019 Share Posted July 7, 2019 32 minutes ago, slapz0r said: @Investor How to change a voice to a specific skin? function voice1(player) local model = getElementModel(player) if model == 99 then setPedVoice(player, "PED_TYPE_GANG", "VOICE_GNG_MACCER") return end so right? that will do only for one specific player, if you want all the players with this skin model use a loop like: for i, v in ipairs(getElementsByType("player")) do 1 Link to comment
Scripting Moderators ds1-e Posted July 8, 2019 Scripting Moderators Share Posted July 8, 2019 10 hours ago, HassoN said: that will do only for one specific player, if you want all the players with this skin model use a loop like: for i, v in ipairs(getElementsByType("player")) do @slapz0r If you're considered about performance. You should use int loop. local players = getElementsByType("player") for i = 1, #players do local player = players[i] -- do your stuff end Source: https://springrts.com/wiki/Lua_Performance 1 Link to comment
Zorgman Posted July 8, 2019 Share Posted July 8, 2019 @majqq is right, but I don't think a loop would be needed anyway. Just set the voice you want for each player when they spawn or when they change skin. 1 Link to comment
fairyoggy Posted July 8, 2019 Author Share Posted July 8, 2019 (edited) /solved Edited July 8, 2019 by slapz0r Link to comment
fairyoggy Posted July 8, 2019 Author Share Posted July 8, 2019 --client addEventHandler("onClientResourceStart", getResourceRootElement(), function() for i,v in pairs (getElementsByType("player")) do setPedVoice(v, "PED_TYPE_DISABLED", "nil") end end ) function refresz() for i,v in pairs (getElementsByType("player")) do setPedVoice(v, "PED_TYPE_DISABLED", "nil") end end addEvent( "refresz", true ) addEventHandler( "refresz", v, refresz ) --server local root = getRootElement() addEventHandler("onPlayerWasted", root, function () for i,v in pairs (getElementsByType("player")) do triggerClientEvent(v, "refresz", v) end end ) addEventHandler("onPlayerLogin", getRootElement(), function (_,account) for i,v in pairs (getElementsByType("player")) do triggerClientEvent(v, "refresz", v) end end ) Voices should not be but other players hear the local player(the one who keeps the server) How to make so that voices do not exist for all players? What needs to be changed in this code? Link to comment
HassoN Posted July 8, 2019 Share Posted July 8, 2019 This should do the trick. -- server addEventHandler("onPlayerSpawn", root, function() triggerClientEvent("sendOrder", source) end) -- client function removeSound() setPedVoice(source, "PED_TYPE_DISABLED", "nil") end addEvent("sendOrder", true) addEventHandler("sendOrder", root, removeSound) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now