(PRESSED) PROBLEM! -
Youice - 18.05.2012
Hello,
I have created this code:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
switch(PRESSED)//ERROR HERE
{
case KEY_HANDBRAKE:
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, 245.10000610,72.30000305,1004.20001221))
{
if(PlayerInfo[playerid][pAdmin] >= SCRIPTER)
{
switch(Open{0})//Check whether the gate opened or closed
{
case true://If the gate opened
{
MoveObject(LSPDdoor, 2245.50000000,72.59999847,1002.59997559, 5);
Open{0} = false;
}
case false://If the gate closed
{
MoveObject(LSPDdoor, 244.00000000,72.59999847,1002.59997559, 5);
SetTimerEx("LSPDClose", 3500, false, "i", playerid);
Open{0} = true;
}
}
}
else return SendClientMessage(playerid, COLOR_GREY, "Access Denied");
}
}
}
and I defined this "PRESSED"
DEFINE:
Код:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
but why Im receiving this error?:
Код:
error 017: undefined symbol "PRESSED"
any explanation?
Thank you! : )
Re: (PRESSED) PROBLEM! -
SuperViper - 18.05.2012
You can't 'switch' a function. You need to use if and else if.
Re: (PRESSED) PROBLEM! -
Youice - 19.05.2012
Well I cant use " if " and " else if " because I used cases which I think if I used these functions it will make it more complicated. Thank you any way
Re: (PRESSED) PROBLEM! -
HDFord - 19.05.2012
use this
pawn Код:
if(PRESSED(KEY_HANDBRAKE))
after PRESSED you need to put the key.
Re: (PRESSED) PROBLEM! -
Finn - 19.05.2012
It won't make it any more complicated. Actually you have made your code very complicated by using cases way too much:
pawn Код:
switch(Open{0})//Check whether the gate opened or closed
{
case true://If the gate opened
{
MoveObject(LSPDdoor, 2245.50000000,72.59999847,1002.59997559, 5);
Open{0} = false;
}
case false://If the gate closed
{
MoveObject(LSPDdoor, 244.00000000,72.59999847,1002.59997559, 5);
SetTimerEx("LSPDClose", 3500, false, "i", playerid);
Open{0} = true;
}
}
pawn Код:
if(Open{0})//Check whether the gate opened or closed
{
MoveObject(LSPDdoor, 2245.50000000,72.59999847,1002.59997559, 5);
Open{0} = false;
}
else
{
MoveObject(LSPDdoor, 244.00000000,72.59999847,1002.59997559, 5);
SetTimerEx("LSPDClose", 3500, false, "i", playerid);
Open{0} = true;
}
Re: (PRESSED) PROBLEM! -
Youice - 19.05.2012
Quote:
Originally Posted by HDFord
use this
pawn Код:
if(PRESSED(KEY_HANDBRAKE))
after PRESSED you need to put the key.
|
okay, but I used "case" function so if I used "if" or "else if" the case will gets me errors
and Thank you for your info.
it worked by just adding this:
Код:
switch(PRESSED(KEY_HANDBRAKE)) <<
Re: (PRESSED) PROBLEM! -
Youice - 19.05.2012
Quote:
Originally Posted by Finn
It won't make it any more complicated. Actually you have made your code very complicated by using cases way too much:
pawn Код:
switch(Open{0})//Check whether the gate opened or closed { case true://If the gate opened { MoveObject(LSPDdoor, 2245.50000000,72.59999847,1002.59997559, 5); Open{0} = false; } case false://If the gate closed { MoveObject(LSPDdoor, 244.00000000,72.59999847,1002.59997559, 5); SetTimerEx("LSPDClose", 3500, false, "i", playerid); Open{0} = true; } }
pawn Код:
if(Open{0})//Check whether the gate opened or closed { MoveObject(LSPDdoor, 2245.50000000,72.59999847,1002.59997559, 5); Open{0} = false; } else { MoveObject(LSPDdoor, 244.00000000,72.59999847,1002.59997559, 5); SetTimerEx("LSPDClose", 3500, false, "i", playerid); Open{0} = true; }
|
and thank you but mine is easier in my opinion : )