Team gate new problem

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Team gate new problem

Post by Poi »

Ok here is my script:

Code: Select all

use uo;
program itemstone( who )
var items := EnumerateItemsInContainer(who.backpack);
var pack1 := who.backpack;
foreach thing in items
    if(thing.objtype = 0x99a1)
       	DestroyItem(0x99a1);
       	DestroyItem(0x99a2);
       	DestroyItem(0x99a3);
       	DestroyItem(0x99a4);
       	DestroyItem(0x99a5);
       	DestroyItem(0x99a6);
       	DestroyItem(0x99a7);
    else
	CreateItemInContainer (pack1, 0x99a1, 1); 
	CreateItemInContainer (pack1, 0x99a2, 1); 
	CreateItemInContainer (pack1, 0x99a3, 1); 
	CreateItemInContainer (pack1, 0x99a4, 1); 
	CreateItemInContainer (pack1, 0x99a5, 1); 
	CreateItemInContainer (pack1, 0x99a6, 1); 
	CreateItemInContainer (pack1, 0x99a7, 1); 
    endif
endforeach


endprogram

My problem: when i step on the gate, it create about 15 of each of these items(i know why) but im not sure how to stop it... Any help?

Note: I know why it creates around 15 of them, don't tell me.
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

hehe... also, DestroyItem needs a reference to the items... Meaning you need to find all of them in the pack before destroying them. You cant just put an objtype in there.
Gnafu
Grandmaster Poster
Posts: 136
Joined: Thu Feb 02, 2006 7:29 am

Post by Gnafu »

---- EDIT ----

Probably the correct version... :D

----- FIXED CODE -----

Code: Select all

use uo; 
program itemstone( who ) 
var wpcis:=GetObjProperty(who, "isin");

if(!wpcis) //the cprop does not exists, so the pc is out

var pack1 := who.backpack; 
local i;
var temp:=0x99a0;  // useless initialization
for (i:=1; i<=7; i:=i+1) 
      temp:=(0x99a0+i);
     CreateItemInContainer (pack1, temp, 1);    
endfor
SetObjProperty(who, "isin", 1);

else  // the pc is in

var items := EnumerateItemsInContainer(who.backpack); 
foreach thing in items 
    if( (thing.objtype >= 0x99a1) && (thing.objtype <= 0x99a7))
      DestroyItem(thing);
    endif;
endforeach 
EraseObjProperty( who, "isin" );

endif

endprogram
----- FIXED CODE -----
Last edited by Gnafu on Mon Jun 26, 2006 11:46 pm, edited 4 times in total.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Ill test it and get back to you, thanks for tying :)
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Its just a tad bit off from what i want, this one creates the items and when you go back thru deletes them and creates more, but i want it so when they go back thru it only deletes them
Gnafu
Grandmaster Poster
Posts: 136
Joined: Thu Feb 02, 2006 7:29 am

Post by Gnafu »

That script destroy or create the objects if they exists or not.
If exists more than one obj, it destroy only one.

If you tell me what does this script must help to do it will better for me to change it according to your wish...

Do you want a pg to have an object to use in a dng and then, when he comes back, destroy it?
And there must be only one ?

give me an example or something as:
"the pg have an empty backpack
he goes thru the gate and he receive an object to use in the zone
when he comes back he cannot bring back the object
so the script must destroy the object."

my questions will be:
"different pg can trade theese objects? or have more than one of each type?"
"how about come back thru with no objects?"
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

This is exactly what i want to do, i hopw you understand it:

Person goes thru the gate, gets a set of items to use for that zone, when he comes back thru the gate it just destroys those items so he doesnt have them anymore, but next time he comes thru he will get the items agian
Gnafu
Grandmaster Poster
Posts: 136
Joined: Thu Feb 02, 2006 7:29 am

Post by Gnafu »

Done.

I used a cprop to set the pc 'in' or 'out'.

Change the name of the cprop used if 'isin' is used in other scripts or you think 'djbethrstyhryh' , 'dtgdhg' or 'iujfndyb' are better :P

If the cprop exists, it means that the pc was in, so the script must destroy all the objects.
If the cprop doesn't exists, getobjproperty() returns an error, it means that the pc was out of the zone, so the script must create the items..

Probably in this way it will work but pay attention to some cases:

- The pc already have an object with that objtype
- The pc exit the zone without using the gate (rune, summon by staff..)

Bye bye
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\pol\scripts>ecompile.exe
EScript Compiler v1.03
Copyright (C) 1994-2003 Eric N. Swanson

Compiling: c:/pol/pkg/teamgates/itemstone.src
Your syntax frightens and confuses me.
Your syntax frightens and confuses me.
Error compiling statement at c:\pol\pkg\teamgates\itemstone.src, Line 2
Parse Error: Waaah!
Near: program itemstone( who )
File: c:\pol\pkg\teamgates\itemstone.src, Line 3
Execution aborted due to: Error compiling file

C:\pol\scripts>
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

post the code you used. Theres an error somehwere in it.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

use uo;
program itemstone( who )
var wpcis:=GetObjProperty(who, 'isin');

if(!wpcis) //the cprop does not exists, so the pc is out

var pack1 := who.backpack;
local i;
var temp:=0x99a0; // useless initialization
for (i:=1; i<=7; i:=i+1)
temp:=(0x99a0+i);
CreateItemInContainer (pack1, temp, 1);
endfor

else // the pc is in

var items := EnumerateItemsInContainer(who.backpack);
foreach thing in items
if( (thing.objtype >= 0x99a1) && (thing.objtype <= 0x99a7))
DestroyItem(thing);
endif;
endforeach
EraseObjProperty( who, 'isin' );

endif

endprogram
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

use double quotes instead of single quotes? "isin" instead of 'isin'
Gnafu
Grandmaster Poster
Posts: 136
Joined: Thu Feb 02, 2006 7:29 am

Post by Gnafu »

ooopppssss....

:lol:

Another hint...
I was thinking that probably you better set a region on the zone you want this script to run and attach that script on EnterScript and LeaveScript

Region TheFantasticZone
{
Range 1500 1500 1700 1700
Guarded 1
EnterText You receive some objects...
LeaveText You lost some objects...
Midi 9

EnterScript :coords:thezone
LeaveScript :coords:thezone
}

So you can also split the script in two (one for entering and one for leaving)
In this case you do not need to set a cprop on the pc
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

Thats 096 only though Gnafu for the EnterScript/LeaveScript. I think hes on 095.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\pol\scripts>ecompile.exe
EScript Compiler v1.03
Copyright (C) 1994-2003 Eric N. Swanson

Compiling: c:/pol/pkg/teamgates/itemstone.src
Your syntax frightens and confuses me.
Your syntax frightens and confuses me.
Error compiling statement at c:\pol\pkg\teamgates\itemstone.src, Line 2
Parse Error: Waaah!
Near: program itemstone( who )
File: c:\pol\pkg\teamgates\itemstone.src, Line 23
Execution aborted due to: Error compiling file

C:\pol\scripts>





Code: Select all

use uo;
program itemstone( who )
var wpcis:=GetObjProperty(who, "isin");

if(!wpcis) //the cprop does not exists, so the pc is out

var pack1 := who.backpack;
local i;
var temp:=0x99a0;  // useless initialization
for (i:=1; i<=7; i:=i+1)
      temp:=(0x99a0+i);
     CreateItemInContainer (pack1, temp, 1);   
endfor

else  // the pc is in

var items := EnumerateItemsInContainer(who.backpack);
foreach thing in items
    if( (thing.objtype >= 0x99a1) && (thing.objtype <= 0x99a7))
      DestroyItem(thing);
    endif;
endforeach
EraseObjProperty( who, 'isin' );

endif

endprogram 
Gnafu
Grandmaster Poster
Posts: 136
Joined: Thu Feb 02, 2006 7:29 am

Post by Gnafu »

Poi.... -_-'

there is another 'isin' to change...
the compiler tells you the point where the error is ("..line 23")

@CWO : Yep, I didn't remember which version he's using :P
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Sorry lmao, i was busy and dint bother to read it, just posted it.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Ok it still does not work, it creates it over and over no matter how many times you walk thru
Gnafu
Grandmaster Poster
Posts: 136
Joined: Thu Feb 02, 2006 7:29 am

Post by Gnafu »

:shock:
mmmm, tomorrow i will test it...
*thinking*
:mrgreen:
Burtonius

Post by Burtonius »

add this line before the else statment:

Code: Select all

SetObjProperty(who, "isin", 1);
that should fix his script
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Hey thanks alot, sorry it took me so long to get to this, ive been sort of.... uhm anyway, how would i make ti so it deletes it off thier body too?
Post Reply