Author Topic: Constant loop script?  (Read 1321 times)

I need a script for an item I am making that will constantly play a specified sound when the player clicks (fires) the "weapon" until A, the player equips the item again and clicks, or B, the player dies/leaves.

If you have more than one question you can post both of them in one thread.

To loop something you have to use a recursive function that calls itself via the schedule function. What this means is that you write a function that will be call itself every so often.

Code: [Select]
function playSoundAtThirtySeconds(%client)
{
    if(!isObject(%client) || !isObject(%client.player) || %client.player.getMountedImage(0) !$= MyWeaponImage || %client.player.doNotPlay)
        return;
    %client.play2d(MyAudioProfile);
    schedule(30 * 1000, 0, playSoundAtThirtySeconds, %client);
}

That script has everything I asked?

That script has everything I asked?

No.

This is not suggestions and requests. This is coding help. Key word: help. Not coding make this for me.

No.

This is not suggestions and requests. This is coding help. Key word: help. Not coding make this for me.
I need HELP with a script. Get out if you don't want to help.

Do you actually have experience with programming?

Do you actually have experience with programming?
Yes, but not good enough to make the script myself

I need HELP with a script. Get out if you don't want to help.
I don't get it. You are in coding help.. We won't do your work for you.



When the person shoots the gun, it uses WeaponImageName::OnFire(%this,%obj,%slot). Make sure you parent it. (Doesn't need to go into a package), so you can use it to loop your sound with a different function. (Unless it uses onFire when you press and hold the trigger)