Hot to set up a sound for opening gate?
#1

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

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
Reply
#3

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

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.
Reply
#5

Would this not suffice?

https://sampwiki.blast.hk/wiki/IsObjectMoving
Reply
#6

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....
Reply
#7

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


Forum Jump:


Users browsing this thread: 1 Guest(s)