OnPlayerKeyStateChange -
zxc1 - 29.07.2011
I want to know why this code aint working. I tried to make it with KEY_CROUCH and KEY_JUMP but it's still not working.
Code:
if(newkeys & KEY_UP)
{
if (PlayerToPoint(4, playerid,2355.8599,224.8270,25.8024))
{
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, 2364.9453,225.0879,22.5551);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
}
else
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,2364.9453,225.0879,22.5551);
}
}
if (PlayerToPoint(4, playerid,1353.1167,450.1613,19.9677))
{
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, 1345.7319,435.9819,19.8277);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
}
else
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,1345.7319,435.9819,19.8277);
}
}
}
if(newkeys & KEY_UP)
{
if (PlayerToPoint(4, playerid,2364.9453,225.0879,22.5551))
{
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, 2355.8599,224.8270,25.8024);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
}
else
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,2355.8599,224.8270,25.8024);
}
}
if (PlayerToPoint(4, playerid,1345.7319,435.9819,19.8277))
{
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, 1353.1167,450.1613,19.9677);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
}
else
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,1353.1167,450.1613,19.9677);
}
}
}
return 1;
}
Re: OnPlayerKeyStateChange -
Rafa - 29.07.2011
there are no errors in pawn
Re: OnPlayerKeyStateChange -
zxc1 - 29.07.2011
No, but it's not working In-Game...
Re: OnPlayerKeyStateChange -
Rafa - 29.07.2011
pawn Code:
if(newkeys && KEY_UP)
{
if (PlayerToPoint(4, playerid,2355.8599,224.8270,25.8024))
{
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, 2364.9453,225.0879,22.5551);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
}
else
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,2364.9453,225.0879,22.5551);
}
}
if (PlayerToPoint(4, playerid,1353.1167,450.1613,19.9677))
{
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, 1345.7319,435.9819,19.8277);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
}
else
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,1345.7319,435.9819,19.8277);
}
}
}
if(newkeys && KEY_UP)
{
if (PlayerToPoint(4, playerid,2364.9453,225.0879,22.5551))
{
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, 2355.8599,224.8270,25.8024);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
}
else
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,2355.8599,224.8270,25.8024);
}
}
if (PlayerToPoint(4, playerid,1345.7319,435.9819,19.8277))
{
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, 1353.1167,450.1613,19.9677);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
}
else
{
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,1353.1167,450.1613,19.9677);
}
}
}
return 1;
}
try this untested...
Re: OnPlayerKeyStateChange -
zxc1 - 30.07.2011
I don't see any changes...
Re: OnPlayerKeyStateChange -
Famalamalam - 30.07.2011
"&&"
This is PAWN.
Re: OnPlayerKeyStateChange -
zxc1 - 30.07.2011
It's still not working.
Re: OnPlayerKeyStateChange -
zxc1 - 30.07.2011
Someone knows what the problem here?
Re: OnPlayerKeyStateChange -
zxc1 - 30.07.2011
Someone?
Re: OnPlayerKeyStateChange -
iPLEOMAX - 30.07.2011
Umm, try this:
Re: OnPlayerKeyStateChange -
MoroDan - 30.07.2011
No, no iPLEOMAX. You have to read a bit about Bitwise operations. Don't check like that, check like this:
PHP код:
if(newkeys & KEY_UP == (KEY_UP)) // to check if only KEY_UP is pressed
PHP код:
if(newkeys & KEY_UP) // to check if at least KEY_UP is pressed
Re: OnPlayerKeyStateChange -
iPLEOMAX - 30.07.2011
I knew i was doing something wrong. Thanks for explaining Moro.
Re: OnPlayerKeyStateChange -
Vince - 30.07.2011
Still, you're are all wrong. Movement keys never get detected with OnPlayerKeyStateChange. You will need a timer or OnPlayerUpdate to detect KEY_UP, KEY_DOWN, KEY_LEFT or KEY_RIGHT.
Re: OnPlayerKeyStateChange -
zxc1 - 30.07.2011
But when I used KEY_JUMP or KEY_CROUCH it's didn't work too...
So what I need to do?
Re: OnPlayerKeyStateChange -
zxc1 - 31.07.2011
Can someone help?
Re: OnPlayerKeyStateChange -
zxc1 - 31.07.2011
Smoeone?
Re: OnPlayerKeyStateChange -
iPLEOMAX - 31.07.2011
You should use debug methods.
pawn Код:
if(newkeys & KEY_CROUCH)
{
SendClientMessageToAll( -1, "Key Crouch works"); //debug line to check if key crouch is being pressed.
if (PlayerToPoint(4, playerid,2355.8599,224.8270,25.8024))
{
SendClientMessageToAll( -1, "Playertopoint works"); //debug line to check if player is close to the point.
if (GetPlayerState(playerid) == 2)
{
SendClientMessageToAll( -1, "State 2 - works."); //debug line to check working state..
These are examples, by adding message lines to your functions, you can determine whether it's being called or not..