Auto Gates on Car Beep *horn H*
#1

Код:
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
Reply
#2

im not sure if it is posible
Reply
#3

it is possible,i saw it on some server.
Reply
#4

Use OnPlayerKeyStateChange:

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply
#5

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

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

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);
Reply
#8

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);
Reply
#9

Код:
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
Reply
#10

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)