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 2119 120 121338 339 Next To the start

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
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 ?

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
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...

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
@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)

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
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()))

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
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.

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
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
edited 1×, last 17.12.09 10:11:03 pm

old Re: Lua Scripts/Questions/Help

zastana
User Off Offline

Quote
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!!!

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
-WiLSoN- has written
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...

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
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.
To the start Previous 1 2119 120 121338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview