Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: longhackmc on Jul 07, 2017, 03:19 PM

Title: [Help] How to get any key?
Post by: longhackmc on Jul 07, 2017, 03:19 PM

I want to use BindKey(true, AnyKey, 0,0)
But I do not know how to get AnyKey
help me. I apologize for the poor english
Title: Re: [Help] How to get any key?
Post by: KAKAN on Jul 07, 2017, 04:48 PM
http://nehe.gamedev.net/article/msdn_virtualkey_codes/15009/
Title: Re: [Help] How to get any key?
Post by: longhackmc on Jul 07, 2017, 05:36 PM
Quote from: KAKAN on Jul 07, 2017, 04:48 PMhttp://nehe.gamedev.net/article/msdn_virtualkey_codes/15009/
Thanks but my idea is like "press any key to continue"
Title: Re: [Help] How to get any key?
Post by: KAKAN on Jul 08, 2017, 03:59 AM
there you go:
anykey <- array(100, false);
function onPlayerJoin( player ){
player.Msg( "Press any key to continue.");
anykey[ player.ID ] = true;
}

function onKeyDown( player, key ){
if( anykey[ player.ID ] ){
player.Msg( "YOU PRESSED 'ANY' KEY, SO SMD!" );
anykey[ player.ID ] = false; // or he'll keep getting the threatening messages.
}
Title: Re: [Help] How to get any key?
Post by: Anik on Jul 08, 2017, 06:23 AM
FFS stop posting in wrong boards.
Title: Re: [Help] How to get any key?
Post by: longhackmc on Jul 08, 2017, 06:38 AM
Quote from: Anik on Jul 08, 2017, 06:23 AMFFS stop posting in wrong boards.

Sorry for posting the wrong post but after finding the required function I will delete the post.
Is there any function similar to getch () in C ++?
Title: Re: [Help] How to get any key?
Post by: KAKAN on Jul 08, 2017, 07:12 AM
Quote from: longhackmc on Jul 08, 2017, 06:38 AM
Quote from: Anik on Jul 08, 2017, 06:23 AMFFS stop posting in wrong boards.

Sorry for posting the wrong post but after finding the required function I will delete the post.
Is there any function similar to getch () in C ++?
you wanted any key to continue. So, what, are you going to loop over all keys? I've provided a very easy example to follow, it's in squirrel. Look up. The topic's discussion ends here :)
Title: Re: [Help] How to get any key?
Post by: Thijn on Jul 09, 2017, 10:46 AM
I doubt that example will work. The onKeyDown event will probably (I didn't test) only be called for keys that were binded.

So no, unless you're going to bind to all keys (Which is a bad idea) this isn't possible.
Title: Re: [Help] How to get any key?
Post by: KAKAN on Jul 09, 2017, 12:14 PM
Quote from: Thijn on Jul 09, 2017, 10:46 AMI doubt that example will work. The onKeyDown event will probably (I didn't test) only be called for keys that were binded.
My antivirus wouldn't mark VCMP as a "KeyLogger" if it did what you said so.
Title: Re: [Help] How to get any key?
Post by: MEGAMIND on Jul 09, 2017, 12:30 PM
just founded this on google

worked for me
https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
Title: Re: [Help] How to get any key?
Post by: PunkNoodle on Jul 09, 2017, 02:27 PM
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Client_Events/KeyBind::OnUp

^ This is probably what you need.
Title: Re: [Help] How to get any key?
Post by: Thijn on Jul 11, 2017, 05:08 PM
Quote from: KAKAN on Jul 09, 2017, 12:14 PM
Quote from: Thijn on Jul 09, 2017, 10:46 AMI doubt that example will work. The onKeyDown event will probably (I didn't test) only be called for keys that were binded.
My antivirus wouldn't mark VCMP as a "KeyLogger" if it did what you said so.
Of course it would. There's a difference between logging it and calling an event.
Title: Re: [Help] How to get any key?
Post by: KAKAN on Jul 11, 2017, 05:38 PM
Quote from: Thijn on Jul 11, 2017, 05:08 PM
Quote from: KAKAN on Jul 09, 2017, 12:14 PM
Quote from: Thijn on Jul 09, 2017, 10:46 AMI doubt that example will work. The onKeyDown event will probably (I didn't test) only be called for keys that were binded.
My antivirus wouldn't mark VCMP as a "KeyLogger" if it did what you said so.
Of course it would. There's a difference between logging it and calling an event.
From my point of view, VCMP captures all the keybinds even if we have only one key to capture.
According to you, Discord( push-to-talk ) should be marked as a KeyLogger as well, but it isn't.
https://en.wikipedia.org/wiki/Keystroke_logging
KeyLogger means something else than just binding a single key.
Title: Re: [Help] How to get any key?
Post by: Thijn on Jul 11, 2017, 08:23 PM
Quote from: KAKAN on Jul 11, 2017, 05:38 PM
Quote from: Thijn on Jul 11, 2017, 05:08 PM
Quote from: KAKAN on Jul 09, 2017, 12:14 PM
Quote from: Thijn on Jul 09, 2017, 10:46 AMI doubt that example will work. The onKeyDown event will probably (I didn't test) only be called for keys that were binded.
My antivirus wouldn't mark VCMP as a "KeyLogger" if it did what you said so.
Of course it would. There's a difference between logging it and calling an event.
From my point of view, VCMP captures all the keybinds even if we have only one key to capture.
According to you, Discord( push-to-talk ) should be marked as a KeyLogger as well, but it isn't.
https://en.wikipedia.org/wiki/Keystroke_logging
KeyLogger means something else than just binding a single key.
Read my reply again. I'm not saying the client isn't listening for all keys, I'm saying the client will only send it's key statuses when it's binded to the server. Otherwise the bandwidth will be way too high.
Title: Re: [Help] How to get any key?
Post by: vito1 on Jul 11, 2017, 09:51 PM
There is no reason to use serverside keybinds since we have clientside one. So we can use bandwidth wisely.
Simple example:
vito_keys <- {
"as_array" : []
"by_id" : {},
"binds" : {}
};
vito_keys.as_array = [];
for(local i = 0; i < 300; i++){
vito_keys.as_array.push([i.tostring(), i]);
}
foreach(vito_key in ::vito_keys.as_array){
::vito_keys.by_id.rawset(vito_key[1], vito_key[0]);
};
foreach(vito_key in ::vito_keys.as_array){
::vito_keys.binds.rawset(vito_key[0],[KeyBind(vito_key[1]), vito_key[1], vito_key[0]]);
};
function KeyBind::OnDown(keybind) {
foreach(vito_keybind_key, vito_keybind in ::vito_keys.binds){
if(vito_keybind[0] == keybind){
::Console.Print("keydown key_id="+vito_keybind[1]+" key_name="+vito_keybind[2]);
}
}
}