Alt + Tab -
Anthonyx3' - 28.11.2010
What would be the keys for alt and tab? I want to make a tabbed system, per say. And the only way to make this, to my knowledge is detecting both keys being pressed together, so anyone know the keys? Would be much appreciated xD
-Anthony
Re: Alt + Tab -
XoSarahMoX - 28.11.2010
https://sampwiki.blast.hk/wiki/GetPlayerKeys -Thanks to buzz for link
That is the wiki for the keys
![Cheesy](images/smilies/biggrin.png)
! Hopefully its what you wanted lol :P.
Re: Alt + Tab -
Anthonyx3' - 28.11.2010
If im correct alt is KEY_SECONDARY_ATTACK but i dont know what tab is :S
Re: Alt + Tab -
Cypog - 28.11.2010
The value depens on the player's setting.
There is no value for ALT or TAB key, cause a player can have set any key to an action in GTA (like crouching)
If a player presses a key, the value of the action is posted to the Callback, not the key's value.
Most of players have ALT for slow walking, but some may use other keys.
Re: Alt + Tab -
Fj0rtizFredde - 28.11.2010
Tab is KEY_ACTION (I think) and alt is KEY_WALK
Re: Alt + Tab -
cessil - 28.11.2010
when a player is paused OnPlayerUpdate isn't called hint hint.
Re: Alt + Tab -
Cypog - 28.11.2010
cessil, I don't know what your "hint" is doing here.
And Fj0rtizFredde, this is just the default value, please note that.
Re: Alt + Tab -
cessil - 28.11.2010
well OnPlayerUpdate is called ~40 times a second, if the player is alt+tabbed then it doesn't get called so if you had code under OnPlayerUpdate to set a variable to 30, and have a timer to decrease it every second, by the time it equals 0 30 seconds would have past.
Re: Alt + Tab -
Cypog - 28.11.2010
OnPlayerKeyStateChange!
Who mad this stupid example in wiki, this is ridiculous.
Anyway, if you want to check if a player is alt tabbing:
Forget it, it's impossible to make a good working solution with sa-mp.
Re: Alt + Tab -
Anthonyx3' - 28.11.2010
I have seen several servers with a perfect working alt tab check, for example underground roleplay. As soon as someone alt tabs, their name turns red and a 3dlabel goes on top of them saying alt tabbed
Re: Alt + Tab -
cessil - 28.11.2010
well if you actually read my post you'd understand how to make one
Re: Alt + Tab -
Anthonyx3' - 28.11.2010
Tbh, you lost me in your post. What i planning is to use OnPlayerKeyStateChange.
Re: Alt + Tab -
Retardedwolf - 28.11.2010
Quote:
Originally Posted by Anthonyx3'
Tbh, you lost me in your post. What i planning is to use OnPlayerKeyStateChange.
|
It won't be as accurate as UGRP's then.
Re: Alt + Tab -
cessil - 28.11.2010
well you can't detect it so easy that way.
pawn Код:
OnPlayerUpdate(playerid) SetPVarInt(playerid,"pause",30)
pawn Код:
public timerfunction(playerid)//run a 1 second timer to call this for each player
{
SetPVarInt(playerid,"pause",GetPVarInt(playerid,"pause")-1);
if(GetPVarInt(playerid,"pause") == 0)
{
printf("30 seconds has passed since %d has paused",playerid);
}
}
Re: Alt + Tab -
Cypog - 28.11.2010
What if somebody hasn't assigned alt? (He can ALT TAB and you won't see it)
What if somebody has asigned another key to slow walking? (He will be shown as ALT Tabber, although hes isn't)
IT IS NOT WORKING!
If you want to make an AFK detection, you can do it with OnPlayerUpdate, but not with checking keys.
Edit: Don't use pVars!
Re: Alt + Tab -
The_Moddler - 28.11.2010
Try this
https://sampforum.blast.hk/showthread.php?tid=186129
Re: Alt + Tab -
Hiddos - 28.11.2010
Quote:
Originally Posted by Cypog
What if somebody hasn't assigned alt? (He can ALT TAB and you won't see it)
What if somebody has asigned another key to slow walking? (He will be shown as ALT Tabber, although hes isn't)
IT IS NOT WORKING!
If you want to make an AFK detection, you can do it with OnPlayerUpdate, but not with checking keys.
Edit: Don't use pVars!
|
Why not? PVars aren't slow, they're just not as fast as normal variables, sure. But that's all.
pawn Код:
public OnPlayerUpdate(playerid)
{
SetPVarInt(playerid, "TC", GetTickCount());
return 1;
}
public OnGameModeInit()
{
SetTimer("CheckAFK", 1500, 1);
return 1;
}
forward CheckAFK();
public CheckAFK()
{
new tc = GetTickCount();
for(new i; i < MAX_PLAYERS; i++)
{
if(tc - GetPVarInt(playerid, "TC") >= 1500)
{
//Do stuff with the AFK user here
}
}
}
Re: Alt + Tab -
Cypog - 28.11.2010
Yes, but don't use GetTickCount for that, you can increment the variable in the timer.
fast and easy:
Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 30
new afk[MAX_PLAYERS];
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
SetTimer("AFKTimer", 1000, 1);
return 1;
}
forward AFKTimer();
public AFKTimer()
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
afk[i]++;
if (afk[i] % 30 == 0)
{
new msg[60];
format(msg, 59, "player %d is afk for %d seconds now!", i, afk[i]);
SendClientMessageToAll(0xFFFFFF00, msg);
}
}
}
}
public OnPlayerUpdate(playerid)
{
afk[playerid] = 0;
return 1;
}