Tren Posted September 13, 2011 Share Posted September 13, 2011 I have problem:script does not work and there is no debug errors and no sound Client: function grenadekill(killerWeapon) if (killerWeapon == 16) then local sound = playSound("Perfect.mp3") setSoundVolume(sound, 1) end end addEventHandler("onClientPlayerWasted", getLocalPlayer(), grenadekill) Server: function grenadekill(killerWeapon) if (killerWeapon == 16) then local sound = playSound("Perfect.mp3") setSoundVolume(sound, 1) end end addEventHandler("OnPlayerWasted", resourceRoot , grenadekill) Script must play sound when anyone kill anyone with grenade For example: PLayer1 ,..Perfect!(sound for all players) PLayer2 kills PLayer1 with grenade Anyone help?Im newbie in scripting.Fix the small code,please Link to comment
Kenix Posted September 13, 2011 Share Posted September 13, 2011 You need play sound for all players if player die ? If yes use this: function grenadekill(killer,killerWeapon,body) if (killerWeapon == 16) then local sound = playSound("Perfect.mp3") setSoundVolume(sound, 1) end end addEventHandler("onClientPlayerWasted", root, grenadekill) if you need play sound for local player use this function grenadekill(killer,killerWeapon,body) if (killerWeapon == 16) then local sound = playSound("Perfect.mp3") setSoundVolume(sound, 1) end end addEventHandler("onClientPlayerWasted", getLocalPlayer(), grenadekill) and remember function playSound not working in server side events. Link to comment
Tren Posted September 14, 2011 Author Share Posted September 14, 2011 You need play sound for all players if player die ?If yes use this: function grenadekill(killer,killerWeapon,body) if (killerWeapon == 16) then local sound = playSound("Perfect.mp3") setSoundVolume(sound, 1) end end addEventHandler("onClientPlayerWasted", root, grenadekill) if you need play sound for local player use this function grenadekill(killer,killerWeapon,body) if (killerWeapon == 16) then local sound = playSound("Perfect.mp3") setSoundVolume(sound, 1) end end addEventHandler("onClientPlayerWasted", getLocalPlayer(), grenadekill) and remember function playSound not working in server side events. thx,but how is server-side? script doesn't work , no sounds.(and no debug errors) Now i have files: client.lua perfect.mp3 meta.xml I need help Link to comment
E-mail Posted September 14, 2011 Share Posted September 14, 2011 Try This function grenadekill ( killer, weapon, bodypart ) if ( weapon == 16 ) then --if the weapon used was the grenade local sound = playSound("Perfect.mp3") setSoundVolume(sound, 0.5) -- set the sound volume to 50% end addEventHandler("onClientPlayerWasted",getLocalPlayer(),grenadekill) and meta.xml "youName" type="script" version="1.0" /> Link to comment
Castillo Posted September 14, 2011 Share Posted September 14, 2011 You have a missing 'end'. function grenadekill ( killer, weapon, bodypart ) if ( weapon == 16 ) then --if the weapon used was the grenade local sound = playSound("Perfect.mp3") setSoundVolume(sound, 0.5) -- set the sound volume to 50% end end addEventHandler("onClientPlayerWasted",getLocalPlayer(),grenadekill) Link to comment
Benevolence Posted September 14, 2011 Share Posted September 14, 2011 You have a missing 'end'. I really hate it when people correct a script but they add their own little mistake. Sometimes I think it's on purpose Link to comment
Kenix Posted September 16, 2011 Share Posted September 16, 2011 thx,but how is server-side? script doesn't work , no sounds.(and no debug errors) You can't play sounds in server side . But you can create trigger to client side and play sound. Link to comment
Headshot4Fun Posted September 16, 2011 Share Posted September 16, 2011 This should work, happens in serverside and trigger all the players ( play the sound for everybody ) Server function player_Wasted ( ammo, attacker, weapon, bodypart ) if not attacker == source then -- If it is not a suicide then if ( weapon == 16 ) -- and if the weapon is 16 ( granede ) triggerClientEvent ( getRootElement(), "perfect", getRootElement()) -- Trigger this to every client. end end end Client addEvent("perfect",true) -- Creates the event handler function perfect() -- Play for everybody local sound = playSound("Perfect.mp3") setSoundVolume(sound, 0.5) end addEventHandler("perfect",getRootElement(),perfect) -- Triggers this event handler This should work, else, post /debugscript 3 Edit now with notes so you can understand better what the hell is happening 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