Help with some Codes

Posted By: CrYzZeR

Help with some Codes - 08/21/10 18:14

Hello guys I hope you can help me because im not so good at programming ( i`ll do my best wink )

I`ve created an Action, that works pretty well. When I go to an entity who had this Action, I go to him until 500 Quants press the Space key and a Panel appear. this works really good but now my problem:

I can`t get it how to disappear this Panel after Iam pressing any key. Can you help me?

Code is in the Spoiler

(Sry for my bad English wink )

Click to reveal..


bmap Angler_tga = <Angler.tga>;
sound Angler_snd = <Anglerspricht.wav>;


action Angler

{


// make sure that your player action includes this line of code: "player = null;" at its beginning

while (player == null) {wait (1);}

while (1)

{

if (vec_dist (player.x, my.x) < 500) // the player has come closer than 100 quants to the switch?

{

if (key_space == on) // the space button button was pressed?

{

while (key_space == on) {wait (1);} // wait until the button is released

// put your own code here
pan_create("bmap = Angler_tga; pos_x = 0; pos_y = 0; flags = overlay, visible;", 10); // layer = 10
snd_play (Angler_snd, 150, 0);

}
}

wait (1);

}

}


Posted By: 3run

Re: Help with some Codes - 08/21/10 18:25

I guess you need to use:
Quote:
ptr_remove(void* object);
Because the way you create the pan like this, in run-time can be deleted only this way (or only after turning engine off, as manual says). But I advice you not to create panel at run-time, but to create it at the beginning on your script, and make it invisible, so then you'll be able to toggle visibility on and off.
Posted By: Aku_Aku

Re: Help with some Codes - 08/21/10 18:49

If you want to hide the panel try this:

reset(Panel,SHOW);

This instruction doesn't remove the panel just hides that.
You can show it again, when it needs.

I propose modify your code:
Code:
bmap Angler_tga = <Angler.tga>;
sound Angler_snd = <Anglerspricht.wav>;


PANEL* pan_Angler; // <------- INSERT THIS LINE

.....

// ------ replace your code with this ------
// -----------------------------------------

pan_Angler=pan_create("bmap = Angler_tga; pos_x = 0; pos_y = 0; flags = overlay, visible;", 10); // layer = 10



So you can use the reset(Panel,SHOW); anytime.
Posted By: Arrovs

Re: Help with some Codes - 08/22/10 21:17

No No no.
This is c-script not lite-c.
/////============

Your code fix
//defineat start where your bmaps are.
panel* panelis;

panelis=pan_create("bmap = Angler_tga; pos_x = 0; pos_y = 0; flags = overlay, visible;", 10); // layer = 10

So next time to remove ir use:
pan_remove(panelis);//so it know which panel to delete or
panelis.visible=off;//if you want only switch it off.
© 2024 lite-C Forums