English Count players and if?

31 replies
Goto Page
To the start Previous 1 2 Next To the start
25.01.18 12:56:41 am
Up
kRm
User
Offline Off
hello, code is like that
Code:
1
2
3
4
5
6
7
8
9
function zp_die(p)
local t = player(p,'team')
if (t == 2) then
parse('maket '..p)
end
     zp_hudtxt2(p,2,1,'',0,0,0)
     zp_hudtxt2(p,4,1,'',0,0,0)
     return 1
end


that means if a ct player die make him t.
but I just want to make like if player count > 1 (that means if more then 1 players is playing on server right now) what should I add on code?
25.01.18 01:03:18 am
Up
script favor
User
Offline Off
Here it is , Not tested.
Code:
1
2
3
4
5
6
7
8
9
10
function zp_die(p)
local t = player(p,'team')
local count = 1
if t == 2 and count==1 then
parse('maket '..p)
end
     zp_hudtxt2(p,2,1,'',0,0,0)
     zp_hudtxt2(p,4,1,'',0,0,0)
     return 1
end
Visit my website : https://bounty-mafia.tk , Discord : https://discord.gg/ntNd6TX, IMG:http://i60.tinypic.com/5kixc8.gif
25.01.18 01:15:24 am
Up
kRm
User
Offline Off
not working @user script favor:
25.01.18 01:21:00 am
Up
script favor
User
Offline Off
@user kRm: Now ?

Code:
1
2
3
4
5
6
7
8
9
10
11
function zp_die(p)
local t = player(p,'team')
for count = 1,32 do
if t == 2 and count > 1 then
parse('maket '..p)
     end
end
     zp_hudtxt2(p,2,1,'',0,0,0)
     zp_hudtxt2(p,4,1,'',0,0,0)
     return 1
end
Visit my website : https://bounty-mafia.tk , Discord : https://discord.gg/ntNd6TX, IMG:http://i60.tinypic.com/5kixc8.gif
25.01.18 01:28:26 am
Up
kRm
User
Offline Off
still not working @user script favor:
25.01.18 01:38:38 am
Up
zyLva okteLon
User
Offline Off
user kRm, Are you using the addhook spawn?
What the F.A.Q.?| zyLva okteLon ∗
25.01.18 01:44:51 am
Up
kRm
User
Offline Off
@user zyLva okteLon: yes I think

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
function zp_spawn(p)
     local t = player(p,'team')
     if (t == 1) then
          zp_p_health[p] = set_zm_val(zp_p_class[p],2)
          zp_zombie_set(p)
          zp_class_check(p)
          if (zp_t_tips > 0 and zp_on_tip > 0) then zp_msg2(p,8,'TIP: '..zp_t_tip[math.random(1,#zp_t_tip)]..'@C') end
     elseif (t == 2) then
          zp_wpn_menu_id[p] = 0
          parse('setmaxhealth '..p..' 100')
          if (zp_p_class[p] == -1) then
               parse('maket '..p)
               zp_msg2(p,4,'Nemesis Cant Change Teams!@C')
          end
          if (zp_on_tip > 0) then
               zp_menu_weapon(p)
               if (zp_buy_standart > 0) then zp_msg2(p,8,'Standart Buying Allowed!@C') end
               if (zp_ct_tips > 0) then zp_msg2(p,8,'TIP: '..zp_ct_tip[math.random(1,#zp_ct_tip)]..'@C') end
          end
          zp_p_weapons[p] = 0
     end
     zp_player_hud(p)
     if (zp_hud_flashlight > 0) then zp_light_set(p) end
end
25.01.18 01:54:37 am
Up
script favor
User
Offline Off
tested worked
Code:
1
2
3
4
5
6
7
8
9
10
11
function zp_die(p)
local t = player(p,'team')
for i = 1,1 do
if t == 2 then
parse('maket '..p)
     end
end
     zp_hudtxt2(p,2,1,'',0,0,0)
     zp_hudtxt2(p,4,1,'',0,0,0)
     return 1
end


Goodluck.
Visit my website : https://bounty-mafia.tk , Discord : https://discord.gg/ntNd6TX, IMG:http://i60.tinypic.com/5kixc8.gif
25.01.18 01:57:57 am
Up
kRm
User
Offline Off
@user script favor: It didnt worked
maybe as @user zyLva okteLon: said becouse of spawn hook ?
25.01.18 08:34:21 am
Up
apex2d
User
Offline Off
did you put Death Hook?
Eat Sleep Conquer Repeat. www.Radeon2D.forumid.net
25.01.18 09:06:09 am
Up
Gaios
Security Supporter
Offline Off
What is
count
? A variable or count of players in-game?
25.01.18 03:08:14 pm
Up
Fraizeraust
Moderator
Offline Off
For the code to take effect, you have to actually hook the
zp_die
function depending on the conditions or events you want to achieve. In this case we'll take cs2d lua hook die. Please take a look at the documentation of cs2d lua cmd addhook.
Code:
1
2
3
4
5
6
7
8
9
10
function zp_die(victim)
  if ( player(victim, 'team') == 2 ) then
    parse('maket ' .. victim)
    zp_hudtxt2(victim, 2, 1, '', 0, 0, 0)
    zp_hudtxt2(victim, 4, 1, '', 0, 0, 0)
    return 0
  end
end

addhook('die', 'zp_die')

As for player counting, you'd simply implement a generic for loop which iterates over existing players and create a condition if the exact count of players is above 1.
25.01.18 03:47:46 pm
Up
Yates
Reviewer
Offline Off
@user Fraizeraust: The function he posted is from file cs2d Zombie Plague Script (v 1.15) (202), it's already hooked. No need to tell him to hook it again as it will most likely break things rather than fix them.

Also telling someone to simply use the for statement when you can clearly see he has no idea what to do doesn't help (also that's the worst solution ever lol, CS2D has the cs2d lua cmd player function for this).

@user script favor: Please stop posting "solutions" as none of your code makes any sense.

@user kRm: What do you actually want to do? Make players zombies when they die if there is more than 1 person playing?

If so:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
function zp_die(p)
     local t = player(p,'team')
     local count = #player(0, "table")

     if (t == 2) and count > 1 then
          parse('maket '..p)
     end

     zp_hudtxt2(p,2,1,'',0,0,0)
     zp_hudtxt2(p,4,1,'',0,0,0)

     return 1
end


You will probably break core functions if you use this though. So.. good luck.
edited 1×, last 25.01.18 06:48:28 pm
25.01.18 05:11:38 pm
Up
Waldin
User
Offline Off
user Yates
count
is table so use
#player(0, "table")
or
#count
to get its lenght
user Waldin (2014) has written:
can be create 3D option for tiles on 3D
user DC (2014) has written:
@user Waldin: This is a 2D game. there are no 3D tiles.
changelog (2017) has written:
ADDED Experimental 3D rendering mode
25.01.18 06:48:13 pm
Up
Yates
Reviewer
Offline Off
My mistake, thank you!
26.01.18 07:50:07 pm
Up
Fraizeraust
Moderator
Offline Off
user Yates has written:
Also telling someone to simply use the for statement when you can clearly see he has no idea what to do doesn't help

This is his problem, not mine. If he has no clue how to code then one should start learning Lua and reading the freaking manual. Just by looking at his erroneously indented code (which is the most prime basic thing for a scripter to learn) I seriously doubt if he can code at all.
26.01.18 08:43:13 pm
Up
Yates
Reviewer
Offline Off
As I said, that's Simonas' code. If you don't want to provide sufficient help to people that need it then do what I usually do; don't post.
26.01.18 08:45:43 pm
Up
script favor
User
Offline Off
The problem is already solved by me stop posting.
Visit my website : https://bounty-mafia.tk , Discord : https://discord.gg/ntNd6TX, IMG:http://i60.tinypic.com/5kixc8.gif
26.01.18 08:46:48 pm
Up
Yates
Reviewer
Offline Off
Yeah sure he solved it just like he said:

user kRm has written:
@user script favor: It didnt worked


10/10 please help again. Go work on your shitty VPS service, thank you.
26.01.18 09:04:22 pm
Up
script favor
User
Offline Off
I send him the script on pm and stop flame , fucking kiddy.
Visit my website : https://bounty-mafia.tk , Discord : https://discord.gg/ntNd6TX, IMG:http://i60.tinypic.com/5kixc8.gif
To the start Previous 1 2 Next To the start