Increasing a var while holding a 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: Increasing a var while holding a key (
/showthread.php?tid=257362)
Increasing a var while holding a key -
BloodyEric - 25.05.2011
Hey,
I am failing for hours now while trying to increase a variable as long as a player holds down a key.
My current (not working) code:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys&4) //CTRL
{
new i=SetTimerEx("LongJumpAngle",50,1,"i",playerid); //TIMER INCREASING THE VARIABLE
SetPVarInt(playerid,"Minigame2t",i);
print("2");
}
else if(oldkeys&4 && newkeys!=4) //Player releases key...I guess
{
KillTimer(GetPVarInt(playerid,"Minigame2t"));
}
}
Any help?
Re: Increasing a var while holding a key -
WackoX - 25.05.2011
You cannot detect when a player is "Holding" a key.
Re: Increasing a var while holding a key -
BloodyEric - 25.05.2011
But I can detect when a player releases a key and can stop increasing the var then, can't I?
Re: Increasing a var while holding a key -
kurta999 - 25.05.2011
Try this:
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Or GetPlayerKeys in timer.
Re: Increasing a var while holding a key -
BloodyEric - 25.05.2011
I dont unterstand the "holding" part there, as the define only works in OnPlayerKeyStateChange and not with GetPlayerKeys for example.
Re: Increasing a var while holding a key -
BloodyEric - 25.05.2011
Thank you all, it works now...I cant say what exactly I changed but anyway, it works so - thank you