Forums Index >> Modding >> Ondrop, or similar?



Page : <1> :


I need a function that is tt compatible. I need it to do something when the scrum is dropped. I dont know if there is an ondrop function, but I need something similar.

Friday, February 18, 2005 at 5:59:47 PM

Or if anyone knows a way to make the scrum stay on the tank until death, that would work. :)

Friday, February 18, 2005 at 9:06:14 PM

Each tank has a getFlag() function that tells you if it has a flag or not. I suppose you could check that periodically to see if it changes. Not the best solution, but might work.

 

 

 

 

Friday, February 18, 2005 at 10:40:57 PM

*the other part of the function here

%flag = %this.getflag();
if(%flag $= 0)
{
%client.tank.setdatablock(lighttank);
%tank.setprojectile(lightprojectile);
*rest of function here*

Like that?

BTW, how do you get the code box? It would be usefull for stuff like this...

Saturday, February 19, 2005 at 1:34:46 PM

Well, that depends what %this is in that function... If it's the player, then it will work.

The flag will return -1 if there is no flag. If there is a flag it will return the flag's ID number so it will be 6289 or some such.

 

                                        
%flag = %client.player.getflag();
if (%flag == -1) // <-- this means that the player does not have flag
{
%client.player.setdatablock(lighttank);
%tank.setprojectile(lightprojectile);
// * more function here*
}
if (%flag != -1) // <-- this means that the player has flag
{
// * more function here*
}

 

PS: Try "pre" in []'s for a code block.

 

 

 

 

Last edited: Saturday, February 19, 2005 at 2:56:23 PM

Saturday, February 19, 2005 at 2:55:41 PM


 

                                        
if (%flag == -1)

 

Haha, that was my problem, I had

 

                                        
if(%flag $= -1)

 

Thanks 56k. :)

Last edited: Saturday, February 19, 2005 at 5:27:57 PM

Saturday, February 19, 2005 at 5:26:52 PM

I made a way to have an ondrop feature, it will be universal and not for a flag type (not like FlagData::OnDrop)
It will also only work if just one flag is on the field

 

                                        
$Lastplayerwithflag = -1;
Function checkfordrops()
{
%count = clientgroup.getCount();
for ( %i = 0; %i < %count; %i++ )
{
%client = ClientGroup.getObject(%i);
%flag = %client.player.getflag();
if (%flag == -1 && isObject(%client.player))
{
if(%client == $LastPlayerWithFlag)
{
OnDrop(%client,%client.player);
}
}
if (%flag != -1 && isObject(%client.player))
{
$LastPlayerWithFlag = %client;
}
}
%count2 = botclientgroup.getCount();
for ( %a = 0; %i < %count2; %a++ )
{
%client = BotClientGroup.getObject(%a);
%flag = %client.player.getflag();
if (%flag == -1 && isObject(%client.player))
{
if(%client == $LastPlayerWithFlag)
{
OnDrop(%client,%client.player);
}
}
if (%flag != -1 && isObject(%client.player))
{
$LastPlayerWithFlag = %client;
}
}
schedule(100,false,"checkfordrops",4,4);
}
checkfordrops();
Function OnDrop(%client,%tank)
{
//code here!
}

 

BTW: When the player has the flag, does %flag have the flag datablock the player has (like DefaultFlag)?

PS: I just noticed that on [ pre ] only the first line is not upper cased, can you fix this?


Last edited: Wednesday, February 23, 2005 at 7:19:29 AM

Tuesday, February 22, 2005 at 1:06:31 PM

Page : <1> :

insert quote insert url insert email insert image bold italic underline superscript subscript horizontal rule : : Help on using forum codes

Add comment:

HTML is disabled within comments, but ZBB Code is enabled.

Back to the top

Web site designed, maintained and funded by -z- and Dan MacDonald