Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 2119 120 121338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
does anyone now how can i make random spawn points (not entities) i mean to get people spawning on different places of the map without being spawn out of the map, is that possible ?

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Yea, you could make table (x,y) of respawn points for each map.
Then set position randomly (from table) of player when he spawn.
But that's not what you need.

There is other way,
You have to make tile() function in that case...

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
thanks blazzingxx, i thought it was possible with a table of tiles where to spawn, but i wanted to be randomly without adding any tab...
anyways thanks a lot

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
@Starkzz
Something like this ?
1
2
3
4
5
6
7
8
addhook("hit","god")
function god(id)
	if (player(id,"usgn") ==  Your Usgn) then
		return 1
	else
		return 0
	end
end
@Anyone
I'm going to need help with that random spawning...
Spoiler >

i'm getting this error :
LUA ERROR: dir: attempt to concatenate local 'y' (a nil value)
the line is this:

parse("spawnplayer "..id.." "..x.." "..y)

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
I'd suggest you to forget this.
You will need some pathfinding algorithms to spawn players inside the map and make sure they can reach certain spots, like bombspots, hogstages, etc.
However, your error is here
1
2
if (map == "de_dust") then
	spawning(id,rndmap())
You must unpack the table to pass it as arguments
1
2
if (map == "de_dust") then
	spawning(id,unpack(rndmap()))

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
i changed it, and now i get this error:

LUA ERROR: dir: bad argument to 'unpack' (table expected, got number)

hmm i think i'll forget this, as you said

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
Here I fixed it
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
maptable =
{
	de_dust={{1,2},{3,4},{5,6},{7,8},{9,10}},
	de_dust2={{11,12},{13,14},{15,16},{17,18},{19,20}}
}

function rndmap(whatmap)
     local rnd = math.random(1,#maptable[whatmap])
     return maptable[whatmap][rnd]
end

map = game("sv_map")

function spawning(id,x,y)
	parse("setpos "..id.." "..x.." "..y)
end

addhook("spawn","spawns")
function spawns(id)
	if map == "de_dust" then
		spawning(id, unpack(rndmap("de_dust")) )
	elseif map == "de_dust2" then
		spawning(id, unpack(rndmap("de_dust2")) )
	end
end

Notice that the spawning function doesn't spawn a player, it just sets it's position, otherwise you might provoke an infinite loop.

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
wow thanks Flacko
Edit:
Now i get other error ... D:!
LUA ERROR: dir: attempt to call a nil value
i checked if i was using an incorrect hook's name, and i wasn't using a wrong function
anyways LOTS of thanks Flacko
1× editiert, zuletzt 17.12.09 22:11:03

alt Re: Lua Scripts/Questions/Help

zastana
User Off Offline

Zitieren
hey blazingxx could u, make another script? new script? warcraft new script? please u rock dude, but if u wanna make the warcraft script u wanna make some skins look like the player at warcraft. please make it!!!

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
-WiLSoN- hat geschrieben
still not working... could the problem be in other part of the script ?


If you have any other running scripts deactivate them, the snippet that I gave you should work with no console error.
At least it does for me...

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
i've got only that script opened... but i added that to another script so its just 1 file but has more things that the random spawning.
Zum Anfang Vorherige 1 2119 120 121338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht