View unanswered posts | View active topics
|
Page 1 of 1
|
[ 7 posts ] |
|
| Author |
Message |
|
Poi
|
Post subject: When demolishing a house Posted: Mon Jul 07, 2008 11:15 pm |
|
Joined: Fri Apr 14, 2006 9:36 am Posts: 240
|
I made a little code so that when someone has a certain item in their house, and they demolish their house, it *should* destroy the item and create the deed used to make the item where that item was. but it doesn't.
Any ideas what is wrong?
I added this code
Code: if(GetObjProperty(thing, "objtype") == 0x10) DestroyItem(thing); var watt := CreateItemAtLocation(thing.x, thing.y, thing.z, 0x5abc, 1); endif in this section Code: function demolish(house)
var lists := GetObjProperty(house, "footage"); var itemlist := {}; foreach entry in lists foreach thing in ListObjectsInBox(entry[1], entry[2], entry[3], entry[4], entry[5],entry[6]) itemlist.append(thing); endforeach endforeach var chk; var builtdeed := GetObjProperty(house, "builtdeed"); if(builtdeed) if(!DestroyItem(SystemFindObjectBySerial(builtdeed))) DestroyItem(SystemFindObjectBySerial(builtdeed, 1)); endif endif foreach thing in itemlist if(GetObjProperty(thing, "objtype") == 0x10) DestroyItem(thing); var watt := CreateItemAtLocation(thing.x, thing.y, thing.z, 0x5abc, 1); endif if(GetObjProperty(thing, "houseserial") == house.serial) if ((GetObjProperty(thing, "secure") == 1) && (thing.movable == 0)) EraseObjProperty(thing, "secure"); if(GetObjProperty(thing, "houseserial" ) == house.serial) var oldscript := GetObjProperty(thing, "oldscript"); if (oldscript == error) oldscript := ""; endif thing.usescript := oldscript; thing.movable := 1; EraseObjProperty(thing, "houseserial" ); EraseObjProperty(thing, "oldscript" ); endif elseif ((GetObjProperty(thing, "lockeddown" ) == 1) && (thing.movable == 0)) thing.movable := 1; EraseObjProperty(thing, "houseserial"); EraseObjProperty(thing, "lockeddown"); elseif (thing.movable == 0) if(thing.objtype == 0xa390) MoveItemToLocation(thing, thing.x, thing.y, (thing.z - 7), MOVEITEM_FORCELOCATION); else DestroyItem(thing); endif endif endif endforeach DestroyMulti(house ); return; endfunction
|
|
| Top |
|
 |
|
ncrsn
|
Post subject: Posted: Tue Jul 08, 2008 1:09 am |
|
Joined: Fri Feb 10, 2006 12:15 am Posts: 223
|
|
Well, after you destroy the thing there's no longer going to be usable x, y and z members.
Try creating the new item before and destroying the thing after.
|
|
| Top |
|
 |
|
Poi
|
Post subject: Posted: Tue Jul 08, 2008 9:14 am |
|
Joined: Fri Apr 14, 2006 9:36 am Posts: 240
|
|
Hmm, that doesn't seem to be the problem as ingame when tested, either way(destroy before or after) they both leave the original item in a non-locked down form(movable) and no deed =/
|
|
| Top |
|
 |
|
CWO
|
Post subject: Posted: Tue Jul 08, 2008 11:07 am |
|
Joined: Sat Feb 04, 2006 5:49 pm Posts: 770 Location: Chicago, IL USA
|
|
is it possible that its because you're doing GetObjProperty(thing, "objtype") == 0x10 instead of thing.objtype == 0x10 ?
|
|
| Top |
|
 |
|
Poi
|
Post subject: Posted: Tue Jul 08, 2008 8:37 pm |
|
Joined: Fri Apr 14, 2006 9:36 am Posts: 240
|
|
Ill try at our next shard restart, thanks.
|
|
| Top |
|
 |
|
Poi
|
Post subject: Posted: Tue Jul 08, 2008 11:29 pm |
|
Joined: Fri Apr 14, 2006 9:36 am Posts: 240
|
|
| Top |
|
 |
|
Pierce
|
Post subject: Posted: Wed Jul 09, 2008 11:34 am |
|
Joined: Thu Feb 02, 2006 8:33 am Posts: 296
|
A very simple way to find self made errors in your own script is to put in some kind of output of especially the variables. I do this normally on my test server with the simple broadcast command. Sure there are other ways
I just make a suggestion what i would do with your script, because we all don't know what e.g. the cprop "footage" look like.
Perhaps you find the error that way or could at least give us the results:
Code: function demolish(house)
var lists := GetObjProperty(house, "footage"); broadcast("footage: " + lists); var itemlist := {}; foreach entry in lists foreach thing in ListObjectsInBox(entry[1], entry[2], entry[3], entry[4], entry[5],entry[6]) itemlist.append(thing); endforeach endforeach broadcast("itemlist size: " + itemlist.size()); var chk; var builtdeed := GetObjProperty(house, "builtdeed"); if(builtdeed) if(!DestroyItem(SystemFindObjectBySerial(builtdeed))) DestroyItem(SystemFindObjectBySerial(builtdeed, 1)); endif endif foreach thing in itemlist broadcast("Test 1"); if(GetObjProperty(thing, "objtype") == 0x10) broadcast("Test 2"); DestroyItem(thing); var watt := CreateItemAtLocation(thing.x, thing.y, thing.z, 0x5abc, 1); endif if(GetObjProperty(thing, "houseserial") == house.serial) if ((GetObjProperty(thing, "secure") == 1) && (thing.movable == 0)) EraseObjProperty(thing, "secure"); if(GetObjProperty(thing, "houseserial" ) == house.serial) var oldscript := GetObjProperty(thing, "oldscript"); if (oldscript == error) oldscript := ""; endif thing.usescript := oldscript; thing.movable := 1; EraseObjProperty(thing, "houseserial" ); EraseObjProperty(thing, "oldscript" ); endif elseif ((GetObjProperty(thing, "lockeddown" ) == 1) && (thing.movable == 0)) thing.movable := 1; EraseObjProperty(thing, "houseserial"); EraseObjProperty(thing, "lockeddown"); elseif (thing.movable == 0) if(thing.objtype == 0xa390) MoveItemToLocation(thing, thing.x, thing.y, (thing.z - 7), MOVEITEM_FORCELOCATION); else DestroyItem(thing); endif endif endif endforeach DestroyMulti(house ); return; endfunction
|
|
| Top |
|
 |
|
Page 1 of 1
|
[ 7 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 0 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|