Forum

> > CS2D > Scripts > Tables and random spawns ?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Tables and random spawns ?

18 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Tables and random spawns ?

Kirito2K
User Off Offline

Zitieren
Hey us !
Today i need some help ..

What i need is so simple , it's 2 requests but easy to be made !

First quest : I need a script for a happytown , when a mod spawns he spawns in a random house of "mod" houses which in the map!
Which means i need 2 tables for this script , i think ..

Second quest : I need a script allows only mods to get in a special and other players just can't in!

alt Re: Tables and random spawns ?

G3tWr3ck3d
User Off Offline

Zitieren
Create your tables and use the spawn hook.

admin = {x,y}
mod = {x,y}

function spawn(id)
if level[id] == admin then
parse("setpos '..id..' '..admin[1]..' '..admin[2]")
end
end

alt Re: Tables and random spawns ?

Mora
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
mods = {114940}

addhook("spawn","_sp")
function _sp(id,tilex,tiley)
	for _,modsusgn in ipairs(mods) do
		if player(id,"usgn")==modsusgn then
rand_sp={"100 100","500 500","240 130"}
parse("setpos "..id.." "..rand_sp[math.random(1,#rand_sp)])
		end
	end
end

you have to add more pos to the table "rand_sp". Good luck.

alt Re: Tables and random spawns ?

Kirito2K
User Off Offline

Zitieren
user Mora's one is good , i used it !

Anyway ! , now i need another script for the houses!

It prevent the normal players from getting into a area can be modified by some entity in the editor !
1× editiert, zuletzt 13.09.15 16:57:33

alt Re: Tables and random spawns ?

Rainoth
Moderator Off Offline

Zitieren
Please mind that I haven't used lua for quite a while so there might be problems.
Here's the code: >

It should do what you're asking for. If you want to include more possible houses to spawn in, write them. It will spawn the person in a random house. Coordinates are in tiles not pixels. If you want to make an impassable area, make any entity and name it either 'No' or 'Impassable' or 'NoEntry'
Say if there's anything wrong and I'll see if I can fix that.
1× editiert, zuletzt 13.09.15 19:39:20

alt Re: Tables and random spawns ?

Kirito2K
User Off Offline

Zitieren
@user Rainoth: Wait , i already said that i want user Mora's script , but also i need the second script of that house u made , i can't understand about it a bit, it will be better if you mix with this script below with your house script!
Script >

alt Re: Tables and random spawns ?

Rainoth
Moderator Off Offline

Zitieren
What's not to understand there?
• Change numbers to fit tile coordinates that you need
• Create an entity where people cant go and name it 'Impassable'
• Try running the script

You don't have to understand anything. Also, you didn't say that we were supposed to mix user Mora' script (which btw requires you to calculate coordinates in pixels by yourself). All you have to do is change the numbers to fit your map. Please tell me you've got enough brain to edit a few numbers .-.

alt Re: Tables and random spawns ?

Kirito2K
User Off Offline

Zitieren
@user Rainoth: The spawning stuff is working well but the house thingy gives a error when the server starts !
Errors >

alt Re: Tables and random spawns ?

Rainoth
Moderator Off Offline

Zitieren
Wut. House thingy IS the spawning stuff.
But I can see the error. I was copy pasting and so there's two 'x' instead of 'x' and 'y'. Let me correct the code and then you copy it from the post where I put it

alt Re: Tables and random spawns ?

Rainoth
Moderator Off Offline

Zitieren
Ah that. No problem. Give me some time (a day at most).

// Oke, here's the code
Click me! >

All you have to do is change pk.Type (line 5) into the number of which entity it has to be. I don't know the type IDs and cs2d.com doesn't provide them so you'll have to print out the type ID by yourself (that much I'm sure you can do) OR wait for someone else to write them
1× editiert, zuletzt 14.09.15 15:02:00

alt Re: Tables and random spawns ?

Kirito2K
User Off Offline

Zitieren
@user Rainoth: Not working , got another bug , u didn't get it so too btw !
I need the entity to be modified by name AND type , not one of them!

here's the bug below ..
1
2
3
4
[15:09:05] LUA ERROR: sys/lua/HT2.lua:23: bad argument #3 to 'inentityzone' (number expected, got nil)
[15:09:05]  -> [C]: in function 'inentityzone'
[15:09:05]  -> sys/lua/HT2.lua:23: in function <sys/lua/HT2.lua:22>
[15:09:05]  -> in Lua hook 'movetile', params: 1, 6, 1

alt Re: Tables and random spawns ?

Rainoth
Moderator Off Offline

Zitieren
That's not possible. At least I don't know how I'd do it. inentityzone has only 3 arguments (x to be checked, y to be checked, entity type). It's the only way to check if you're in the zone. If you want it by name, you use one entity for one tile. If you want one entity for an area of tiles, you'll have to use my method. It's just how CS2D works.

In the future I'd advise to write what you want properly. You didn't say that you wanted it both by name and inentityzone so how was I supposed to 'get you'???

TL;DR choose one method.

alt Re: Tables and random spawns ?

Kirito2K
User Off Offline

Zitieren
Can't we just add
1
if entity(x,y,"name") == "NoEntry" or entity(x,y,"name") == "Impassable" or entity(x,y,"name") == "No" then
Before
1
if inentityzone(x,y,pk.Type) then

or simply modifying the zone using env_hurt with 0 valve ??

alt Re: Tables and random spawns ?

Rainoth
Moderator Off Offline

Zitieren
@Option 1: No you can't because it's looking for ENTITY at X|Y
So lets say you've got a 5 tile wide gap which you want to close
If you want your method to work you'd have to do:
X - entity, O - space covered by entity
1
X X X X X
Then it would work but then why would you need inentityzone?
Cause when you've got
1
X O O O O
(with inentityzone) and say you're here
1
X O P O O
then you're looking for entity but it's not there (only a zone covered by entity in another tile)
@Option 2: Ye, it could work with any kind of entity that covers area. env_hurt would be no exception however it would work on ALL env_hurt entities. I'd rather suggest using _NoBuildings.

TL;DR choose one method.

alt Re: Tables and random spawns ?

Kirito2K
User Off Offline

Zitieren
Then i would like to use the x|y x|y thingy , but i need a example for it so i can understand , btw ur X and O things didn't get them at all ..

alt Re: Tables and random spawns ?

Rainoth
Moderator Off Offline

Zitieren
Zitat
Then i would like to use the x|y x|y thingy

Wat. There's no x|y thingy in my script when talking about disallowing entry on a tile.

I'll just assume that you want to use the "entity with name "NoEntry"" method and place an entity everywhere that's supposed to be impassable

Replace
1
if inentityzone(x,y,pk.Type) then
with
1
if entity(x,y,"name") == "NoEntry" or entity(x,y,"name") == "Impassable" or entity(x,y,"name") == "No" then
in my code. I'm sure you can do that much.

alt Re: Tables and random spawns ?

Kirito2K
User Off Offline

Zitieren
@user Rainoth: About the X|Y i meant i write X to X , Y to Y , but i got idea that it using env_room , i don't use that entity at any place , so it will be a good idea for mod houses only!

I think that i have to use this
code, right ? >


but i got a error last time i used it here it is below
Pirates killer hat geschrieben
1
2
3
4
[15:09:05] LUA ERROR: sys/lua/HT2.lua:23: bad argument #3 to 'inentityzone' (number expected, got nil)
[15:09:05]  -> [C]: in function 'inentityzone'
[15:09:05]  -> sys/lua/HT2.lua:23: in function <sys/lua/HT2.lua:22>
[15:09:05]  -> in Lua hook 'movetile', params: 1, 6, 1


EDIT : Any help ?? none answered me ?
1× editiert, zuletzt 16.09.15 16:07:22
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht