Forum

> > CS2D > Scripts > Increasing Speed every second
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Increasing Speed every second

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Increasing Speed every second

AtomKuh
User Off Offline

Zitieren
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^^

alt Re: Increasing Speed every second

Mami Tomoe
User Off Offline

Zitieren
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

alt Re: Increasing Speed every second

AtomKuh
User Off Offline

Zitieren
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'

alt Re: Increasing Speed every second

AtomKuh
User Off Offline

Zitieren
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)

alt Re: Increasing Speed every second

Cebra
User Off Offline

Zitieren
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
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht