Author Topic: Last guy standing script  (Read 919 times)

I'm not very good with scripting, so far all I can do is make a /help cmd.I just thought I should let you know. Anyways I need a script that notifies the players when there is only one man left on one of the two teams. An example would be like...

This Guy Killed That Guy.
(Name of the last guy) is the only one left on (Team name).

I would script this myself, but I really have no idea on how I would do it.
It would be nice if someone could explain it to me though.

you need to package the on death function, and check all players alive.
i am not going to give you the code, maybe 2morow i will, or someone else might

So it would basically be something like this.

Code: [Select]
package Test
{
function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)
{
parent::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc);
messageclient(%client,"","You died fool.");
}
};
activatepackage(Test);
Edit: I started to mess with the script some and this is what I have so far. It isn't much though.
Now I just needs to somehow recognize how many players are left on each team, and then once there's only one left it says the message.
« Last Edit: July 26, 2010, 02:39:33 PM by aml »


Loop through the minigame's members.
Check if they're on the same team as the one who died.
Count the number of them that are alive.

Loop through the minigame's members.
Check if they're on the same team as the one who died.
Count the number of them that are alive.
I know what to do its just I have no idea on how I would do it.

Then put it in suggestions and requests so someone else can do it.

this works, but if both teams have 1 player left, it will only grab 1 player

u can do in your package test

if(test() != 0)messageAll('',test().name@" is the only player left on the "@test().minigame.teamname[test().tdmteam]@" team!");

or something.

Code: [Select]
function test()
{
for(%i=0; %i<clientGroup.getCount(); %i++)
{
%client=clientGroup.getObject(%i);

if(%client.minigame == 0)
continue;

if(%client.player !$= "")
{
%teamone=%client.miningame.teamname[%client.tdmteam];
if(%client.minigame.teamname[%client.tdmteam] !$= %teamone)
{
%teamtwo=%client.minigame.teamname[%client.tdmteam];
break;
}
}
}



for(%i=0; %i<clientGroup.getCount(); %i++)
{
%client=clientGroup.getObject(%i);

if(%client.minigame == 0)
continue;

if(%client.minigame.teamname[%client.tdmteam] $= %teamone)
%teamonecount++;

if(%client.minigame.teamname[%client.tdmteam] $= %teamTwo)
%teamTwoCount++;
}

if(%teamOneCount==1)
{
for(%i=0; %i<clientGroup.getCount(); %i++)
{
%client=clientGroup.getObject(%i);

if(%client.minigame == 0)
continue;
if(%client.minigame.teamName[%client.tdmTeam] $= %teamone)
return %client;
}
}

if(%teamtwoCount==1)
{
for(%i=0; %i<clientGroup.getCount(); %i++)
{
%client=clientGroup.getObject(%i);

if(%client.minigame == 0)
continue;

if(%client.minigame.teamName[%client.tdmTeam] $= %teamTwo)
return %client;
}
}

return false;

}
« Last Edit: July 28, 2010, 06:19:03 PM by herb »

loveist script... Needs more Person.