Jump to content

script bad work


Kenix

Recommended Posts

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

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

  
------------------- 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

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 by Guest
Link to comment

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...