﻿ Unreal Software - Thread: Count players and if?

Count players and if?

31 replies
Goto Page
1 2
25.01.18 12:56:41 am
kRm
User
Offline
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
script favor
User
Offline
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
25.01.18 01:15:24 am
kRm
User
Offline
not working @ script favor:
25.01.18 01:21:00 am
script favor
User
Offline
@ 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
25.01.18 01:28:26 am
kRm
User
Offline
still not working @ script favor:
25.01.18 01:38:38 am
Polar
User
Offline
kRm, Are you using the addhook spawn?
What the F.A.Q.?| faqduLLAH
25.01.18 01:44:51 am
kRm
User
Offline
@ Polar: 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
script favor
User
Offline
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.
25.01.18 01:57:57 am
kRm
User
Offline
@ script favor: It didnt worked
maybe as @ Polar: said becouse of spawn hook ?
25.01.18 08:34:21 am
apex2d
User
Offline
did you put Death Hook?
Eat Sleep Conquer Repeat. www.Radeon2D.forumid.net
25.01.18 09:06:09 am
Gaios
Security Supporter
Offline
What is
count
? A variable or count of players in-game?
25.01.18 03:08:14 pm
Fraizeraust
Moderator
Offline
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 die. Please take a look at the documentation of 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
Yates
Reviewer
Offline
@ Fraizeraust: The function he posted is from 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 player function for this).

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

@ 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
Waldin
User
Offline
Yates
count
is table so use
#player(0, "table")
or
#count
to get its lenght
Waldin (2014) has written:
can be create 3D option for tiles on 3D
DC (2014) has written:
@ Waldin: This is a 2D game. there are no 3D tiles.
changelog (2017) has written:
Experimental 3D rendering mode
25.01.18 06:48:13 pm
Yates
Reviewer
Offline
My mistake, thank you!
26.01.18 07:50:07 pm
Fraizeraust
Moderator
Offline
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
Yates
Reviewer
Offline
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
script favor
User
Offline
The problem is already solved by me stop posting.
26.01.18 08:46:48 pm
Yates
Reviewer
Offline
Yeah sure he solved it just like he said:

kRm has written:
@ 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
script favor
User
Offline
I send him the script on pm and stop flame , fucking kiddy.
1 2
﻿