Kenix Posted January 30, 2011 Share Posted January 30, 2011 problem with the definition of a player from any team. is a question of how to make that sound is played only once and stopped without timers? server side ------------------- sound events --------------------------------- ------------------- when zombies die ----------------------------- addEventHandler( "onPlayerWasted", getRootElement( ), function() if getElementType(player) == "player" then local team = getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam(player) if team and getTeamName(team) == "Zombies" then triggerClientEvent (source,"onzombiedie", source) end end end) ------------------- when the survivor died ----------------------- addEventHandler( "onPlayerWasted", getRootElement( ), function() if getElementType(player) == "player" then local team = getPlayerTeam" class="kw2">getPlayerTeam(player) if team and getTeamName(team) == "Survivors" then triggerClientEvent (source,"onsurvivorsdie", source) end end end) ------------------ when zombie killed survivor -------------------- function zombiekilling () if killer ~= nil and killer ~= false and getElementType(player) == "player" then local team = getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam(player) if team and getTeamName(team) == "Zombies" then triggerClientEvent (source,"onzombiekill", source) end end end ----------------- when the survivor has killed the zombie ------------------------ function survivorskilling () if killer ~= nil and killer ~= false and getElementType(player) == "player" then local team = getPlayerTeam" class="kw2">getPlayerTeam(player) if team and getTeamName(team) == "Survivors" then triggerClientEvent (source,"onSurvivorskill", source) end end end client side local x,y,z = getElementPosition() addEvent("onzombiedie",true) addEventHandler( "onzombiedie", getLocalPlayer(), function( ) zombiediesounds = playSound( "sounds/zombies/die" .. tostring( math.random( 1, 3 ) ) .. ".mp3", x,y,z, true ) setSoundVolume(zombiediesounds, 0.9) setSoundMaxDistance(zombiediesounds, 10) setTimer(function() stopSound( zombiediesounds ) end, 3000, 1) end) addEvent("onsurvivorsdie",true) addEventHandler( "onsurvivorsdie", getLocalPlayer(), function( ) survivordiesounds = playSound( "sounds/humans/dead" .. tostring( math.random( 1, 4 ) ) .. ".mp3", x,y,z, true ) setSoundVolume(survivordiesounds, 0.9) setSoundMaxDistance(survivordiesounds, 10) setTimer(function() stopSound( survivordiesounds ) end, 3000, 1) end) addEvent("onzombiekill",true) addEventHandler( "onzombiekill", getLocalPlayer(), function( ) zombiekillsounds = playSound( "sounds/zombies/attack" .. tostring( math.random( 1, 5 ) ) .. ".mp3", x,y,z, true ) setSoundVolume(zombiekillsounds, 0.9) setSoundMaxDistance(zombiekillsounds, 10) setTimer(function() stopSound( zombiekillsounds ) end, 3000, 1) end) addEvent("onsurvivorskill",true) addEventHandler( "onsurvivorskill", getLocalPlayer(), function( ) survivorkillsounds = playSound( "sounds/humans/attack" .. tostring( math.random( 1, 4 ) ) .. ".mp3", x,y,z, true ) setSoundVolume(survivorkillsounds, 0.9) setSoundMaxDistance(survivorkillsounds, 10) setTimer(function() stopSound( survivorkillsounds ) end, 3000, 1) end) Link to comment
Castillo Posted January 30, 2011 Share Posted January 30, 2011 last argument of playSound is to define if you want the sound to repeat, change it to false if you won't it to be repeated. Link to comment
Kenix Posted January 30, 2011 Author Share Posted January 30, 2011 last argument of playSound is to define if you want the sound to repeat, change it to false if you won't it to be repeated. Thanks but as if to fix server side? Link to comment
Kenix Posted February 1, 2011 Author Share Posted February 1, 2011 i fixing script thanks Solidsnake14 I've corrected the client side but still a problem when a player died of a team of survivors from the team sound zombies. server side ------------------- sound events --------------------------------- ------------------- when zombies die ----------------------------- addEventHandler( "onPlayerWasted", getRootElement( ), function() if getPlayerTeam" class="kw2">getPlayerTeam(player) ~= "Zombies" then return end triggerClientEvent (source,"onzombiedie", source) end) ------------------- when the survivor died ----------------------- addEventHandler( "onPlayerWasted", getRootElement( ), function() if getPlayerTeam" class="kw2">getPlayerTeam(player) ~= "Survivors" then return end triggerClientEvent (source,"onsurvivorsdie", source) end) ------------------ when zombie killed survivor -------------------- function zombiekilling () if (killer ~= nil and killer ~= false) then elseif getPlayerTeam" class="kw2">getPlayerTeam(player) ~= "Zombies" then return end triggerClientEvent (source,"onzombiekill", source) end ----------------- when the survivor has killed the zombie ------------------------ function survivorskilling () if (killer ~= nil and killer ~= false) then elseif getPlayerTeam" class="kw2">getPlayerTeam(player) ~= "Survivors" then return end triggerClientEvent (source,"onSurvivorskill", source) end Link to comment
Castillo Posted February 1, 2011 Share Posted February 1, 2011 I'm not sure of understand you, could you explain it better please? Link to comment
Kenix Posted February 2, 2011 Author Share Posted February 2, 2011 I'm not sure of understand you, could you explain it better please? I want him to check out what team he is killed or made a suicide Link to comment
MTA Team ccw Posted February 2, 2011 MTA Team Share Posted February 2, 2011 Exsqueeze me for butting in, but 'player' and 'killer' aren't defined anywhere Link to comment
Castillo Posted February 2, 2011 Share Posted February 2, 2011 ------------------- sound events --------------------------------- ------------------- when zombies die ----------------------------- addEventHandler( "onPlayerWasted", getRootElement( ), function() if getPlayerTeam(source) ~= "Zombies" then return end triggerClientEvent (source,"onzombiedie", source) end end) ------------------- when the survivor died ----------------------- addEventHandler( "onPlayerWasted", getRootElement( ), function() if getPlayerTeam(source) ~= "Survivors" then return end triggerClientEvent (source,"onsurvivorsdie", source) end) ------------------ when zombie killed survivor -------------------- function zombiekilling () if getPlayerTeam(source) ~= "Zombies" then return end triggerClientEvent (source,"onzombiekill", source) end ----------------- when the survivor has killed the zombie ------------------------ function survivorskilling () if getPlayerTeam(source) ~= "Survivors" then return end triggerClientEvent (source,"onSurvivorskill", source) end try that, i'm not sure if i did it right (i just wake up) Link to comment
Kenix Posted February 2, 2011 Author Share Posted February 2, 2011 (edited) you slept well there had to remove the end addEventHandler( "onPlayerWasted", getRootElement( ), function() if getPlayerTeam(source) ~= "Zombies" then return end triggerClientEvent (source,"onzombiedie", source) end) I did but it still does not work Edited February 2, 2011 by Guest Link to comment
Castillo Posted February 2, 2011 Share Posted February 2, 2011 You want to play a Sound when you die acording to your Team name? Link to comment
Castillo Posted February 2, 2011 Share Posted February 2, 2011 Ah! then you got it wrong, you gotta use getTeamName of course, ------------------- sound events --------------------------------- ------------------- when zombies die ----------------------------- addEventHandler( "onPlayerWasted", getRootElement( ), function() if getTeamName(getPlayerTeam(source))) ~= "Zombies" then return end triggerClientEvent (source,"onzombiedie", source) end end) ------------------- when the survivor died ----------------------- addEventHandler( "onPlayerWasted", getRootElement( ), function() if getTeamName(getPlayerTeam(source)) ~= "Survivors" then return end triggerClientEvent (source,"onsurvivorsdie", source) end) ------------------ when zombie killed survivor -------------------- function zombiekilling () if getTeamName(getPlayerTeam(source)) ~= "Zombies" then return end triggerClientEvent (source,"onzombiekill", source) end ----------------- when the survivor has killed the zombie ------------------------ function survivorskilling () if getTeamName(getPlayerTeam(source)) ~= "Survivors" then return end triggerClientEvent (source,"onSurvivorskill", source) end Link to comment
Kenix Posted February 2, 2011 Author Share Posted February 2, 2011 does not work still loses event zombie wasted I fixed a bug with ) and end ------------------- when zombies die ----------------------------- addEventHandler( "onPlayerWasted", getRootElement( ), function() if getTeamName(getPlayerTeam(source)) ~= "Zombies" then return end triggerClientEvent (source,"onzombiedie", source) end) Link to comment
Castillo Posted February 2, 2011 Share Posted February 2, 2011 this should work, ------------------- sound events --------------------------------- ------------------- when zombies die ----------------------------- addEventHandler( "onPlayerWasted", getRootElement( ), function() if getTeamName(getPlayerTeam(source)) == "Zombies" then triggerClientEvent (source,"onzombiedie", source) end end) ------------------- when the survivor died ----------------------- addEventHandler( "onPlayerWasted", getRootElement( ), function() if getTeamName(getPlayerTeam(source)) == "Survivors" then triggerClientEvent (source,"onsurvivorsdie", source) end end) ------------------ when zombie killed survivor -------------------- function zombiekilling () if getTeamName(getPlayerTeam(source)) == "Zombies" then triggerClientEvent (source,"onzombiekill", source) end end ----------------- when the survivor has killed the zombie ------------------------ function survivorskilling () if getTeamName(getPlayerTeam(source)) == "Survivors" then triggerClientEvent (source,"onSurvivorskill", source) end end i've done this little test to know what team you are in: addEventHandler( "onPlayerWasted", getRootElement( ), function() if getTeamName(getPlayerTeam(source)) == "Zombies" then outputChatBox("Team = Zombies") else outputChatBox("Team = ".. getTeamName(getPlayerTeam(source))) end end) Link to comment
Kenix Posted February 3, 2011 Author Share Posted February 3, 2011 So now works but works better in chatbox when a player dies from the team Survivors wrote zombies and loses 2 sounds simultaneously from different teams ... 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