English Last Team Player Check and 1vs1 Check

7 replies
Goto Page
To the start Previous 1 Next To the start
Up
Ferb Fletcher
User
Offline Off
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*


Code:
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
USGN ID #100000
27.11.14 02:17:31 pm
Up
Raaj Nadar
User
Offline Off
There was a thread were a person asked for a last man standing script.

Try to search with that name.
Or else if i get on pc i will post here.
27.11.14 03:27:55 pm
Up
Joni And Friends
User
Offline Off
This you mean?
Code:
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
Web | file File does not exist (15501) | file File does not exist (15463) | file cs2d [JAF] Adventure (19) | file File does not exist (15919)
27.11.14 07:01:35 pm
Up
Ajmin
User
Offline Off
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
28.11.14 12:46:44 am
Up
Joni And Friends
User
Offline Off
@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
Web | file File does not exist (15501) | file File does not exist (15463) | file cs2d [JAF] Adventure (19) | file File does not exist (15919)
28.11.14 01:32:19 am
Up
VADemon
User
Offline Off
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
28.11.14 06:03:44 am
Up
MikuAuahDark
User
Offline Off
This simple thing may help
Code:
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
file cs2d LuaJIT for Dedicated Server (13) JIT POWER! | Know your Lua errors! | Part of LÖVE development team since 11.3
29.11.14 07:20:56 am
Up
Ferb Fletcher
User
Offline Off
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.

Code:
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
USGN ID #100000
To the start Previous 1 Next To the start