SA-MP Forums Archive
Auto Gates on Car Beep *horn H* - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Auto Gates on Car Beep *horn H* (/showthread.php?tid=109601)



Auto Gates on Car Beep *horn H* - Naruto4 - 21.11.2009

Код:
public NearGatelv()
{
	for(new i=0; i<MAX_PLAYERS; i++) {
		if(IsPlayerConnected(i)) {
			if(PlayerToPoint(10.0, i, 2237.188965, 2448.813232, 9.845795) && HasPGP[i] == 1)
			{
	     	MoveObject(pdgateLV, 2237.127930, 2458.059570, 9.840160, 3.5);
			}else{
			 	MoveObject(pdgateLV, 2237.188965, 2448.813232, 9.845795, 3.5);
			}
		}
	}
}
i wanted to add when player beep with the car then it opens..And specific faction. HasPGP that is a script from someone i dont remember.
Anyway i tried using:
Код:
if(PlayPlayerSound...
but failed
help plz
thx


Re: Auto Gates on Car Beep *horn H* - [LCG]TANKER - 21.11.2009

im not sure if it is posible


Re: Auto Gates on Car Beep *horn H* - Naruto4 - 21.11.2009

it is possible,i saw it on some server.


Re: Auto Gates on Car Beep *horn H* - Rzzr - 21.11.2009

Use OnPlayerKeyStateChange:

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



Re: Auto Gates on Car Beep *horn H* - Naruto4 - 21.11.2009

Thanks mate.(working on it,i let you know if it works)

Do i add it under Public NearGatelv();
or under this:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)

it would be nice if some could make code for it.
VEHICLE_HORN
----------


Re: Auto Gates on Car Beep *horn H* - member - 21.11.2009

Quote:
Originally Posted by Naruto4
Thanks mate.(working on it,i let you know if it works)
Whilst you were working on it, i also was working on it before your post. Since i've made it, might as well post it.

pawn Код:
#define KEY_HORN 2

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (newkeys & KEY_HORN) // If the player is pressing the horn key.
    {
        if(PlayerToPoint(10.0, i, 2237.188965, 2448.813232, 9.845795) && HasPGP[i] == 1)
        {
          new sendername[24],string[128];
            GetPlayerName(playerid,sendername, sizeof(sendername));
            format(string, sizeof(string), "%s pushes a button in his pocket to open the HQ Gate.", sendername);
            SendClientMessageToAll(0x00E100FF, string);
            MoveObject(pdgateLV, 2237.127930, 2458.059570, 9.840160, 3.5); //open the gate
            SetTimer(CloseGate, 7000, 0);
        }
    }
    return 1;
}

forward CloseGate();
public CloseGate()
{
    MoveObject(pdgateLV, 2237.188965, 2448.813232, 9.845795, 3.5); // close the gate
    return 1;
}
Note: You will need to get rid of your "NearGatelv" timer, it's not needed seen as you are using the horn. Untested.


Re: Auto Gates on Car Beep *horn H* - Naruto4 - 21.11.2009

The code looks great... trying it now..
i got "i" as undefines simbol...
should i add that
Код:
i=0,i<MAX_PLAYERS .............
or something else
Код:
C:\Users\Mich\Desktop\LV Role Play\gamemodes\rp.pwn(26820) : error 017: undefined symbol "i"
C:\Users\Mich\Desktop\LV Role Play\gamemodes\rp.pwn(26827) : error 076: syntax error in the expression, or invalid function call
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
second error line is:
Код:
SetTimer(ClosePDGate1, 7000, 0);



Re: Auto Gates on Car Beep *horn H* - member - 21.11.2009

Oops, sorry change this line:

pawn Код:
if(PlayerToPoint(10.0, i, 2237.188965, 2448.813232, 9.845795) && HasPGP[i] == 1)
to this:
pawn Код:
if(PlayerToPoint(10.0, playerid, 2237.188965, 2448.813232, 9.845795) && HasPGP[i] == 1)
I used the PlayerToPoint from your looping timer. (was a bit lazy)

Oh, and change
pawn Код:
SetTimer(CloseGate, 7000, 0);
to
pawn Код:
SetTimer("CloseGate", 7000, 0);



Re: Auto Gates on Car Beep *horn H* - Naruto4 - 21.11.2009

Код:
C:\Users\Mich\Desktop\LV Role Play\gamemodes\rp.pwn(26827) : error 076: syntax error in the expression, or invalid function call
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
i invalid sintax on SetTimer
sorry for bothering you guys
i am very sorry


Re: Auto Gates on Car Beep *horn H* - member - 21.11.2009

Quote:
Originally Posted by Naruto4
Код:
C:\Users\Mich\Desktop\LV Role Play\gamemodes\rp.pwn(26827) : error 076: syntax error in the expression, or invalid function call
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
i invalid sintax on SetTimer
sorry for bothering you guys
i am very sorry
Quote:
Originally Posted by [B2K
Hustler ]
Oh, and change
pawn Код:
SetTimer(CloseGate, 7000, 0);
to
pawn Код:
SetTimer("CloseGate", 7000, 0);