(PRESSED) PROBLEM!
#1

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! : )
Reply
#2

You can't 'switch' a function. You need to use if and else if.
Reply
#3

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
Reply
#4

use this
pawn Код:
if(PRESSED(KEY_HANDBRAKE))
after PRESSED you need to put the key.
Reply
#5

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;
}
Reply
#6

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)) <<
Reply
#7

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 : )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)