TobiaszPL Posted June 3, 2019 Share Posted June 3, 2019 Hey T_Ti have problem... why my EPIC and Amazing script for MMO Spots is not working? xD Image with all ingerents: Here is script one: Scriptname QLG_Script_MMOSpot extends Actor { } ;===- Base Info. -===; ;Created: 2019-05-19 ;Update: 2019-06-03 ;Author: TobiPL ;Unit: M.PC<1> ;===- Var. setup -============================================ FormList Property QSpawnPoints Auto { Points where Actors can be Spawn } FormList Property QSpawnActors Auto { Actors that can be Spawn } float Property QSpawnDelay Auto { Delay to wait in game h to wait before next spawn :: 0.5 is 30 Game Minutes } GlobalVariable Property QDebug Auto { Global, true/false to show Debug Notifications ! please, use "QLG_DEBUG_SCRIPT" } ;*******************************************; int ToSpawn = 0 ; Amount of Monsters left to Spawn Bool Register = true ; Should register for update? ;*******************************************; ObjectReference SpawnRef ; Ref where unit gonna be spawn ActorBase ActorRef ; Ref which unit gonna be spawn ;*******************************************; ;================================================ ;===- Main Script -============================== ;***********************************************; Event OnActivate( ObjectReference QRef ) If( QDebug as bool ) Debug.Notification( "MMO Spot: New Unit Register" ) EndIf ToSpawn += 1 If( Register ) Register = false RegisterForSingleUpdate( QSpawnDelay ) EndIf EndEvent ;***********************************************; Event OnUpdate() ToSpawn -= 1 If( QDebug as bool ) Debug.Notification( "MMO Spot: Update, left: " + ( ToSpawn as Int ) + "!..." ) EndIf ;******************; If( ToSpawn <= 0 ) Register = true Else RegisterForSingleUpdate( QSpawnDelay ) EndIf ;******************; SpawnRef = ( QSpawnPoints.GetAt( Utility.RandomInt( 0 , QSpawnPoints.GetSize() ) ) as ObjectReference ) ActorRef = ( QSpawnActors.GetAt( Utility.RandomInt( 0 , QSpawnActors.GetSize() ) ) as ActorBase ) SpawnRef.PlaceAtMe( ( ActorRef as ActorBase ) , 1 ) ;******************; EndEvent ; The End Here is script two: Scriptname QLG_Script_MMOMonsterDeath extends Actor { Script to register new Actor Spawn in MMO Script } ;===- Base Info. -===; ;Created: 2019-05-19 ;Update: 2019-05-31 ( TobiPL ) ;Author: TobiPL ;Unit: M.PC<3> ;===- Var. setup -============================================ ObjectReference Property QTarget Auto { Spot CARDINAL Ref. } ;===- Script -Main- -================================================ Event OnDeath( Actor QKiller ) QTarget.Activate( self ) Utility.Wait(60.0) ;Wait for other Mods / Scripts self.disable( true ) ;Disable Utility.Wait(10.0) ;Wait self.delete() ;Delete EndEvent ;===- Script -===-===- ;ReDragon2013 ( NexusForum ) Event OnCellDetach() Self.Delete() ; Just in case ( Have to be verified ) EndEvent ; The End I can see in game Debug Notifications but no new units... After one unit die this script should spawn new...Script should spawn new units every 30 sec untill all units got respawn Link to comment Share on other sites More sharing options...
maxarturo Posted June 4, 2019 Share Posted June 4, 2019 (edited) I erased the post because i was wrong.... Edited June 4, 2019 by maxarturo Link to comment Share on other sites More sharing options...
ReDragon2013 Posted June 4, 2019 Share Posted June 4, 2019 (edited) maybe this is working.. ; be carful with next two variables, they make both Refs persistent as long as the script exists !!! ObjectReference SpawnRef ; Ref where unit gonna be spawn Actor ActorRef ; Ref which unit gonna be spawn Event OnActivate( ObjectReference QRef ) If( QDebug as bool ) Debug.Notification( "MMO Spot: New Unit Register" ) EndIf ToSpawn += 1 ; ADD by 1 If( Register ) Register = false RegisterForSingleUpdate( QSpawnDelay ) EndIf EndEvent Event OnUpdate() ToSpawn -= 1 ; DEL by 1 int i1 = Utility.RandomInt(0, QSpawnPoints.GetSize() - 1) int i2 = Utility.RandomInt(0, QSpawnActors.GetSize() - 1) If( QDebug as bool ) Debug.Notification( "MMO Spot: Update, left: " + ToSpawn + "!..." + i1 + ", " + i2) EndIf If( ToSpawn <= 0 ) ; <-- *** this is Zero normally *** Register = true Else RegisterForSingleUpdate( QSpawnDelay ) EndIf SpawnRef = QSpawnPoints.GetAt(i1) as ObjectReference ; you get a spawnpoint, but is it already placed in the world? yes/no ; https://www.creationkit.com/index.php?title=PlaceAtMe_-_ObjectReference ; ----------------------------------------------------------------------- ActorRef = SpawnRef.PlaceAtMe(QSpawnActors.GetAt(i2), 1) ; if spawnpoint already exists this should work to spawn new actors EndEvent Edited June 4, 2019 by ReDragon2013 Link to comment Share on other sites More sharing options...
TobiaszPL Posted June 5, 2019 Author Share Posted June 5, 2019 (edited) ; be carful with next two variables, they make both Refs persistent as long as the script exists !!!ObjectReference SpawnRef ; Ref where unit gonna be spawnActor ActorRef ; Ref which unit gonna be spawn what exactly do u mean?They will be bigger and bigger with every mob spawned? ActorRef = NULLor something will work to clear variable? i think i know what is wrong but can't test it xDDDFirst line of First Script: ( Scriptname QLG_Script_MMOSpot extends Actor ) Its because i rewrite other script for actor and forgot to change extends xDprobably when i change it to ObjectReference it will work fine :D but im not sure... still i want to know what u mean by "Persistent" and what shouldn't i do with those variablesor what i should do to keep my script good :D //Edit:( QSpawnPoints.GetAt( Utility.RandomInt( 0 , QSpawnPoints.GetSize() ) ) as ObjectReference ).( QSpawnActors.GetAt( Utility.RandomInt( 0 , QSpawnActors.GetSize() ) ) as ActorBase ) xD Edited June 5, 2019 by TobiaszPL Link to comment Share on other sites More sharing options...
Evangela Posted June 5, 2019 Share Posted June 5, 2019 (edited) Persistent in programming means an object being retained in memory indefinitely. (The Reference can't be deleted.) Papyrus NULL is none, so use none. Edited June 6, 2019 by Rasikko Link to comment Share on other sites More sharing options...
Recommended Posts