Need help with replacing "F" key with /enter and /exit
#2

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
      if(newkeys & KEY_SECONDARY_ATTACK) // Enter / F key
      {
               if( lastPickup[playerid] != -1 || properties[lastPickup[playerid]][eType] > 0 ){
            new
                id = propPickups[lastPickup[playerid]],
                Float:x,
                Float:y,
                Float:z;

            GetPropertyEntrance( id, x, y, z );
            if( IsPlayerInRangeOfPoint( playerid, 3.0, x, y, z )){
                PutPlayerInProperty( playerid, id );
                SendClientMessage( playerid, 0x0BBF6AA, "[ PROPERTY: You have entered a property, type /exit to leave. ]");
                return 1;
            }
           else if( currentInt[playerid] > -1 && GetPlayerInterior(playerid) == GetPropertyInteriorId( currentInt[playerid] )){

            new id2 = currentInt[playerid];
            new Float:x2;
            new Float:y2;
            new Float:z2;
            new Float:a;

            // make sure they're near the exit before allowing them to exit.
            GetPropertyExit( id, x2, y2, z2 );
            if(!IsPlayerInRangeOfPoint(playerid,4.5,x2,y2,z2)) {
                SendClientMessage(playerid,0xFF0000AA, "[ ERROR: You must be near the property's entrance in order to use /exit ]");
                return 1;
            }

            a = GetPropertyEntrance( id2, x2, y2, z2 );
            SetPlayerPos( playerid, x2, y2, z2 );
            SetPlayerFacingAngle( playerid, a );
            SetPlayerInterior( playerid, 0 );
            SetPlayerVirtualWorld( playerid, 0 );
        }
        currentInt[playerid] = -1;
        return 1;
           }
      return 1;
}
Key state changes, and else if is your friend.
Reply


Messages In This Thread
Need help with replacing "F" key with /enter and /exit - by Sc0pion - 14.03.2015, 17:17
Re: Need help with replacing "F" key with /enter and /exit - by Abagail - 14.03.2015, 17:19
Re: Need help with replacing "F" key with /enter and /exit - by Sc0pion - 14.03.2015, 18:04
Re: Need help with replacing "F" key with /enter and /exit - by Abagail - 14.03.2015, 18:06
Re: Need help with replacing "F" key with /enter and /exit - by Sc0pion - 14.03.2015, 18:21

Forum Jump:


Users browsing this thread: 1 Guest(s)