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 2174 175 176338 339 Next To the start

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Okay, I added some explanations...
Spoiler >

old Re: Lua Scripts/Questions/Help

Dictatus Papae
User Off Offline

Quote
Can anyone tell me how to make a credit system that has no limit and shows it on the players screen. Also, if anyone knowas, how can I add the function to it (it's possible, already saw it on servers) , for example if aplayer collects money ($500), then it will add 500 to the normal money, but then take 500 away again (so it will be 0), but add 500 to the credits.

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
Terminator T02 has written
Can anyone tell me how to make a credit system that has no limit and shows it on the players screen. Also, if anyone knowas, how can I add the function to it (it's possible, already saw it on servers) , for example if aplayer collects money ($500), then it will add 500 to the normal money, but then take 500 away again (so it will be 0), but add 500 to the credits.

are you saying they should be able to have unlimited money?

old Re: Lua Scripts/Questions/Help

Dictatus Papae
User Off Offline

Quote
I have an error in this script, and I don't know this one, and I don't know what it means. The error is:
1
LUA ERROR:sys/lua/samples/Bounty_Hunter_DEMO.lua:61:attemp to index field 'mainmenu' (a function value)
.

I also have a VERY serious problem, what I can't even guess why it happens. The problem is that when I press key 1 (F2), the whole game closes. I hope someone knows how to solve it.

The script is unfinished, but I don't care, I just want to solve the problems.

The code is:
Spoiler >

Sorry, but the site put the ends in straight colums, otherwise it wouldn't be like that.

CmDark has written
Haha....
Terminator T02 is trying to recreate
[CC] RP Server's
lua scripts


No, I just think that it's a standard thing for all rps, I'm going to make mine completely different.
edited 2×, last 14.03.10 03:32:06 am

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
• math.randomseed() + os.clock()
1
math.randomseed(os.clock())
• math.random()
1
print(math.random(1100))

old Re: Lua Scripts/Questions/Help

goweiwen
User Off Offline

Quote
@Terminator
For your money thing, try using another value to store the player's money, serverside. Update it every time the player gets money, and use hudtxt2 to show the value on his screen.

1
LUA ERROR:sys/lua/samples/Bounty_Hunter_DEMO.lua:61:attemp to index field 'mainmenu' (a function value)
You are trying to index mainmenu, which is a function.
Instead of using mainmenu to store the players' selections, use another table with a different name.

@DRoNE
Use math.random()
1
math.random(0, 5)
That returns a random number from 0 to 5.

EDIT: ninja'd

old Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Quote
1
parse ("sv_sound \"blabla/"[b]..math.random(1,3)..[/b]"\"")

is this good? if i want random sound file of 3 soundifles

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Script which loads all T & CT spawns in table.
When do you want to spawn players at spawn base?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- Players Spawn (Table) Script --

blazz = { spawn_t_x = {}, spawn_t_y = {}, spawn_ct_x = {}, spawn_ct_y = {} }

function blazz.load()
	local x, y, name
	for x = 0, map([[xsize]]) do
		for y = 0, map([[ysize]]) do
			if entity(x,y,[[exists]]) then
				name = entity(x,y,[[typename]])
				if name == [[Info_T]] then
					table.insert(blazz.spawn_t_x, x)
					table.insert(blazz.spawn_t_y, y)
				elseif name == [[Info_CT]] then
					table.insert(blazz.spawn_ct_x, x)
					table.insert(blazz.spawn_ct_y, y)
				end
			end
		end
	end
end

blazz.load()

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
This script switch T & CT spawn places
That's example how to use those tables.
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
blazz = { spawn_t_x = {}, spawn_t_y = {}, spawn_ct_x = {}, spawn_ct_y = {} }

function blazz.load()
	local x, y, name
	for x = 0, map([[xsize]]) do
		for y = 0, map([[ysize]]) do
			if entity(x,y,[[exists]]) then
				name = entity(x,y,[[typename]])
				if name == [[Info_T]] then
					table.insert(blazz.spawn_t_x, x * 32)
					table.insert(blazz.spawn_t_y, y * 32)
				elseif name == [[Info_CT]] then
					table.insert(blazz.spawn_ct_x, x * 32)
					table.insert(blazz.spawn_ct_y, y * 32)
				end
			end
		end
	end
end

blazz.load()

function blazz.setpos(p) -- Random Terrorists Spawning
	local team, id = player(p,[[team]])
	if team == 2 then
		id = math.random(#blazz.spawn_t_x)
		parse(string.format([[setpos %s %s %s]],p,blazz.spawn_t_x[id],blazz.spawn_t_y[id]))
	elseif team == 1 then
		id = math.random(#blazz.spawn_ct_x)
		parse(string.format([[setpos %s %s %s]],p,blazz.spawn_ct_x[id],blazz.spawn_ct_y[id]))
	end
end

addhook([[spawn]],[[blazz.spawn]])
function blazz.spawn(p)
	blazz.setpos(p)
end

old Re: Lua Scripts/Questions/Help

DRoNe
User 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
27
28
29
30
31
32
33
34
35
36
37
drspawn = { spawn_t_x = {}, spawn_t_y = {}, spawn_ct_x = {}, spawn_ct_y = {} }

function drspawn.load()
     local x, y, name
     for x = 0, map([[xsize]]) do
          for y = 0, map([[ysize]]) do
               if entity(x,y,[[exists]]) then
                    name = entity(x,y,[[typename]])
                    if name == [[Info_CT]] then
                         table.insert(drspawn.spawn_ct_x, x * 32)
                         table.insert(drspawn.spawn_ct_y, y * 32)
                    end
               end
          end
     end
end

drspawn.load()

function pldie(p)
local team, id = player(p),[[team]])
	if (team==2) then
		if (dr.lifes[id] >= 6) then
			if (player(id,die)) then
				id = math.random(#drspawn.spawn_ct_x)
				parse(string.format([[setpos %s %s %s]],p,drspawn.spawn_ct_x[id],drspawn.spawn_ct_y[id]))
				dr.lifes[id] = dr.lifes[id] - 1
				msg2(id,"©000255000Your lifes : '..dr.lifes[id]..'/4@C")			
			end
		end
	end
end

addhook([[spawn]],[[drspawn.spawn]])
function drspawn.spawn(p)
     drspawn.setpos(p)
end

will this work? i chages your values(blazz) to (drspawn)
i combine your script with my ..
edited 3×, last 14.03.10 06:37:10 pm

old Re: Lua Scripts/Questions/Help

byengul
User Off Offline

Quote
Hi guyz;

I'm making a big Role-Playing Map and i want a level script how can i make a script like this;

•Killing Players Gives Exp
•Breaking Breakable things Gives Exp

I've another question but first i must know this level script
To the start Previous 1 2174 175 176338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview