Sending player to spec
Posted: Sun Apr 19, 2009 9:38 pm
Is it possible and without giving to much away at beginning of this post how would I go about sending people to spec once they have reached their 60 kill limit for the map.
It's very hard to detect kills accurately. I managed to do this but I don't like to share this information unless you can tell me what you're trying to do with itsdlall wrote:Is it possible and without giving to much away at beginning of this post ....
Code: Select all
local.player spectatorCode: Select all
//=============================================
//
// KILLED and DEATH logic for multiplayer
//
// --------------------------------------------------
// How to access player kill and death count:
//
// The player variable: .killcount for kills
// The player variable: .deathcount for deaths
//
// Do not change any of the following player variables:
// - killcount
// - deathcount
// - detect
//
// --------------------------------------------------
// Use: Put this before waittill spawn in your mapscript
//
// exec global/killed_player.scr
//
// --------------------------------------------------
// This script unfortunately cannot detect if a player fell to his doom
// or if he has been killed by a script.
//
// =============================================
//
main:
level waittill spawn
thread mark_live
waitframe
thread kill_handler
end
/**************************
Mark Live Players
------------------
This thread marks all living players
with .status = "alive" and all dead/non-playing
players with .status = "notalive"
*/
mark_live:
while (1)
{
for (local.i = 1; local.i <= $player.size; local.i++)
{
if ( (isAlive $player[local.i]) && $player[local.i].dmteam != "spectator")
{
$player[local.i] weaponcommand dual targetname ("w" + $player[local.i].entnum)
local.weapon = $("w" + $player[local.i].entnum )
if(local.weapon != NULL)
{
local.weapon targetname ""
$player[local.i].status = "alive"
}
else
{
$player[local.i].status = "notalive"
}
}
else
{
$player[local.i].status = "notalive"
}
}
wait 0.1
}
end
kill_handler:
while(1)
{
if ($player.size > 0)
{
for (local.i = 1; local.i <= $player.size; local.i++)
{
if ($player[local.i].detect == NIL || $player[local.i].detect == NULL)
{
if ($player[local.i].status == "alive")
{
$player[local.i] waitthread setup_kill
}
}
}
}
wait 0.5
}
end
//Based on giffe's death detection
setup_kill:
if(self.detect != NIL && self.detect != NULL)
{
self.detect remove
}
self.detect = spawn trigger_multipleall "spawnflags" "128"
self.detect.origin = self.origin
self.detect.angle = self.angle
self.detect setthread killed
self.detect glue self
self.detect.player = self
self.detect.team = self.dmteam
self.detect.alive = 1
self.detect.attacker = NIL
self.detect setsize ( -17 -17 0 ) ( 17 17 92 )
end
killed:
//self waittill trigger //causes inaccuracy
local.murderer = parm.other
//check if player is still on the server or on the same team
if (self.player == NIL || self.player == NULL)
{
self remove
end
}
if ( self.alive == 0 || self.player.dmteam == "spectator")
{
end
}
//MAIN KILL-HANDLER
if ( isAlive self.player != 1 && self.alive == 1 )
{
self nottriggerable
self.alive = 0
self.attacker = local.murderer
waitframe
//benzin barrel
if (local.murderer == NULL)
{
if (self.player.deathcount == NIL)
self.player.deathcount = 0
self.player.deathcount++
end
}
//committed suicide or teamkill
if ( local.murderer == self.player || local.murderer.dmteam == self.player.dmteam )
{
if ( local.murderer.killcount == NIL )
{
local.murderer.killcount = 0
local.murderer.killcount--
}
else if ( local.murderer.killcount != NIL )
{
local.murderer.killcount--
}
}
//no traitor
else if ( local.murderer.dmteam != self.player.dmteam )
{
if ( local.murderer.killcount == NIL )
{
local.murderer.killcount = 0
local.murderer.killcount++
}
else if ( local.murderer.killcount != NIL )
{
local.murderer.killcount++
}
}
if (self.player.deathcount == NIL)
self.player.deathcount = 0
self.player.deathcount++
self immediateremove
}
endCode: Select all
spec_kick:
exec global/killed_player.scr //my script
level waittill spawn
while(1)
{
for (local.i = 1; local.i <= $player.size; local.i++)
{
if ($player[local.i].killcount != NIL && $player[local.i].dmteam != "spectator" && $player[local.i].killcount >= 60)
{
$player[local.i] iprint "You have killed enough players for this match!" 1
$player[local.i] spectator
wait 0.3
}
}
wait 1.5
}
end