SA-MP Forums Archive
Hot to set up a sound for opening gate? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hot to set up a sound for opening gate? (/showthread.php?tid=448198)



Hot to set up a sound for opening gate? - gligorj - 03.07.2013

Hello i need a code for setting a sound when the gate is opening , thanks


Re: Hot to set up a sound for opening gate? - davve95 - 03.07.2013

I don't know exactly but I think this could work:

See how long it takes for the gate to open/close.

Then create a timer that starts when you open the gate that's long as the gate opening/closing time so you have same times.

https://sampwiki.blast.hk/wiki/PlayerPlaySound

https://sampwiki.blast.hk/wiki/SetTimer


Re: Hot to set up a sound for opening gate? - park4bmx - 03.07.2013

Or instead of a timer
https://sampwiki.blast.hk/wiki/OnObjectMoved


Re: Hot to set up a sound for opening gate? - davve95 - 03.07.2013

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
Moved

Won't the sound play after the gate is already moved then?, and it won't sync while the gate is moving with the sound?. Seems like that.


Re: Hot to set up a sound for opening gate? - Luis- - 03.07.2013

Would this not suffice?

https://sampwiki.blast.hk/wiki/IsObjectMoving


Re: Hot to set up a sound for opening gate? - davve95 - 03.07.2013

Quote:
Originally Posted by ******
Посмотреть сообщение
"instead of a timer" In your post you said to use a timer to detect the end of the movement of the gate and thus stop playing the sound, park4bmx was simply pointing out that that isn't needed.
Yeah, I see .

But wouldn't the sound come after (to late) if he use that function? (OnObjectMoved) .


And it won't in this?: https://sampwiki.blast.hk/wiki/IsObjectMoving

Because it can play when it's actually moving and the other one played the
sound when the other object already was moved?...

Sorry if I got it wrong...

But I thought like that I don't know if it's fully right....


Re: Hot to set up a sound for opening gate? - Zigonja - 03.07.2013

Okay, this is very easy, I've already found good sounds for you to move, just change coordinates and objects/names.

At the top
pawn Код:
new object;
new gatemoved;
OnFilterScriptInt
pawn Код:
gatemoved = 0;
    object = CreateObject(1518, 5, 5, 3, 0, 0, 0); //change this
The commandtext
pawn Код:
if (strcmp("/opengate", cmdtext, true, 10) == 0)
    {
        if(gatemoved == 0)
        {
            PlayerPlaySound(playerid, 1153, 5, 5, 3.0); //change coordinates here
            MoveObject(object, 1, 1, 3, 2); //change coordinates here
            gatemoved = 1;
        }
        else if(gatemoved == 1)
        {
            PlayerPlaySound(playerid, 1153, 5, 5, 3.0); //change coordinates here
            MoveObject(object, 5, 5, 3, 2); //change coordinates here
            gatemoved = 0;
        }
        return 1;
    }
And OnObjectMoved
pawn Код:
public OnObjectMoved(objectid)
{
    new playerid;
    PlayerPlaySound(playerid, 1154, 5, 5, 3.0); //change coordinates here
}