I was trying to make a remote car like topfun missions but when i bindkey it works only once even if i hold and it moves when i press continuosly.
Can anyone give a idea how to make it move when i hold a key..
You can use this as an example:
http://forum.vc-mp.org/?topic=668.msg4292#msg4292
I have pasted your code as it is in a blank page . when i press h in game nothing happens.
This should give you an idea,
pKey <- BindKey( .. ) // Your key bind defined.
function onKeyDown( player, key )
{
if( key == pKey ) {
// Move the car for the player who pressed the key.
}
}
function onKeyUp( player, key )
{
if( key == pKey ) {
// Stop moving the car for player who has stopped pressing the key.
}
}
using this as is in a blank page
function onScriptLoad()
{
w <- BindKey(true,0x57,0,0); // Your key bind defined.
}
function onKeyDown( player, key )
{
if( key == w ) {
// Move the car for the player who pressed the key.
}
}
function onKeyUp( player, key )
{
if( key == w ) {
// Stop moving the car for player who has stopped pressing the key.
}
}
gives error at onkeydown , if( key == w)
Quote from: Ksna on Aug 08, 2015, 02:58 PMusing this as is in a blank page
function onScriptLoad()
{
w <- BindKey(true,0x57,0,0); // Your key bind defined.
}
function onKeyDown( player, key )
{
if( key == w ) {
// Move the car for the player who pressed the key.
}
}
function onKeyUp( player, key )
{
if( key == w ) {
// Stop moving the car for player who has stopped pressing the key.
}
}
gives error at onkeydown , if( key == w)
No it doesn't. Make sure you actually copy paste correctly. Also, if you do get an error why not post it...
I made a video because this needs it
https://youtu.be/lC_VnzBr93g
Once it worked and i got crashes when i pressed 'w'.
But it works on my script
Atleast put something between the brackets instead of just a comment. This code works fine:
function onScriptLoad()
{
w <- BindKey(true,0x57,0,0); // Your key bind defined.
}
function onKeyDown( player, key )
{
if( key == w ) {
// Move the car for the player who pressed the key.
print("moo");
}
}
function onKeyUp( player, key )
{
if( key == w ) {
// Stop moving the car for player who has stopped pressing the key.
print("boo");
}
}
Sorry for late reply , after a restart everything is working fine even the one which gave me an error. Why this happen?
when i paste this code as is http://forum.vc-mp.org/?topic=668.msg4292#msg4292 . this works randomly i mean sometime it works , sometimes it wont . Even if it is working when i press h it shows nothing.
The code works fine, so make sure you have all the latest plugins, server and client. Otherwise I wouldn't know what's wrong on your side, it works fine here.