Buttons/Keys Help
#1

Hello all,
I need help regarding this.They don't work..none of them.I want them to work like ENTER & EXIT for buildings..but they don't work.Help me please!
pawn Код:
if(newkeys == KEY_CROUCH){
    // ---------------- BANK --------------------------------------------//
    if(IsPlayerInRangeOfPoint(playerid, 5.0, -180.9258,1132.7721,19.7422)){
    SetPlayerPos(playerid, 319.6804,1852.7080,1613.3672);
    SetPlayerFacingAngle(playerid, 91.7607);
    }
    else if(IsPlayerInRangeOfPoint(playerid, 5.0, 319.6804,1852.7080,1613.3672)){
    SetPlayerPos(playerid, -180.9258,1132.7721,19.7422);
    SetPlayerFacingAngle(playerid, 94.2908);
    }
    // ---------------- Police ------------------------------------------//
    if(IsPlayerInRangeOfPoint(playerid, 5.0, 95.0559,1178.1721,18.6641)){
    SetPlayerPos(playerid, 254.2448,1459.5632,-8.3811);
    SetPlayerFacingAngle(playerid, 181.3984);
    }
    else if(IsPlayerInRangeOfPoint(playerid, 5.0, 254.2448,1459.5632,-8.3811)){
    SetPlayerPos(playerid, 95.0559,1178.1721,18.6641);
    SetPlayerFacingAngle(playerid, 20.6802);
    }
    // ------------------ DMV ------------------------------------------//
    if(IsPlayerInRangeOfPoint(playerid, 5.0, -144.9055,1079.3195,20.4922)){
    SetPlayerPos(playerid, 186.8596,1740.3788,4.7413);
    SetPlayerFacingAngle(playerid, 273.0641);
    }
    else if(IsPlayerInRangeOfPoint(playerid, 5.0, 186.8596,1740.3788,4.7413)){
    SetPlayerPos(playerid, -144.9055,1079.3195,20.4922);
    SetPlayerFacingAngle(playerid, 4.5817);
    }
    // --------------- Hospital ------------------------------------------//
    if(IsPlayerInRangeOfPoint(playerid, 5.0, -318.5496,1050.1066,20.3403)){
    SetPlayerPos(playerid, 1245.8932,324.6824,-11.7422);
    SetPlayerFacingAngle(playerid, 156.4026);
    }
    else if(IsPlayerInRangeOfPoint(playerid, 5.0, 1245.8932,324.6824,-11.7422)){
    SetPlayerPos(playerid, -318.5496,1050.1066,20.3403);
    SetPlayerFacingAngle(playerid, 6.9412);
    }
    }
Reply
#2

Change:
Код:
newkeys == KEY_CROUCH
to:

Код:
newkeys & KEY_CROUCH
Reply
#3

Quote:
Originally Posted by Brandon_More
Посмотреть сообщение
Change:
Код:
newkeys == KEY_CROUCH
to:

Код:
newkeys & KEY_CROUCH
Didn't work sorry...anyone else?
Reply
#4

The correct way to check for a key is what Brandon_More said.

Are you sure you're actually in range of those points? Also keep in mind that on foot the button is C but on vehicle the button is H/Caps Lock.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The correct way to check for a key is what Brandon_More said.

Are you sure you're actually in range of those points? Also keep in mind that on foot the button is C but on vehicle the button is H/Caps Lock.
I tested your words...and I AM in range of those points.
And I presses both C and H/Caps...in cars and foot both...any idea ?
Reply
#6

Can someone make me the script for this function?
Like "C" to enter a building...and leave the coords area which I'll fill myself...
Can anyone?
Reply
#7

"BUMP"
Reply
#8

Here is one for you,you can add whatever you want or modify it how you like:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys==KEY_CROUCH)//Player pressed C
	{
	    if(IsPlayerInRangeOfPoint(playerid, 3, ENTRANCE TO THE BUILDING))
	    {
	                SetPlayerVirtualWorld(playerid, SET VW);
			SetPlayerInterior(playerid, SET INTERIOR YOU WANT);
			SetPlayerPos(playerid, LOCATION OF THAT INTERIOR);
	    }
	    if(IsPlayerInRangeOfPoint(playerid, 3, LOCATION OF THE EXIT,INSIDE THE INTERIOR) && GetPlayerVirtualWorld(playerid)==VW WHICH WAS SET UP && GetPlayerInterior(playerid)==INTERIOR WHICH WAS SET UP)
	    {
	        SetPlayerVirtualWorld(playerid, SET THE DEFAULT VW);
	        SetPlayerInterior(playerid, SET DEFAULT INTERIOR);
	        SetPlayerPos(playerid, ENTRANCE TO THE BUILDING); // He will come to the place where he pressed C
	    }
	}
	return 1;
}
Reply
#9

Quote:
Originally Posted by Tagathron
Посмотреть сообщение
Here is one for you,you can add whatever you want or modify it how you like:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys==KEY_CROUCH)//Player pressed C
	{
	    if(IsPlayerInRangeOfPoint(playerid, 3, ENTRANCE TO THE BUILDING))
	    {
	                SetPlayerVirtualWorld(playerid, SET VW);
			SetPlayerInterior(playerid, SET INTERIOR YOU WANT);
			SetPlayerPos(playerid, LOCATION OF THAT INTERIOR);
	    }
	    if(IsPlayerInRangeOfPoint(playerid, 3, LOCATION OF THE EXIT,INSIDE THE INTERIOR) && GetPlayerVirtualWorld(playerid)==VW WHICH WAS SET UP && GetPlayerInterior(playerid)==INTERIOR WHICH WAS SET UP)
	    {
	        SetPlayerVirtualWorld(playerid, SET THE DEFAULT VW);
	        SetPlayerInterior(playerid, SET DEFAULT INTERIOR);
	        SetPlayerPos(playerid, ENTRANCE TO THE BUILDING); // He will come to the place where he pressed C
	    }
	}
	return 1;
}
BUMP...didn't work...
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The correct way to check for a key is what Brandon_More said.

Are you sure you're actually in range of those points? Also keep in mind that on foot the button is C but on vehicle the button is H/Caps Lock.
I just wanted to point out one small thing here that both ways are correct depending on what you are trying to achieve. It could be useful to just use 'newkeys == ??' if you only want that key pressed when no other keys are pressed this would be the way my point is both ways are correct what we have is choosing the correct method for circumstances of using the key.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)