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);
}
}
newkeys == KEY_CROUCH
newkeys & KEY_CROUCH
Change:
Код:
newkeys == KEY_CROUCH Код:
newkeys & KEY_CROUCH |
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. |
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; }
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; } |
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. |