SA-MP Forums Archive
GetPlayerKeys - released - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: GetPlayerKeys - released (/showthread.php?tid=431459)



GetPlayerKeys - released - Riddick94 - 18.04.2013

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.


Re: GetPlayerKeys - released - doreto - 18.04.2013

Detecting releasing a key


Re: GetPlayerKeys - released - Riddick94 - 18.04.2013

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


Re: GetPlayerKeys - released - Vince - 18.04.2013

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


Re: GetPlayerKeys - released - Riddick94 - 18.04.2013

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.


Re: GetPlayerKeys - released - Jay_ - 18.04.2013

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.


Re: GetPlayerKeys - released - Riddick94 - 18.04.2013

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.