Alt + Tab
#1

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
Reply
#2

https://sampwiki.blast.hk/wiki/GetPlayerKeys -Thanks to buzz for link

That is the wiki for the keys ! Hopefully its what you wanted lol :P.
Reply
#3

If im correct alt is KEY_SECONDARY_ATTACK but i dont know what tab is :S
Reply
#4

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.
Reply
#5

Tab is KEY_ACTION (I think) and alt is KEY_WALK
Reply
#6

when a player is paused OnPlayerUpdate isn't called hint hint.
Reply
#7

cessil, I don't know what your "hint" is doing here.


And Fj0rtizFredde, this is just the default value, please note that.
Reply
#8

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.
Reply
#9

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.
Reply
#10

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
Reply
#11

well if you actually read my post you'd understand how to make one
Reply
#12

Tbh, you lost me in your post. What i planning is to use OnPlayerKeyStateChange.
Reply
#13

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.
Reply
#14

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);
    }
}
Reply
#15

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!
Reply
#16

Try this

https://sampforum.blast.hk/showthread.php?tid=186129
Reply
#17

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
    }
  }
}
Reply
#18

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)