SA-MP Forums Archive
get time for a pressed key? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: get time for a pressed key? (/showthread.php?tid=229439)



get time for a pressed key? - MrIncredible - 21.02.2011

how can i get for how many secs a key is pressed?
does this have to do with gettickcount??


Re: get time for a pressed key? - MrIncredible - 21.02.2011

cmon, i need this noww


Re: get time for a pressed key? - Stigg - 21.02.2011

You could use something like this with some tweaking.

pawn Код:
IsKeyJustDown(key, newkeys, oldkeys)
{
    if((newkeys & key) && !(oldkeys & key)) return 1;
    return 0;
}
Peace...


Re: get time for a pressed key? - Marricio - 21.02.2011

Use timers and check when a key is released


Re: get time for a pressed key? - Hiddos - 21.02.2011

Save the result of GetTickCount() in a PVar when the player presses the key. When the play releases the key again, get the result of GetTickCount() again and subtract the value you saved in the PVar off of it.