Forum

> > CS2D > Scripts > Increasing Speed every second
Forums overviewCS2D overview Scripts overviewLog in to reply

English Increasing Speed every second

5 replies
To the start Previous 1 Next To the start

old Increasing Speed every second

AtomKuh
User Off Offline

Quote
I want my speed to be increased every second until 10 seconds are reached.

I have this script (console does not show any errors):

1
2
3
4
5
6
7
8
function menu_f2(id,action)
if action==1 then
for i = 1000,10000,1000 do
timer(i,"parse","speedmod " .. id .. " " .. player(id, "speedmod") + 10)
  
	end	  	  
end
end

It does not work^^ It only increases my speed +10 after one second and that nothing happens^^

old Re: Increasing Speed every second

Mami Tomoe
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
sp = { playersdata = {} }
for i = 1 ,32 do
	sp.playersdata[i] = { increase = false }
end

addhook('second', 'sp.hooks.second')
function sp.hooks.second()
	for _, id in pairs(players(0, 'tableliving')) do
		if sp.playerdata[id].increase then
			parse('speedmod '..id.. '..player(id, 'speed') + 10)
		end
	end
end

addhook('leave', 'sp.hooks.leave')
function sp.hooks.leave(id)
	sp.playerdata[id].increase = false
end

addhook('serveraction', 'sp.hooks.serveraction')
function sp.hooks.serveraction(id, button)
	if button == 1 then
		sp.playersdata[id].increase = not sp.playersdata[id].increase
	end
end

old Re: Increasing Speed every second

AtomKuh
User Off Offline

Quote
Thanks Goo but I am getting an error in this line:

1
parse('speedmod '..id.. '..player(id, 'speed') + 10)

Error: LUA ERROR: sys/lua/lol.lua:10: ')' expected near 'speed'

old Re: Increasing Speed every second

AtomKuh
User Off Offline

Quote
after changing that line my games crashes instantly after starting the server

Error in log-file:
1
LUA ERROR: sys/lua/lol.lua:7: attempt to index field 'hooks' (a nil value)

old Re: Increasing Speed every second

Cebra
User Off Offline

Quote
yeah, i think i fixed all errors now

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
sp = { playersdata = {}, hooks = {} }
for i = 1 ,32 do
     sp.playersdata[i] = { increase = false }
end

addhook('second', 'sp.hooks.second')
function sp.hooks.second()
     for _, id in pairs(player(0, 'tableliving')) do
          if sp.playersdata[id].increase then
               parse('speedmod '..id..' '..player(id, 'speedmod') + 10)
          end
     end
end

addhook('leave', 'sp.hooks.leave')
function sp.hooks.leave(id)
     sp.playersdata[id].increase = false
end

addhook('serveraction', 'sp.hooks.serveraction')
function sp.hooks.serveraction(id, button)
     if button == 1 then
          sp.playersdata[id].increase = not sp.playersdata[id].increase
     end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview