GetPlayerKeys - released
#1

Is there any way to check, is key has been released by user? i.e

if(Keys & KEY_FIRE)
{

}

if(RELEASED(KEY_FIRE))
{

}

or something like that? I'm using GetPlayerKeys in timer ex.
Reply
#2

Detecting releasing a key
Reply
#3

Quote:
Originally Posted by doreto
Посмотреть сообщение
Did you read my post or thread title?
Reply
#4

That's exacly what you asked? Please elaborate on what you're trying to do.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
That's exacly what you asked? Please elaborate on what you're trying to do.
Can I check in my timer, with GetPlayerKeys function.. when I released each key? for example:

pawn Код:
if(holding/pressed(KEY_FIRE))
{
// do something
}

else if(released(KEY_FIRE))
{
// do something
}
I thought it was enough info in first post to understand, my mistake, sorry. Anyway, as we know GetPlayerKeys we're checking like:

pawn Код:
if(Keys & KEY_FIRE)
But we don't have oldkeys for GetPlayerKeys. That's why I'm stuck, or maybe I am an idiot and I don't know how to use GetPlayerKeys to check released key. If I am, then tell me, please.
Reply
#6

You're getting confused with GetPlayerKeys and OnPlayerKeyStateChange. GetPlayerKeys simply returns the current keys the player is pressing, whereas the OnPlayerKeyStateChange callback is called every time a player changes their key combination. It wouldn't make sense to include an oldkeys parameter in this function.

I don't know why you would favor GetPlayerKeys over OnPlayerKeyStateChange for this functionality. But nonetheless, you'd have to store their previous "oldkeys" attribute in variables which you can compare and retrieve when getting their new keys.
Reply
#7

Quote:
Originally Posted by Jay_
Посмотреть сообщение
You're getting confused with GetPlayerKeys and OnPlayerKeyStateChange. GetPlayerKeys simply returns the current keys the player is pressing, whereas the OnPlayerKeyStateChange callback is called every time a player changes their key combination. It wouldn't make sense to include an oldkeys parameter in this function.

I don't know why you would favor GetPlayerKeys over OnPlayerKeyStateChange for this functionality. But nonetheless, you'd have to store their previous "oldkeys" attribute in variables which you can compare and retrieve when getting their new keys.
Thanks for the idea, however I wanted to make it in KeyStateChange callback but, wondering.. from time to time I need someone whose gonna enlight me.. anyway, thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)