Windows Key

Started by Ksna, Aug 21, 2015, 03:20 PM

Previous topic - Next topic

Ksna

Is there any function to check find if a player pressed windows key. so I can kick him from race.
I'm using bindkeys to make this but I want to know if there is any function to make my code simple.

.

#1
Yeah, use this code:

if (I_wasn_t_so_lazy)
{
    print("i d be a better programmer and stop asking useless questions");
}
else
{
    print("why bother with logic when I can type");
}

See? Simple!
.

Ksna

I mean how to know if a player goes afk by pressing windows key  I have seen this function  OnplayerStatechange but it crashes . I want to make it without bindkeys...

.

Well, you check the player position every 5-10 seconds. And if the last position is the same as a current one then that guy didn't move and he's AFK or camping. Give or take 0.01 ... (ish) when doing the calculation to account for any precision issues with floats. No need for keys.

You could also use OnPlayerGameKeysChange(...) and save the time-point of the last pressed registered game key. And if the last game key was pressed 5-10 seconds ago then the player is AFK. This method would allow camping unlike the above one.

Use that brain or you'll suffer the consequences.
.

soulshaker

Bindkey is just good

function onScriptLoad()
{
    WINL <- BindKey(true, 0x5B,0,0);
    WINR <- BindKey(true, 0x5C,0,0);
}

function onKeyDown(player,key)
{
    if(key== WINL || WINR)
    {
      KickPlayer(player);
    }
}

Thijn

Quote from: soulshaker on Aug 21, 2015, 07:35 PMBindkey is just good

function onScriptLoad()
{
    WINL <- BindKey(true, 0x5B,0,0);
    WINR <- BindKey(true, 0x5C,0,0);
}

function onKeyDown(player,key)
{
    if(key== WINL || WINR)
    {
      KickPlayer(player);
    }
}
Did you test that script? Because I can tell you didn't.

.

Before anyone wonders this is what Thijn means:
if(key== WINL || WINR)
.

soulshaker

Quote from: Thijn on Aug 21, 2015, 07:35 PMDid you test that script? Because I can tell you didn't.
How can you say so? ._.



KAKAN

Quote from: S.L.C on Aug 21, 2015, 07:46 PMBefore anyone wonders this is what Thijn means:
if(key== WINL || WINR)
Hmm i have used else if ( cmd =="This" || cmd == "we" )
So it will work in this syntax also right?
else if ( cmd == "wep" || "we")
oh no

Thijn

Nope :P
You're testing if the command is wep, or the string we is true.

FinchDon

@Ksna It is very easy i think because make a bind of window key like

if ( key == Window_your_bind )
{
if ( !race ) return 0;
else
{
KickPlayer( player );
Message( " " + player.Name + " has been kick reason : Press Window while in race " );
}
}

 See ? easy Lol @soulshaker
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

soulshaker

So my code is in alien language? I just gave example how to do that

FinchDon

yea that was good i just say that i give with his system according to that i am not laughing at you fella :)
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

soulshaker

Quote from: KAKAN on Aug 22, 2015, 12:52 AMHmm i have used else if ( cmd =="This" || cmd == "we" )
So it will work in this syntax also right?
else if ( cmd == "wep" || "we")
else if ( ( cmd == "wep" ) || ( cmd == "we" ) )

Ksna

#14
I should quote myself as you have not read this in my previous reply
Quote from: Ksna on Aug 21, 2015, 03:43 PMI want to make it without bindkeys...
SLC shown some ways anymore?