Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 298 99 100338 339 Next To the start

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
xd
Spoiler >


Can you help me please? it's not doing any errors
but its also not doing the function either

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Try this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
addhook("leave","playerlog_save")
function playerlog_save(id)
	local usgn = player(id, "usgn")
	if usgn > 0 then
		local score = player(id,"score")
		local death = player(id,"deaths")
		local name = player(id,"name")
		local ip = player(id,"ip")
		local port = player(id,"port")
		local health = player(id,"health")
		local maxhealth = player(id,"maxhealth")
		local speed = player(id,"speedmod")
		local armor = player(id,"armor")
		local money = player(id,"money")
		local save_data = name.." "..score.." "..death.." "..ip.." "..port.." "..health.." "..maxhealth.." "..speed.." "..armor.." "..money
		file = assert(io.open("sys/lua/playerlog/"..usgn..".txt","w"))
		file:write(save_data)
		file:close()
		msg2(id,'©000255000Player Log Saved!@C')
	end
end

old Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Quote
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
addhook("leave","leave")
function leave(id,reason)
save(id)
end

function save(id)
	name = player(id,"name")
	mn = player(id,"money")
	usgn = player(id, "usgn")
	score = player(id,"score")
	death = player(id,"deaths")
	mxhl = player(id,"maxhealth")
	ip = player(id,"ip")
	speed = player(id,"speedmod")
	armor = player(id,"armor")
	hl = player(id,"health")
	if (player(id, "usgn") > 0) then
		save_data = mn.." "..score.." "..death.." "..mxhl.." "..speed.." "..ip.." "..armor.." "..hl.." "..name
		file = assert(io.open("sys/lua/playerlog/"..usgn..".txt","w"))
		file:write(save_data)
		file:close()
		msg2(id,'©000255001Your U.S.G.N ID: '..usgn..' Save Succesful!@C')
		else
			msg2(id,"©Player Log Saved!@C")
	end
end

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
ok i wanna be able to make simple classes for zombies ONLY, does anyone have a very easy to use script for this? all it has to have is zombie hp, items, and speed.

thanks

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
Lol @Starkkz

You just made it so that if the save is unsuccessful then it parses Player log Saved
lol..


and
@jackisokay2
To manage speed and hp you can do that in server settings for items also in server settings

mp_zombiekillequip
mp_zombiespeedmod
mp_zombierecover

All in server settings

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
well, i mean different speed hp and items for each zombie. :p like classes for the zombies, for example, zombie plague.

so far all i have is(most i copy-pasta from sample class, correct it if its wrong plox?)
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
function serveraction(id,action)
	if (action == 2) then
		if (player(id,"team")==1) then
	sample.classes.class=initArray(32)
function sample.classes.classmenu(id)
	menu(id,"Select your Class,Basic|Basic,Spy|Stealth,Fat Zombie|Armor,Fast Zombie|Speed,Strong Zombie|Machete,Super Fat Zombie|Super Armor")	
end


	if (sample.classes.class[id]<=1) then
		parse ("setmaxhealth "..id.." 100")
		parse ("setarmor "..id.." 0")
		return "40,4,51";
	end
	
	if (sample.classes.class[id]==2) then
		parse ("setmaxhealth "..id.." 80")
		parse ("equiparmor "..id.." 85")
		parse ("speedmod "..id.." 5")
		return "21,1";
	end
	
	if (sample.classes.class[id]==3) then
		parse ("setmaxhealth "..id.." 80")
		parse ("equiparmor "..id.." 50")
                parse ("speedmod "..id.." -1")
		return "10,2,74";
	end
	
	if (sample.classes.class[id]==4) then
		parse ("setmaxhealth "..id.." 125")
		parse ("setarmor "..id.." 75")
		return "46,6,73";
	end
	
	if (sample.classes.class[id]==5) then
		parse ("setmaxhealth "..id.." 75")
		parse ("setarmor "..id.." 0")
		parse ("speedmod "..id.." 15")
		return "5,69,54";
	end
	
	if (sample.classes.class[id]==6) then
		parse ("setmaxhealth "..id.." 75")
		parse ("setarmor "..id.." 25")
		return "35,3,53";
	end
end
edited 1×, last 24.11.09 01:16:52 am

old Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Quote
jackisokay2 has written
well, i mean different speed hp and items for each zombie. :p like classes for the zombies, for example, zombie plague.

so far all i have is(most i copy-pasta from sample class, correct it if its wrong plox?)
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
function serveraction(id,action)
	if (action == 2) then
		if (player(id,"team")==1) then
	sample.classes.class=initArray(32)
function sample.classes.classmenu(id)
	menu(id,"Select your Class,Basic|Basic,Spy|Stealth,Fat Zombie|Armor,Fast Zombie|Speed,Strong Zombie|Machete,Super Fat Zombie|Super Armor")	
end


	if (sample.classes.class[id]<=1) then
		parse ("setmaxhealth "..id.." 100")
		parse ("setarmor "..id.." 0")
		return "40,4,51";
	end
	
	if (sample.classes.class[id]==2) then
		parse ("setmaxhealth "..id.." 80")
		parse ("equiparmor "..id.." 85")
		parse ("speedmod "..id.." 5")
		return "21,1";
	end
	
	if (sample.classes.class[id]==3) then
		parse ("setmaxhealth "..id.." 80")
		parse ("equiparmor "..id.." 50")
                parse ("speedmod "..id.." -1")
		return "10,2,74";
	end
	
	if (sample.classes.class[id]==4) then
		parse ("setmaxhealth "..id.." 125")
		parse ("setarmor "..id.." 75")
		return "46,6,73";
	end
	
	if (sample.classes.class[id]==5) then
		parse ("setmaxhealth "..id.." 75")
		parse ("setarmor "..id.." 0")
		parse ("speedmod "..id.." 15")
		return "5,69,54";
	end
	
	if (sample.classes.class[id]==6) then
		parse ("setmaxhealth "..id.." 75")
		parse ("setarmor "..id.." 25")
		return "35,3,53";
	end
end


use this.

Spoiler >

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
Thanks starkkz!!!

but now i have a new question, i'm sure i'm doing something stupid, but this is my script so far, but if i start a new game in cs2d, it doesn't work. what am i doing wrong? as a matter of fact none of the parse("") stuff doesn't work. help?

Spoiler >
edited 1×, last 24.11.09 05:49:45 am

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
you should use spoiler command to hide your code, because to long >.< , got a problem? why don't post the error here?

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
@Jackisokay:
Omg dude, your script is full of crap Dx
Quote
[...]
parse("mp_wpndmg xm1014 55")
parse("mp_wpndmg claw 2000")
parse("mp_wpndmg deagle 35")
parse("mp_wpndmg mine 100")
parse("mp_wpndmg he 100")
parse('mp_wpndmg "Gut Bomb" 0')
parse("mp_autoteambalance 0")
parse("sv_friendlyfire 0")
parse("mp_infammo 1")
parse("mp_zombierecover 0")
parse("sv_fow 0")
end
[...]

Why is there an end?

Quote
addhook("team","sample.classes.team")
function sample.zombie.team(id,team)
if (team>0) then
sample.zombie.classmenu(id)
end
end

You know that any player (zombies and survivors) will be able to choose class, right?

Quote
if (sample.zombie.class[id]==6) then
parse ("setmaxhealth "..id.." 75")
parse ("equiparmor "..id.." 83")
parse ("speedmod "..id.." -10")
return "35,3,53";
end

There isn't any command called "equiparmor", you surely meant "setarmor"

And why aren't there any tabs?
If you put them, we will be able to help you better

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
Flacko has written
@Jackisokay:
Omg dude, your script is full of crap Dx


Quote
addhook("team","sample.classes.team")
function sample.zombie.team(id,team)
if (team>0) then
sample.zombie.classmenu(id)
end
end

You know that any player (zombies and survivors) will be able to choose class, right?


Quote
if (sample.zombie.class[id]==6) then
parse ("setmaxhealth "..id.." 75")
parse ("equiparmor "..id.." 83")
parse ("speedmod "..id.." -10")
return "35,3,53";
end

There isn't any command called "equiparmor", you surely meant "setarmor"

And why aren't there any tabs?
If you put them, we will be able to help you better


hahah thanks as you can see im a total retard when it comes to scripts.

im also wondering, what are tabs?

how would i make it just for zombies then? thanks

also, now that i edited it, it works, until i click on "zombies" then it just quits out of the game.
edited 1×, last 24.11.09 02:16:30 pm

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Lol, not a retard, just a newbie
Tabs are these:

Untabbed function ×
1
2
3
4
5
6
addhook("team","sample.classes.team")
function sample.zombie.team(id,team)
if (team>0) then
sample.zombie.classmenu(id)
end
end

Tabbed function √
1
2
3
4
5
6
addhook("team","sample.classes.team")
function sample.zombie.team(id,team)
	if (team>0) then
		sample.zombie.classmenu(id)
	end
end

This way you can find missing ends and helps to make the code more readable.
Now put some tabs in your script. Go, go, go!

EDIT: w00t the 100 page is MINE
edited 1×, last 24.11.09 02:41:07 pm

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function zombiemenu(id)
	menu(id,"Zombies Menu,Zombie1,Zombie2")-- zombie classes here
end
addhook("team","teamm")
function teamm(id,team)
	if (team == 1) then
		zombiemenu(id) -- opens zombie class menu
	end
end
addhook("serveraction","svac")
function svac(id,ac)
	if (player(id,"team")==1) then
		if (ac == 1) then
			zombiemenu(id) -- opens zombie menu if you press F2
		end
	end
end
that should work. but you need to do the menu thing now.

old Re: Lua Scripts/Questions/Help

Scythe
User Off Offline

Quote
I have a question.

How can you detect if a player is dead?
1
if player==dead???

addhook ("say" "Prison.dead")
function Prison.dead (id,t (what do i put for dead?))
To the start Previous 1 298 99 100338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview