Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Ksna on Aug 21, 2015, 03:20 PM

Title: Windows Key
Post by: Ksna on Aug 21, 2015, 03:20 PM
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.
Title: Re: Windows Key
Post by: . on Aug 21, 2015, 03:31 PM
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!
Title: Re: Windows Key
Post by: Ksna on Aug 21, 2015, 03:43 PM
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...
Title: Re: Windows Key
Post by: . on Aug 21, 2015, 04:18 PM
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.
Title: Re: Windows Key
Post by: soulshaker on Aug 21, 2015, 07:35 PM
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);
    }
}
Title: Re: Windows Key
Post by: Thijn on Aug 21, 2015, 07:35 PM
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.
Title: Re: Windows Key
Post by: . on Aug 21, 2015, 07:46 PM
Before anyone wonders this is what Thijn means:
if(key== WINL || WINR)
Title: Re: Windows Key
Post by: soulshaker on Aug 21, 2015, 07:53 PM
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? ._.
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fs11.postimg.org%2Fcqkzcrcgz%2FUntitled.png&hash=ed34e2415d1ffb5a76062af81262dffe8e57895a)

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fs13.postimg.org%2Freyv5t7br%2FUntitled1.png&hash=8b9b36de7848277327777b8b13c6ec070224072f)
Title: Re: Windows Key
Post by: KAKAN on Aug 22, 2015, 12:52 AM
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")
Title: Re: Windows Key
Post by: Thijn on Aug 22, 2015, 09:01 AM
Nope :P
You're testing if the command is wep, or the string we is true.
Title: Re: Windows Key
Post by: FinchDon on Aug 22, 2015, 02:29 PM
@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
Title: Re: Windows Key
Post by: soulshaker on Aug 22, 2015, 02:33 PM
So my code is in alien language? I just gave example how to do that
Title: Re: Windows Key
Post by: FinchDon on Aug 22, 2015, 02:36 PM
yea that was good i just say that i give with his system according to that i am not laughing at you fella :)
Title: Re: Windows Key
Post by: soulshaker on Aug 22, 2015, 02:43 PM
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" ) )
Title: Re: Windows Key
Post by: Ksna on Aug 22, 2015, 02:57 PM
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?
Title: Re: Windows Key
Post by: FinchDon on Aug 22, 2015, 03:04 PM
i don't know about it fella well Window Key was best which one i gave anyway as your choice
Title: Re: Windows Key
Post by: MatheuS on Aug 22, 2015, 03:51 PM
Here (http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx)
Title: Re: Windows Key
Post by: Thijn on Aug 22, 2015, 04:18 PM
I'm going to lock this topic.

No it isn't possible without BindKey. If you want to use the BindKey method there has been a post by soulshaker that works (read his last post, though).