key to enter and exit building
#1

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 1170.6563,-1489.6108,22.7553))
        {
          SetPlayerPos(playerid, 2476.6519,-1668.5076,-1.9851);
        }
    }
    return 1;
}
Now , How do i make exit using "KEY_SECONDARY_ATTACK" key?
Reply
#2

The same way with different coordinates..?
Reply
#3

You mean switching the coordinates? like :
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 1170.6563,-1489.6108,22.7553))
        {
          SetPlayerPos(playerid, 2476.6519,-1668.5076,-1.9851);
        }
    }
    return 1;
}

   if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 2476.6519,-1668.5076,-1.9851))
        {
          SetPlayerPos(playerid, 1170.6563,-1489.6108,22.7553);
        }
    }
    return 1;
}
Reply
#4

Yes but a radius of one is TINY. You should make it 2 for outside and 10 for inside.
Reply
#5

I wouldn't go for 10 inside - Try 4~5'ish
Some interiors are bloody small
Reply
#6

It allows me to enter but it didnt allow me to exit o.o
Reply
#7

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(IsPlayerInRangeOfPoint(playerid, 2.0, 1170.6563,-1489.6108,22.7553))
        {
          SetPlayerPos(playerid, 2476.6519,-1668.5076,-1.9851);
        }
   
        if(IsPlayerInRangeOfPoint(playerid, 5.0, 2476.6519,-1668.5076,-1.9851))
        {
          SetPlayerPos(playerid, 1170.6563,-1489.6108,22.7553);
        }
    }
    return 1;
}
try it in the same if statement
Reply
#8

idk..it wont work still the same. Is there anyway to put my
pawn Code:
CMD:exit(playerid, params[])
command to OnPlayerKeyStateChange?
Reply
#9

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(IsPlayerInRangeOfPoint(playerid, 2.0, 1170.6563,-1489.6108,22.7553))
        {
          SetPlayerPos(playerid, 2476.6519,-1668.5076,-1.9851);
        }
        else if(IsPlayerInRangeOfPoint(playerid, 5.0, 2476.6519,-1668.5076,-1.9851))
        {
          SetPlayerPos(playerid, 1170.6563,-1489.6108,22.7553);
        }
    }
    return 1;
}
Reply
#10

Yeah - Pretty sure you just use

pawn Code:
cmd_exit;
and it treats it as if you'd typed it.

im still old fashioned and use strcmp lmao, but the same principle should still apply.
I use:

pawn Code:
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(newkeys == 16 || newkeys == 24)
        {
            OnPlayerCommandText(playerid, "/enter");
            return 1;
        }
    }
But if im not mistaken, you should be able to write it as
pawn Code:
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(newkeys == 16 || newkeys == 24)
        {
            cmd_exit;
            return 1;
        }
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)