Open door with a key or something like that
#1

hey,
ive got a door what i can open and close with command /door
but i wanna make it with a key or something thats easier to open it

Код:
	if(strcmp(cmd, "/door", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pMember] == 7)
			{
			    if(IsPlayerInRangeOfPoint(playerid, 3, 246.3489,72.0905,1003.6406))
			    {
			        new name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					if(IsPlayerConnected(playerid))
					{
					    if(IsLSPDDoorOpen == 0)
				    	{
				    		MoveObject(LSPD_Door[ObjectID1], 247.3080, 72.3000, 1003.6700, 1.50);
				    		MoveObject(LSPD_Door[ObjectID2], 245.480, 72.5750, 1003.6650, 1.50);
				    		MoveObject(LSPD_Door[ObjectID3], 247.888, 72.4500, 1003.7000, 1.50);
				    		MoveObject(LSPD_Door[ObjectID4], 244.908, 72.4500, 1003.7000, 1.50);
				    		IsLSPDDoorOpen = 1;
				    		format(string, sizeof(string), "* %s slides their card and opens the door", name);
				    		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
							return 1;
						}
						if(IsLSPDDoorOpen == 1)
				    	{
					    	MoveObject(LSPD_Door[ObjectID1], 246.4050, 72.3000, 1003.6700, 1.50);
				    		MoveObject(LSPD_Door[ObjectID2], 246.4050, 72.5750, 1003.6650, 1.50);
				    		MoveObject(LSPD_Door[ObjectID3], 246.9850, 72.4500, 1003.7000, 1.50);
				    		MoveObject(LSPD_Door[ObjectID4], 245.8330, 72.4500, 1003.7000, 1.50);
                            IsLSPDDoorOpen = 0;
                            format(string, sizeof(string), "* %s slides their card and closes the door", name);
				    		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                            return 1;
						}
					}
			    }
				if(IsPlayerInRangeOfPoint(playerid, 3, 222.09, 70.57, 1004.00))
			    {
			        if(IsPlayerConnected(playerid))
				    {
				    	if(DoorOpened==0)
						{
							MoveObject(door, 222.21, 72.27, 1004.00, 3);
							chiefdoortimer = SetTimer("ClosePDDoor",3000,0);
							DoorOpened = 1;
						}
						else if(DoorOpened==1)
						{
							MoveObject(door, 222.09, 70.57, 1004.00, 3);
							KillTimer(chiefdoortimer);
	  						DoorOpened = 0;
						}
					}
			    }
			}
	    }
	}
This is have
and ive i add this
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (PRESSED(KEY_FIRE))
	{
i get many errors ?
how to fix this ?
and ive you know that someone know if you typed /door or used the key its goes open ?
that you dont delete /door ?
i cant get it right lol everytime i get errors lol.
Reply
#2

TRy ^^

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
            OnPlayerCommandText(playerid, "/door");
         }
}
Reply
#3

Quote:
Originally Posted by Ricop522
Посмотреть сообщение
TRy ^^

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
            OnPlayerCommandText(playerid, "/door");
         }
}
no my pawn crash if i compile ?
Reply
#4

make it so that when you press the FIRE key a variable will change sorta like...
pawn Код:
new DoorKeyPressed[MAX_PLAYERS];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
            DoorKeyPressed[playerid] = 1;
    }
}
Reply
#5

Just transfer all the code inside the /door command to the OnPlayerKeyStateChange callback.
Reply
#6

Steven82's idea sounds more practical. It wouldn't make sense having to hold down the left mouse button while typing in a command.
Reply
#7

Quote:
Originally Posted by Steven82
Посмотреть сообщение
Just transfer all the code inside the /door command to the OnPlayerKeyStateChange callback.
but thats the problem too i get errors if i do that


here ive got this

Код:
/*line20707*/ public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (PRESSED(KEY_FIRE))
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pMember] == 7)
			{
			    if(IsPlayerInRangeOfPoint(playerid, 3, 246.3489,72.0905,1003.6406))
			    {
			        new name[MAX_PLAYER_NAME];
			        GetPlayerName(playerid, name, sizeof(name));
					if(IsPlayerConnected(playerid))
					{
					    if(IsLSPDDoorOpen == 0)
				    	{
				    		MoveObject(LSPD_Door[ObjectID1], 247.3080, 72.3000, 1003.6700, 1.50);
				    		MoveObject(LSPD_Door[ObjectID2], 245.480, 72.5750, 1003.6650, 1.50);
				    		MoveObject(LSPD_Door[ObjectID3], 247.888, 72.4500, 1003.7000, 1.50);
				    		MoveObject(LSPD_Door[ObjectID4], 244.908, 72.4500, 1003.7000, 1.50);
				    		IsLSPDDoorOpen = 1;
				    		format(string, sizeof(string), "* %s slides their card and opens the door", name);
				    		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
							return 1;
						}
						if(IsLSPDDoorOpen == 1)
				    	{
					    	MoveObject(LSPD_Door[ObjectID1], 246.4050, 72.3000, 1003.6700, 1.50);
				    		MoveObject(LSPD_Door[ObjectID2], 246.4050, 72.5750, 1003.6650, 1.50);
				    		MoveObject(LSPD_Door[ObjectID3], 246.9850, 72.4500, 1003.7000, 1.50);
				    		MoveObject(LSPD_Door[ObjectID4], 245.8330, 72.4500, 1003.7000, 1.50);
                            IsLSPDDoorOpen = 0;
                            format(string, sizeof(string), "* %s slides their card and closes the door", name);
				    		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                            return 1;
						}
					}
			    }
				if(IsPlayerInRangeOfPoint(playerid, 3, 222.09, 70.57, 1004.00))
			    {
			        if(IsPlayerConnected(playerid))
				    {
				    	if(DoorOpened==0)
						{
							MoveObject(door, 222.21, 72.27, 1004.00, 3);
							chiefdoortimer = SetTimer("ClosePDDoor",3000,0);
							DoorOpened = 1;
						}
						else if(DoorOpened==1)
						{
							MoveObject(door, 222.09, 70.57, 1004.00, 3);
							KillTimer(chiefdoortimer);
	  						DoorOpened = 0;
						}
					}
			    }
			}
	    }
	}
}
and i get this errors

Код:
C:\Users\Dennis\Downloads\Server\gamemodes\matrix2.pwn(20707) : error 029: invalid expression, assumed zero
C:\Users\Dennis\Downloads\Server\gamemodes\matrix2.pwn(20707) : error 017: undefined symbol "newkeys"
C:\Users\Dennis\Downloads\Server\gamemodes\matrix2.pwn(20709) : error 017: undefined symbol "newkeys"
Reply
#8

Well, What are the errors? And what lines are the errors on?
Reply
#9

and i have already

Код:
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
Reply
#10

Someone Knows the problem ?
Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)