Forums
Games
Cyberpunk 2077 Thronebreaker: The Witcher Tales GWENT®: The Witcher Card Game The Witcher 3: Wild Hunt The Witcher 2: Assassins of Kings The Witcher The Witcher Adventure Game
Jobs Store Support Log in Register
Forums - CD PROJEKT RED
Menu
Forums - CD PROJEKT RED
  • Hot Topics
  • NEWS
  • GENERAL
    THE WITCHER ADVENTURE GAME
  • STORY
    THE WITCHER THE WITCHER 2 THE WITCHER 3 THE WITCHER TALES
  • GAMEPLAY
    THE WITCHER THE WITCHER 2 THE WITCHER 3 MODS (THE WITCHER) MODS (THE WITCHER 2) MODS (THE WITCHER 3)
  • TECHNICAL
    THE WITCHER THE WITCHER 2 (PC) THE WITCHER 2 (XBOX) THE WITCHER 3 (PC) THE WITCHER 3 (PLAYSTATION) THE WITCHER 3 (XBOX) THE WITCHER 3 (SWITCH)
  • COMMUNITY
    FAN ART (THE WITCHER UNIVERSE) FAN ART (CYBERPUNK UNIVERSE) OTHER GAMES
  • RED Tracker
    The Witcher Series Cyberpunk GWENT
THE WITCHER
THE WITCHER 2
THE WITCHER 3
MODS (THE WITCHER)
MODS (THE WITCHER 2)
MODS (THE WITCHER 3)
Menu

Register

Destroy created objekt...

+
R

ralf1731

Senior user
#1
Oct 3, 2008
Destroy created objekt...

Ok - have a question and hope anybody can help:1. I write a script to create an objectstring sObject = "plc_object";int nHour = GetTimeHour();if (nHour == 7){CreateObject (OBJECT_TYPE_PLACEABLE, sObject, GetLocation(GetWaypointByTag("wp_object")), TRUE);}2. So far so good. But now in a defined time i want destroy that objectobject oObject = GetObjectByTag("plc_object");int nHour = GetTimeHour();if (nHour == 19){DestroyObject(oObject);}with an existing object it doesnt work, because the most have no tag.when i create my own placeable i can define a tag (f.E.: plc_object).but doesnt work either.
 
A

ailinon

Senior user
#2
Oct 4, 2008
Never even think of erasing posts, they're all valuable :)However, that millisecond-something script is very, very unstable: it works only on 19:xx:xx.000 hours - which might, even though there is 3600 of those in an hour, never happen: the script may fire on 19:01:12:998 and on 19:01:13:003, only a 5-millisecond gap, but enough to miss the 000 point.About the destroyed objects - you might either save the objects' references somewhere: SetLocalObject(GetModule(),"OBJECT_TO_DESTROY1",oObject);... or tag them when creating: CreateObject(OBJECT_TYPE_PLACEABLE,"template",GetLocation(...), TRUE, "delete_me"); // "delete_me" here is the new tag-- Sinus
 
R

ralf1731

Senior user
#3
Oct 5, 2008
@Ailinon the script may fire on 19:01:12:998 and on 19:01:13:003, only a 5-millisecond gap, but enough to miss the 000 point.
Click to expand...
I set first the "GetTimeMinute()", but create thousands of objects :-\ When there is an other option, i get them grateful.I tested the script several times and every time it works. The "destroy-command" can destroy the whole houre, if it want ;)But i know that every script slow down the game, so alternatives would be fine.
CreateObject(OBJECT_TYPE_PLACEABLE,"template",GetLocation(...), TRUE, "delete_me"); // "delete_me" here is the new tag
Click to expand...
Thanks. i didnt know it works in this way...Edit: I have not only one object, there are several to create and destroy. only for info.
 
A

ailinon

Senior user
#4
Oct 5, 2008
Well, to destroy more objects with a specified tag, use
Code:
object oObject;while ((oObject = GetObjectByTag("tag")) != OBJECT_INVALID)  // "as long as an object with 'tag' can be successfully found...  DestroyObject(oObject);  // kill it!
Warning, code typed 'by hand', untested. ;)-- Sinus
 
R

ralf1731

Senior user
#5
Oct 5, 2008
@Ailinon Warning, code typed 'by hand', untested.
Click to expand...
you are right, it doesnt work. Better is:while (GetIsObjectValid(oObject)){}Edit: Didnt work. Script create_obj, OID: 8000060c, Tag: , FEHLER: ZU VIELE ANWEISUNGEN. (Failure: Tu much orders.), Last Command Id: 68
 
N

nandusso

Senior user
#6
Oct 5, 2008
You want to create an object one time at 7 and destroy it at 19:void main(){ if ((GetTimeHour()==7)&&(GetLocalInt(GetFirstPC(),"new_obj")==0)) { CreateObject(OBJECT_TYPE_PLACEABLE,"template_name",GetLocation(GetWaypointByTag("wp_object")),TRUE,"delete_me"); SetLocalInt(GetFirstPC(),"new_obj",1); } if ((GetTimeHour()==19)&&(GetLocalInt(GetFirstPC(),"new_obj")==1)) { DestroyObject(GetObjectByTag("delete_me")); SetLocalInt(GetFirstPC(),"new_obj",0); }}At least I've understood it in this way.But who calls this script? If you put it in OnEnter of the area and then enter at 8..... :), you should modify to:if ((GetTimeHour()>6)&&(GetTimeHour()
 
R

ralf1731

Senior user
#7
Oct 5, 2008
@nandussovoid main(){
Click to expand...
 
N

nandusso

Senior user
#8
Oct 5, 2008
I've corrected my previous post: 19 instead of 8 :)If GetLocalInt doesn't work you can use GetDialogFlagValue and SetDialogFlagValue. But add the dialog flag into the file globaldlgflags.2da of your module.In the heartbeat should be fine, I don't suggest you to use the daily script of the objects for such things, I had some problems.Yes, each object needs a different tag.bye
 
R

ralf1731

Senior user
#9
Oct 5, 2008
thanks. :)
 
A

ailinon

Senior user
#10
Oct 6, 2008
And what "doesn't work" in my hand-typed code? It certainly compiles, and it definitely does remove all objects matching the specified tag. If your objects are not tagged... then it can't be helped. :)Nandusso,> Yes, each object needs a different tag.Nope, it doesn't. If they all have the same tag, my code above will get rid of them. But if they have NO tags... then it's a problem.-- Sinus
 
R

ralf1731

Senior user
#11
Oct 6, 2008
It doesnt compile.
 
N

nandusso

Senior user
#12
Oct 8, 2008
@ AilinonYou are right boss!!! ;D I've never thought to contradict you... :-XI was thinking on creating the objects one by one giving them a different tag, to know exactly, after, what you are destroing. @RALF1731I'm curious: could you post your script?.. because if it doesn't compile the game shouldn't load it!bye
 
R

ralf1731

Senior user
#13
Oct 8, 2008
nono - my script compiles fine. my sound doesnt play, thats the big prob ::)I know, that i slowly stress the nervs, but it cost me so much time, and no solution :whistle:
 
Share:
Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email Link
  • English
    English Polski (Polish) Deutsch (German) Русский (Russian) Français (French) Português brasileiro (Brazilian Portuguese) Italiano (Italian) 日本語 (Japanese) Español (Spanish)

STAY CONNECTED

Facebook Twitter YouTube
CDProjekt RED Mature 17+
  • Contact administration
  • User agreement
  • Privacy policy
  • Cookie policy
  • Press Center
© 2018 CD PROJEKT S.A. ALL RIGHTS RESERVED

The Witcher® is a trademark of CD PROJEKT S. A. The Witcher game © CD PROJEKT S. A. All rights reserved. The Witcher game is based on the prose of Andrzej Sapkowski. All other copyrights and trademarks are the property of their respective owners.

Forum software by XenForo® © 2010-2020 XenForo Ltd.