Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: dEaN on Dec 07, 2015, 10:19 AM

Title: BINDKEY problam!
Post by: dEaN on Dec 07, 2015, 10:19 AM
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);
        }
}
Title: Re: BINDKEY problam!
Post by: EK.IceFlake on Dec 07, 2015, 12:01 PM
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
Title: Re: BINDKEY problam!
Post by: MacTavish on Dec 07, 2015, 02:12 PM
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);
        }
}
Title: Re: BINDKEY problam!
Post by: dEaN on Dec 07, 2015, 06:33 PM
thx kusangi try later!
Title: Re: BINDKEY problam!
Post by: dEaN on Dec 10, 2015, 05:34 PM
not worked!!
Title: Re: BINDKEY problam!
Post by: . on Dec 10, 2015, 05:48 PM
:poop:

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fwww.jamieglowacki.com%2Fwp-content%2Fuploads%2F2015%2F01%2FLYw4POpF.jpeg&hash=27243af65f7d0710c155572fc05cf5a26b6983c5)
Title: Re: BINDKEY problam!
Post by: Mashreq on Dec 11, 2015, 07:02 AM
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;
}
Title: Re: BINDKEY problam!
Post by: KAKAN on Dec 11, 2015, 08:22 AM
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
Title: Re: BINDKEY problam!
Post by: dEaN on Dec 11, 2015, 02:22 PM
-worked-