Author Topic: playing a different sound when a player is killed depending on item used  (Read 1017 times)

apprently saveBricks is RTB only so..??

i need the function that will save bricks help


title? I have an explosive kunai, shurikens, and a katana. how could i make it so they play a sound, different from their regular swinging sounds, when someone is killed by them?
« Last Edit: November 26, 2014, 05:26:55 PM by Waru »

do you want this on the server side or client side

server-sided saving is a bit more involved; you'd have to find or make functionality to save on the server

Really the only way to do this is to remove the sound from the weapon datablock so that it doesn't play when you swing. Then, on projectile collision, play the sound from the source position of the projectile (the sword). Soooo..


function YourProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal) {
    %soundPosition = %obj.sourceObject.getPosition();
    %ret = parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
    if(!(%col.getType() & $TypeMasks::PlayerObjectType) || %col.getState() !$= "dead")
        %soundDB = YourNoKillSoundDatablock;
    else
        %soundDB = YourKillSoundDatablock;
    serverPlay3D(%soundDB, %soundPosition);
    return %ret;
}