BINDKEY problam!

Started by dEaN, Dec 07, 2015, 10:19 AM

Previous topic - Next topic

dEaN

hello every one  iam facing bindkey problam when i press f12 list show but when i f12 down list not hide why?
this code
function onKeyDown( player, bindid )
{
 if(bindid==STAFFLIST)
{
LIST <-CreateSprite( "LIST.png", 340, 40, 0, 0, 0, 255 );
LIST.ShowForPlayer(player);
}
}
function onKeyUp( player, bindid )
{
if(bindid==STAFFLIST)
{
LIST.HideFromPlayer(player);
        }
}
I think first impressions are important when i pick up a Main.nut script and I'm sticking to the script, I'm putting that organic feeling back in the game.
-Since 2012-

EK.IceFlake

well its a bit different you have to make 2 keys STAFFLISTDOWN and STAFFLISTUP.
there is a value true/false in bindkey, afaik do false for down and true for up

MacTavish

Because you are creating sprite again and again when you press key donno if this could be a reason

try
function onScriptLoad()
{
LIST <-CreateSprite( "LIST.png", 340, 40, 0, 0, 0, 255 ); // Creating sprite once will prevent creating multiple sprites on keypress
}
function onKeyDown( player, bindid )
{
 if(bindid==STAFFLIST)
{
LIST.ShowForPlayer(player);
}
}
function onKeyUp( player, bindid )
{
if(bindid==STAFFLIST)
 {
LIST.HideFromPlayer(player);
        }
}

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

dEaN

thx kusangi try later!
I think first impressions are important when i pick up a Main.nut script and I'm sticking to the script, I'm putting that organic feeling back in the game.
-Since 2012-

dEaN

I think first impressions are important when i pick up a Main.nut script and I'm sticking to the script, I'm putting that organic feeling back in the game.
-Since 2012-

.

.

Mashreq

You can avoid the issue of the multiple replace of the sprite by using arrays, here's an example:

function onScriptLoad()
{
stafflist <- array( GetMaxPlayers(), null );
STAFFLIST <- BindKey(true,0x7B,0,0);
}

function onPlayerJoin( player )
{
stafflist[ player.ID ] = CreateSprite( "LIST.png", 340, 40, 0, 0, 0, 255 );
}

function onKeyDown( player, key )
{
if( key == STAFFLIST )
{
stafflist[ player.ID ].ShowForPlayer( player );
}
}

function onKeyUp( player, key )
{
if( key == STAFFLIST )
{
stafflist[ player.ID ].HideFromPlayer( player );
}
}

function onPlayerPart( player, reason )
{
stafflist[ player.ID ] = null;
}

KAKAN

Quote from: dEaN on Dec 10, 2015, 05:34 PMnot worked!!
Probably, you don't has LIST.png in your sprites folder.
It's case sensitive.
If on your sprites folder it's "list.png" and in your createsprite thing it is "LIST.png" it won't work.

Tell us do you have the sprite?
The directory must be:-
<your vcmp server dir>\store\sprites
oh no

dEaN

I think first impressions are important when i pick up a Main.nut script and I'm sticking to the script, I'm putting that organic feeling back in the game.
-Since 2012-