Textdraw.delete() problem

Started by rulk, Sep 14, 2015, 04:15 PM

Previous topic - Next topic

rulk

Hya chaps,
I am new to textdraws and am having a problem deleting it once it has been created.

Here is my code....

function Draw( playerID )
{
local plr = FindPlayer( playerID );
if ( plr )
{
if( this[ "MyStopWatch" ][ playerID ].textdraw )
{
// Create the textdraw and display it to the player
test <- CreateTextdraw( "Time: " +  MyStopWatch[ playerID ].getElapsedTime( plr ), 480, 120, 0xFFFFAA00 );
test.ShowForPlayer( plr );
}
else
{
// Delete the textdraw   <--- this is being called but not deleting the textdraw...????
test.Delete();
}
}
}

I am sending a timer to call this function, and if the timer instance is found in 'this[ "MyStopWatch" ][ playerID ].textdraw',
it creates the textdraw. working perfect.

Once the timer instance is deleted, I want it to delete the textdraw.  Not working. ( the condition is being called, but its not deleting the textdraw)


what am i doing wrong ?

thanks,


rulk
We are all god's children.

.

#1
First thought:
        else
        {
            // Delete the textdraw.
            test.Delete(); /* 'test' IS NOT IN THIS SCOPE. SHOULD THROW: Error index 'test' doesn't exist! */
        }

Second thought... This whole approach doesn't even make sense :-\
.

rulk

Quote from: S.L.C on Sep 14, 2015, 04:21 PMFirst thought:
        else
        {
            // Delete the textdraw.
            test.Delete(); /* 'test' IS NOT IN THIS SCOPE. SHOULD THROW: Error index 'test' doesn't exist! */
        }

Second thought... This whole approach doesn't even make sense :-\

 I wish it did throw a error, but the console outputs nothing.  but are you saying create the textdraw before doing the conditioning ?
We are all god's children.

.

#3
Quote from: rulk on Sep 14, 2015, 04:30 PMI wish it did throw a error, but the console outputs nothing.  but are you saying create the textdraw before doing the conditioning ?

Never mind, I just realized you're using the instancing operator on the root table. The simplicity of the name got me confused. Choose a more unique name. Could be that it gets overwritten somewhere else.

I have no idea why are you using this here:
this[ "MyStopWatch" ][ playerID ].textdraw
And this bellow it:
MyStopWatch[ playerID ].getElapsedTime( plr )
It's quite confusing :-\ Either way, the whole thing is quite confusing. And there's bits of pieces missing to make any sense out of it.
.

rulk

Ok, sorry for getting your confused, I should have simplified it.

I've got it working now, the 'else' condition wasn't even being called, so I lied in my first post :-/

Fixed!

thank you for your help.
We are all god's children.