Scripts / How to Spawn entity by number

Author
Message
shakyshawn8151
10
Years of Service
User Offline
Joined: 9th Nov 2013
Location: United States
Posted: 11th Jun 2015 05:10
Like title says, I did it in the past but I have been away
I got this


How to spawn an entity that is Entity # 9
CPU; Intel G850 2.9ghz \ GPU: Raedon HD 7750 1gb \ 4GB Ram

Windows 10 \ 1TB HD \ 60GB HD
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 11th Jun 2015 07:59
Spawn(9)
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
shakyshawn8151
10
Years of Service
User Offline
Joined: 9th Nov 2013
Location: United States
Posted: 11th Jun 2015 18:56
Awesome TY, I figured last night that (e) stood for Entity Number, I tried it last night, guess I used a wrong format, it is working, but how about if I want to spawn multiple entities say for instance entity 1 24 25 29 I tried a few things like
Spawn(1,24,25,28) --I knew this one wouldnt work but tried anyway I also tried
Spawn('1, 24, 25, 28')
CPU; Intel G850 2.9ghz \ GPU: Raedon HD 7750 1gb \ 4GB Ram

Windows 10 \ 1TB HD \ 60GB HD
shakyshawn8151
10
Years of Service
User Offline
Joined: 9th Nov 2013
Location: United States
Posted: 11th Jun 2015 20:59
Not sure if it is even possible without some sort of work around, maybe smallg would know.
CPU; Intel G850 2.9ghz \ GPU: Raedon HD 7750 1gb \ 4GB Ram

Windows 10 \ 1TB HD \ 60GB HD
Isagabe
9
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 12th Jun 2015 06:20 Edited at: 12th Jun 2015 06:26
I am not a coder by any stretch but I have multiple spawns all over my little map and this seems to work just fine. Last count - at least 20 different multiple spawn point trigger zones and they all work. Obviously entity numbers will differ and each script has a different name. Anyway as no one answered I hope this helps .

-- LUA Script -
-- Script to spawn entities on trigger point

function multiplespawn_init(e)
entity_number = 1
entity_number = 2
entity_number = 3
end
function multiplespawn_main(e)
if GetPlayerInZone(e) == 1 then
Spawn(1)
end
if GetPlayerInZone(e) == 1 then
Spawn(2)
end
if GetPlayerInZone(e) == 1 then
Spawn(3)
end
end

edit: as you already know the selected item(s) have to be set "spawn at start=no", "always active=no" in properties.
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 12th Jun 2015 07:22
@Isagabe - In your example "entity_number" would always be 3 and doesn't actually do anything anyway. All spawns would occur one after another too so your code could be written this way to do the same thing. I think it also solves shakyshawn8151's problem too.



An alternate method is to set the entity numbers at the top so you can easily change them (which is perhaps what you were trying to do).



There are much more elegant solutions using tables and _name fields but that might be best left for now so as not to confuse the issue.
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
Isagabe
9
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 12th Jun 2015 11:47
Thank you. Always nice to learn from someone who actually knows.
shakyshawn8151
10
Years of Service
User Offline
Joined: 9th Nov 2013
Location: United States
Posted: 12th Jun 2015 17:46
Awesome, I am feeling very dumbfounded as to why I did not realize I could call multiple spawns by just repeating the command, thank you guys very much.
CPU; Intel G850 2.9ghz \ GPU: Raedon HD 7750 1gb \ 4GB Ram

Windows 10 \ 1TB HD \ 60GB HD

Login to post a reply

Server time is: 2024-05-03 09:58:19
Your offset time is: 2024-05-03 09:58:19