Kill streak

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Kill streak

Post by Moustache » May 15th, 2010, 3:09 pm

When a player kills 20 people in a row I want that they get a text on their screen.

I don't know how to let the script check if they have made a kill. How can I do that?

Maybe something like this?

Code: Select all

self.pers["killstreak"];
or this?

Code: Select all

self.pers["kill"];
But the above codes don't work.

User avatar
ConnoR
CJ Worshipper
CJ Worshipper
Posts: 465
Joined: January 2nd, 2010, 7:52 pm
Gamertag: conz0rz
Location: Nottingham, England
Contact:

Re: Kill streak

Post by ConnoR » May 15th, 2010, 5:15 pm

Im guessing for a mod you are working on?
Image

User avatar
Opel
CJ Fan
CJ Fan
Posts: 188
Joined: September 15th, 2008, 12:28 pm
Location: Scotland

Re: Kill streak

Post by Opel » May 15th, 2010, 6:06 pm

Try Something Like This Mabye.

Code: Select all



streak()
{
self notify("streak_function");
self endon("disconnect");
self endon("joined_spectators");
self endon("streak_function");


while(1)
{
wait 0.05;
			
		if(isDefined(self.cur_kill_streak))
		{			
		streak = self.cur_kill_streak;	
		switch(streak)
			{
			case 20:
                        self iprintlnbold("20 Killstreak");
                        break;
			}
		}
		
	}
}




Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Kill streak

Post by Moustache » May 16th, 2010, 10:59 am

ConnoR wrote:Im guessing for a mod you are working on?
I want to place this on a promod TDM server :)
You can add your own scripts in custom_ruleset.
liam wrote:Try Something Like This Mabye.

Code: Select all



streak()
{
self notify("streak_function");
self endon("disconnect");
self endon("joined_spectators");
self endon("streak_function");


while(1)
{
wait 0.05;

if(isDefined(self.cur_kill_streak))
{ 
streak = self.cur_kill_streak; 
switch(streak)
{
case 20:
self iprintlnbold("20 Killstreak");
break;
}
}

}
}



That doesn't work.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Kill streak

Post by Drofder2004 » May 16th, 2010, 12:26 pm

onplayerConnect()
{
for(;;)
{
level waittill("connected", player);
player thread onPlayerSpawned();
}
}

onPlayerSpawned()
{
for(;;)
{
self waittill("spawned_player");
self thread streak();
}
}

streak()
{
self endon("disconnect");
self endon("killed_player");
self endon("joined_spectators");

last = 0;

while(1)
{
if(last != self.cur_kill_streak)
{
switch(self.cur_kill_streak)
{
case 20;
iprintln( &"RANK_KILL_STREAK_N", self, 20);
break;
}

last = self.cur_kill_streak
}

wait 0.05;
}
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Kill streak

Post by Moustache » May 16th, 2010, 1:10 pm

That also doesn't work :?

Maybe promod doesn't support that function?

I was thinking about using something like this.
But this also doesn't work:

Code: Select all

setkills()
{
	self.killstreak = 0;

	for(;;)
	{
		self waittill("spawned_player");

		if ( self.killstreak == 3)
		{
			IPrintLnBold( "^23");
			IPrintLnBold( "kills treak");
		}

		else if( isPlayer( attacker ) )
		{
			self.killstreak++;
		}
		wait 0.05;
	}
}

User avatar
Opel
CJ Fan
CJ Fan
Posts: 188
Joined: September 15th, 2008, 12:28 pm
Location: Scotland

Re: Kill streak

Post by Opel » May 16th, 2010, 1:27 pm

yours wouldnt work as there is no self.killstreak. You would use self.cur_kill_streak as it is used in globalogic

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Kill streak

Post by Moustache » May 16th, 2010, 2:16 pm

liam wrote:yours wouldnt work as there is no self.killstreak. You would use self.cur_kill_streak as it is used in globalogic
I create the self.killstreak with this:

Code: Select all

self.killstreak = 0;
Or am I wrong?

User avatar
ConnoR
CJ Worshipper
CJ Worshipper
Posts: 465
Joined: January 2nd, 2010, 7:52 pm
Gamertag: conz0rz
Location: Nottingham, England
Contact:

Re: Kill streak

Post by ConnoR » May 16th, 2010, 6:25 pm

Promod TDM eh? Sounds interesting
Image

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Kill streak

Post by Moustache » May 16th, 2010, 6:31 pm

ConnoR wrote:Promod TDM eh? Sounds interesting
Explain :?:

User avatar
ConnoR
CJ Worshipper
CJ Worshipper
Posts: 465
Joined: January 2nd, 2010, 7:52 pm
Gamertag: conz0rz
Location: Nottingham, England
Contact:

Re: Kill streak

Post by ConnoR » May 16th, 2010, 6:46 pm

Its just i'd never heard of it before and it would be interesting too see the mod when its done
Image

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Kill streak

Post by Moustache » May 17th, 2010, 7:27 am

ConnoR wrote:Its just i'd never heard of it before and it would be interesting too see the mod when its done
:)

Then I need to know how the kills are defined. But I don't know that :|

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Kill streak

Post by Moustache » May 17th, 2010, 6:24 pm

Promod Fails with killstreaks :|

This code (Thanxs Drofder :mrgreen: ) works on other mods, but not on promod:

Code: Select all

onplayerConnect()
{
	for(;;)
	{
		level waittill("connected", player);
		player thread onPlayerSpawned();
	}
}

onPlayerSpawned()
{
	for(;;)
	{
		self waittill("spawned_player");
		self thread streak();

		IPrintLnBold( "^2Test KS" );
	}
}

streak()
{
	self endon("disconnect");
	self endon("killed_player");
	self endon("joined_spectators");

	last = 0;

	while(1)
	{
		if(last != self.cur_kill_streak)
		{
			switch(self.cur_kill_streak)
			{
				case 3:

				IPrintLnBold( "^13 ks" );

				iprintln( &"RANK_KILL_STREAK_N", self, 3);
				break;
			}
			last = self.cur_kill_streak;
		}
		wait 0.05;
	}
}
When someone spawn everyone gets this message: Test KS
But the rest fail :|
This is the script:

Code: Select all

onplayerConnect()
{
	for(;;)
	{
		level waittill("connected", player);
		player thread onPlayerSpawned();
	}
}

onPlayerSpawned()
{
	for(;;)
	{
		self waittill("spawned_player");
		self thread streak();

		IPrintLnBold( "^2Test KS" );
	}
}

streak()
{
	self.useLastStandParams = undefined;
		
	assert( isdefined( self.lastStandParams ) );
		
	attacker = self.lastStandParams.attacker;
				
	self.lastStandParams = undefined;

	self endon("disconnect");
	self endon("killed_player");
	self endon("joined_spectators");

	self.kills_in_a_row = 0;

	while(1)
	{
		if ( isPlayer( attacker ) )
		{
			self.kills_in_a_row++;
			IPrintLnBold( "^6KS +1" );
		}

		if ( self.kills_in_a_row >= 2 )
		{
			IPrintLnBold( "^22");
			IPrintLnBold( "kill treak");
		}
		wait 0.05;
	}
}

This part I copied from _globallogic.gsc:

Code: Select all

	self.useLastStandParams = undefined;
		
	assert( isdefined( self.lastStandParams ) );
		
	attacker = self.lastStandParams.attacker;
				
	self.lastStandParams = undefined;

User avatar
Opel
CJ Fan
CJ Fan
Posts: 188
Joined: September 15th, 2008, 12:28 pm
Location: Scotland

Re: Kill streak

Post by Opel » May 17th, 2010, 8:29 pm

Doesn't Promod disable killstreaks? So you would have to change something in its globallogic or something?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Kill streak

Post by Drofder2004 » May 17th, 2010, 10:25 pm

Try this.

Code: Select all

onPlayerSpawned()
{
	for(;;)
	{
		self waittill("spawned_player");
		self thread monitorKills();
	}
}

onPlayerConnect()
{
	for(;;)
	{
		level waittill("connected", player);
		player thread onPlayerSpawned();
	}
}

monitorKills()
{
	self endon("disconnect");
	self endon("killed_player");
	self endon("joined_spectators");
	
	streak = 0;
	before = self.kills;
	
	for(;;)
	{
		current = self.kills;
		while(current == self.kills)
			wait 0.05;
		
		streak = self.kills - before;
		
		if((streak % 5) == 0)
			iprintln( &"RANK_KILL_STREAK_N", self, streak);
	}
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests