Forum

> > CS2D > Scripts > Last Team Player Check and 1vs1 Check
Forums overviewCS2D overview Scripts overviewLog in to reply

English Last Team Player Check and 1vs1 Check

7 replies
To the start Previous 1 Next To the start

old Last Team Player Check and 1vs1 Check

Ferb Fletcher
User Off Offline

Quote
The script have inspired from original Counter-Strike where have last team player check before win the round and the script have player vs player check.

I have written this inspired script for CS2D and I have done this halfway but I have a trouble about 1vs1 scripting and better last player check.

I have done:
When the last player in team is alive before their will win the round, message "*Player* is the one and only" (red text if T, blue text if CT) will public shown, only last team player will heard "The one and only" sound.

Problems:
I have done 1 vs 1 scripting, when this round have 1 T and 1 CT alive, message will shown ID players instead player names and also message spam in console for 32 lines.
When the last player in team is alive, I have scripting problem about counting opposite team players.

Example I want:
When the last player is alive in team, the script will count all opposite team players alive, only last player in team will heard "The one and only" sound.
When all teammates are killed but only 1 T and 1 CT, will display message (and sound).

Quote
*Player* vs 7 CTs: All your teammates were killed. Good luck!
*Player* vs *Player2*


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
addhook("die","ferb.lastmancheckt")
addhook("die","ferb.lastmancheckct")
addhook("die","ferb.pvpcheck")
addhook("endround","ferb.lastmanstanding")

function ferb.lastmancheckt()
      if lastman==false and #player(0,"team1living")==1 then
          for id=1,32 do
               if player(id,"team")==1 and player(id,"health")>0 then
                    msg("ฉ255040040"..player(id,"name").." is the one and only@C")
                    parse("sv_sound2 "..id.." \"Random Sounds From Ferb Fletcher/oneandonly.ogg\"")
                    lastman=true
               end
           end
      end
end

function ferb.lastmancheckct()
      if lastman==false and #player(0,"team2living")==1 then
          for id=1,32 do
               if player(id,"team")==2 and player(id,"health")>0 then
                    msg("ฉ040040255"..player(id,"name").." is the one and only@C")
                    parse("sv_sound2 "..id.." \"Random Sounds From Ferb Fletcher/oneandonly.ogg\"")
                    lastman=true
               end
           end
      end
end

function ferb.pvpcheck()
     if #player(0,"team1living")==1 and #player(0,"team2living")==1 then
          for id=1,32 do
               msg("ฉ240240240"..player(0,"team1living")[1].." vs. "..player(0,"team2living")[1].."@C")
               pvpcheck=true
           end
      end
end

function ferb.lastmanstanding()
    lastman=false
    pvpcheck=false
end

old Re: Last Team Player Check and 1vs1 Check

Joni And Friends
User Off Offline

Quote
This you mean?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function checkalivepl()
playeralive={}
playeralive[1]=0
playeralive[2]=0
thelast={}
thelast[1]=0
thelast[2]=0
     for idd=1,32 do
         if player(idd,"exists") and player(idd,"health")>0 and player(idd,"team")==1 then
             playeralive[1]=playeralive[1]+1
             thelast[1]=idd
     end
          if player(idd,"exists") and player(idd,"health")>0 and player(idd,"team")==2 then
             playeralive[2]=playeralive[2]+1
             thelast[2]=idd
          end
  end
          if playeralive[1]==1 then
              msg(player(thelast[1],"name").." is the last player from Tero!@C")
            elseif playeralive[2]==1 then
              msg(player(thelast[2],"name").." is the last player from CT!@C")
        end
          if playeralive[1]==1 and playeralive[2]==1 then
              msg("[System] "..player(thelast[1],"name").." Vs "..player(thelast[2],"name"))
      end
end

addhook("die","_die")
function _die()
checkalivepl()
end
edited 2×, last 27.11.14 03:46:14 pm

old Re: Last Team Player Check and 1vs1 Check

Ajmin
User Off Offline

Quote
Also Note this:
Quote
player(0,"table"): a Lua table with all player IDs
player(0,"tableliving"): a Lua table with all living player IDs
player(0,"team1"): a Lua table with all terrorist IDs
player(0,"team2"): a Lua table with all counter-terrorist IDs
player(0,"team1living"): a Lua table with all living terrorist IDs
player(0,"team2living"): a Lua table with all living counter-terrorist IDs

old Re: Last Team Player Check and 1vs1 Check

Joni And Friends
User Off Offline

Quote
@user Ajmin: Yes, can using it on the script, and it will be like this
More >
edited 2×, last 27.12.14 11:29:51 am

old Re: Last Team Player Check and 1vs1 Check

VADemon
User Off Offline

Quote
Maybe the following code is a little bit easier to understand:
only 1v1 check, not tested >

Partially based on user Joni And Friends's ideas

old Re: Last Team Player Check and 1vs1 Check

MikuAuahDark
User Off Offline

Quote
This simple thing may help
1
2
3
4
5
6
7
8
9
10
local temp=player(0,"team1living")
if #temp==1 then
	local alive_id_t=temp[1]
	-- only 1 T are remaining
end
temp=player(0,"team2living")
if #temp==1 then
	local alive_id_ct=temp[1]
	-- only 1 CT are remaining
end

old Re: Last Team Player Check and 1vs1 Check

Ferb Fletcher
User Off Offline

Quote
Thanks, the script is stable now, unfortunately about counting all team players alive.

So, I just little tweaked the script and let see how is working.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
-----------------------
-- INITIAL SETUP     --
-----------------------
function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end

------------------------

if ferb==nil then ferb={} end
ferb={}

addhook("die","ferb.lastplayercheck")
function ferb.lastplayercheck()
	ferb.checkplayeralive()
end

addhook("endround","ferb.lastmanstanding")
function ferb.lastmanstanding()
    lastman=false
end

function ferb.checkplayeralive()
playeralive={}
playeralive[1]=0
playeralive[2]=0
thelast={}
thelast[1]=0
thelast[2]=0
     for idd=1,32 do
         if player(idd,"exists") and player(idd,"health")>0 and player(idd,"team")==1 then
             playeralive[1]=playeralive[1]+1
             thelast[1]=idd
     end
          if player(idd,"exists") and player(idd,"health")>0 and player(idd,"team")==2 then
             playeralive[2]=playeralive[2]+1
             thelast[2]=idd
          end
  end
          if lastman==false and playeralive[1]==1 then
              msg("ฉ255040040"..player(thelast[1],"name").." is the one and only@C")
	      parse("sv_sound2 "..thelast[1].." \"oneandonly.ogg\"")
              lastman=true
           elseif lastman==false and playeralive[2]==1 then
              msg("ฉ040040255"..player(thelast[2],"name").." is the one and only@C")
	      parse("sv_sound2 "..thelast[2].." \"oneandonly.ogg\"")
              lastman=true
        end
          if playeralive[1]==1 and playeralive[2]==1 then
	      msg("ฉ240240240"..player(thelast[1],"name").." vs. "..player(thelast[2],"name").."@C")
      end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview