can't destroy element

Posts 1–9 of 9 · Page 1 of 1
can't destroy element
Hello guys.

I have a problem. I made little test mod to do something.
When you kill someone you got an icon at topright. It works.
After death Icon will destroyed. But it doesn't work.

_rank.gsc
[php]#include <...>

displayIcon()
{
self endon("disconnect");
self endon("death");

self waittill("killed_enemy");
self iPrintlnBold("^1Ta-da!");
pr8_icon = createIcon("rank_prestige8", 40, 40);
pr8_icon setPoint("CENTER", "TOPRIGHT", -50, 50);
pr8_icon.hideWhenInMenu = true;
pr8_icon.foreground = true;
}

destroyIcon()
{
self endon("disconnect");

for(;
{
self waittill("death");
self.pr8_icon destroyElem();
wait 1;
}
}

init()
{
<...>

precacheShader("white");
precacheShader("rank_prestige8");

<...>
}

<...>

onPlayerSpawned()
{
self endon("disconnect");

for(;
{
self waittill("spawned_player");
self thread displayIcon();
self thread destroyIcon();
}
}

<...>
[/php]

Sorry for lame english. I hope you understand me.
Code:
destroyIcon()
{
    self waittill("death");
    self.pr8_icon destroy();
}
Still not destroyed after death.

Someone can help me? I don't know why master131's solution didn't work. While creating this create-destroy-icon I took the example from Hide and Seek mod. It works there but not here.
Code:
destroyIcon() 
{ 
    self endon("disconnect"); 
     
    for(;;) 
    { 
        self waittill("death"); 
        pr8_icon destroy();
    } 
}
Quote Originally Posted by Shucker View Post
Code:
destroyIcon() 
{ 
    self endon("disconnect"); 
     
    for(;;) 
    { 
        self waittill("death"); 
        pr8_icon destroy();
    } 
}
Thx but I tried this and got an error "uninitialized pr8_icon".
This should work actually. Did you do this in the onPlayerSpawned():
Code:
self thread destroyIcon();


Quote Originally Posted by Talamaur View Post
Thx but I tried this and got an error "uninitialized pr8_icon".
[php]#include <...>

displayIcon()
{
self endon("disconnect");
self endon("death");

self waittill("killed_enemy");
self iPrintlnBold("^1Ta-da!");
pr8_icon = createIcon("rank_prestige8", 40, 40);
pr8_icon setPoint("CENTER", "TOPRIGHT", -50, 50);
pr8_icon.hideWhenInMenu = true;
pr8_icon.foreground = true;
self waittill("death");
pr8_icon destroy();
wait 1;
}

init()

{
<...>

precacheShader("white");
precacheShader("rank_prestige8");

<...>
}

<...>

onPlayerSpawned()
{
self endon("disconnect");

for(;
{
self waittill("spawned_player");
self thread displayIcon();
}
}

<...>

[/php]
Avoid doubleposting

/Merged
Thank you guys for your answers. I solved the problem yourself. Realy wierd for me.

[php]#include <...>

displayIcon()
{
self endon("disconnect");
self endon("death");

self waittill("killed_enemy");
self iPrintlnBold("^1Ta-da!");
self.pr8_icon = createIcon("rank_prestige8", 40, 40);
self.pr8_icon setPoint("CENTER", "TOPRIGHT", -50, 50);
self.pr8_icon.hideWhenInMenu = true;
self.pr8_icon.foreground = true;
}

destroyIcon()
{
self endon("disconnect");

self waittill("death");
if(isDefined(self.pr8_icon))
{
self.pr8_icon destroyElem();
}
}

init()
{
<...>

precacheShader("white");
precacheShader("rank_prestige8");

<...>
}

<...>

onPlayerSpawned()
{
self endon("disconnect");

for(;
{
self waittill("spawned_player");
self thread displayIcon();
self thread destroyIcon();
}
}

<...> [/php]

I missed "self" before "pr8_icon".
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us