key to enter and exit building -
[Headless] - 26.11.2011
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?
Re: key to enter and exit building -
MP2 - 26.11.2011
The same way with different coordinates..?
Re: key to enter and exit building -
[Headless] - 26.11.2011
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;
}
Re: key to enter and exit building -
MP2 - 26.11.2011
Yes but a radius of one is TINY. You should make it 2 for outside and 10 for inside.
Re: key to enter and exit building -
Rob_Maate - 26.11.2011
I wouldn't go for 10 inside - Try 4~5'ish
Some interiors are bloody small
Re: key to enter and exit building -
[Headless] - 26.11.2011
It allows me to enter but it didnt allow me to exit o.o
Re: key to enter and exit building -
Rob_Maate - 26.11.2011
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
Re: key to enter and exit building -
[Headless] - 26.11.2011
idk..it wont work still the same. Is there anyway to put my
pawn Code:
CMD:exit(playerid, params[])
command to OnPlayerKeyStateChange?
Re: key to enter and exit building -
KosmasRego - 26.11.2011
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;
}
Re: key to enter and exit building -
Rob_Maate - 26.11.2011
Yeah - Pretty sure you just use
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;
}
}