PenUltima Online

It is currently Wed Aug 20, 2008 9:58 am

All times are UTC - 4 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: vender script help
PostPosted: Fri Jan 25, 2008 12:41 am 
Offline

Joined: Fri Apr 14, 2006 1:36 pm
Posts: 240
Im editing the vendor deed script so that you can place on specific tiles and name your vendor whatever, but im having issues..
My script so far:
Code:
use os;
use uo;
include "include/canAccess";
include "include/attributes";
var text :=;
const SEARCH_RANGE := 10;

program makevendor(who, deed)
  EraseObjProperty(who, "IsMeditating");
  EraseObjProperty(who, "HealTimer");
  if(!can_access(who, deed))
    return;
  endif
  if(!ReserveItem(deed))
    return;
  endif
  var place;

foreach static in (ListStaticsAtLocation(who.x, who.y, who.z, ITEMS_IGNORE_MULTIS, who.realm))
   var value := static.objtype;
   if(static.z == who.z)
      if(value == 0x4F6)
         var sign;
         place := CreateNpcFromTemplate("playervendor", who.x, who.y, who.z);
         if(!place)
            SendSysMessage( who, "Your vendor has not been created");
            return;
         else
            text := RequestInput(who,who.backpack,"What would you like to name your vendor?");
            SendSysMessage(who, "You have successfully created a vendor");
            SetObjProperty(place, "master", who.serial);
            SetObjProperty(place, "mn", who.name);
            SetObjProperty(place, "r", 1500);
            SetName(place, text + " (" + who.name + ")");
            if(!DestroyItem(deed))
               RevokePrivilege(place, "invul");
               SetObjProperty(place, "guardkill", 1);
               ApplyRawDamage(place, (GetHp(place) + 5));
            endif
         exit;
      endif
   endif
endforeach

       var sign;
    place := CreateNpcFromTemplate("playervendor", who.x, who.y, who.z);
    if(!place)
      SendSysMessage( who, "Your vendor has not been created");
      return;
    else
   text := RequestInput(who,who.backpack,"What would you like to name your vendor?");


      SendSysMessage(who, "You have successfully created a vendor");
      SetObjProperty(place, "master", who.serial);
      SetObjProperty(place, "mn", who.name);
      SetObjProperty(place, "r", 1500);
   if (text)
   SetName(place, text + " (" + who.name + ")");
   endif
      if(!DestroyItem(deed))
        RevokePrivilege(place, "invul");
        SetObjProperty(place, "guardkill", 1);
        ApplyRawDamage(place, (GetHp(place) + 5));
      endif


  if(who.multi.serial)
    var multi := who.multi;
    var sign;
    foreach thing in (multi.components)
      if(thing.objtype == 0xbd2)
        sign := thing;
        break;
      endif
    endforeach
    if(!sign)
      SendSysMessage(who, "You cannot place a vendor here.");
      return;
    endif
    if(!GetObjProperty(sign, "Public"))
      SendSysMessage(who, "You can only place vendors in public houses.");
      return;
    endif
    place := CreateNpcFromTemplate("playervendor", who.x, who.y, who.z);
    if(!place)
      SendSysMessage( who, "Your vendor has not been created");
      return;
    else
      SendSysMessage(who, "You have successfully created a vendor");
      SetObjProperty(place, "master", who.serial);
      SetObjProperty(place, "mn", who.name);
      SetObjProperty(place, "r", 1500);
      if(!DestroyItem(deed))
        RevokePrivilege(place, "invul");
        SetObjProperty(place, "guardkill", 1);
        ApplyRawDamage(place, (GetHp(place) + 5));
      endif
    endif
  else
   SendSysMessage( who, "You cannot place your vendor here");
   return;
  endif
endprogram


Error:

Quote:
C:\pol096\scripts>ecompile -a
EScript Compiler v1.05
Copyright (C) 1994-2007 Eric N. Swanson

Compiling: ../scripts/items/vendorDeed.src
Unhandled reserved word: endforeach
Error compiling statement at C:\pol096\scripts\items\vendorDeed.src, Line 43
Error in IF statement starting at File: C:\pol096\scripts\items\vendorDeed.src,
Line 21
Error compiling statement at C:\pol096\scripts\items\vendorDeed.src, Line 21
Error compiling statement at C:\pol096\scripts\items\vendorDeed.src, Line 19
Error detected in program body.
Error occurred at C:\pol096\scripts\items\vendorDeed.src, Line 43
Execution aborted due to: Error compiling file

C:\pol096\scripts>

No idea what im doin wrong..


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 25, 2008 5:49 am 
Offline

Joined: Fri Aug 25, 2006 12:06 pm
Posts: 11
can you try to close if statement whit endif after or before exit; instruction

Code:

else
   text := RequestInput(who,who.backpack,"What would you like to name your vendor?");
   SendSysMessage(who, "You have successfully created a vendor");
   SetObjProperty(place, "master", who.serial);
   SetObjProperty(place, "mn", who.name);
   SetObjProperty(place, "r", 1500);
   SetName(place, text + " (" + who.name + ")");
   if(!DestroyItem(deed))
     RevokePrivilege(place, "invul");
     SetObjProperty(place, "guardkill", 1);
     ApplyRawDamage(place, (GetHp(place) + 5));
   endif
endif
   exit;


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 25, 2008 9:31 am 
Offline

Joined: Fri Apr 14, 2006 1:36 pm
Posts: 240
cucciola3000 wrote:
can you try to close if statement whit endif after or before exit; instruction

Code:

else
   text := RequestInput(who,who.backpack,"What would you like to name your vendor?");
   SendSysMessage(who, "You have successfully created a vendor");
   SetObjProperty(place, "master", who.serial);
   SetObjProperty(place, "mn", who.name);
   SetObjProperty(place, "r", 1500);
   SetName(place, text + " (" + who.name + ")");
   if(!DestroyItem(deed))
     RevokePrivilege(place, "invul");
     SetObjProperty(place, "guardkill", 1);
     ApplyRawDamage(place, (GetHp(place) + 5));
   endif
endif
   exit;



Now it says
Quote:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\pol096\scripts>ecompile -a
EScript Compiler v1.05
Copyright (C) 1994-2007 Eric N. Swanson

Compiling: ../scripts/items/vendorDeed.src
Expected Unknown Token: (281,8) before endprogram
Error compiling statement at C:\pol096\scripts\items\vendorDeed.src, Line 48
Error detected in program body.
Error occurred at C:\pol096\scripts\items\vendorDeed.src, Line 104
Execution aborted due to: Error compiling file

C:\pol096\scripts>



Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 25, 2008 3:09 pm 
Offline
Distro Developer
User avatar

Joined: Fri Feb 10, 2006 12:08 pm
Posts: 305
Location: Myrtle Beach, South Carolina
This should work....

Code:
use os;
use uo;

include "include/attributes";

program MakeVendor(mobile, deed)

   EraseObjProperty(mobile, "IsMeditating");
   EraseObjProperty(mobile, "HealTimer");

   if ( mobile.Backpack != deed.Container )
      SendSysMessage(mobile, "Aborted. That item must be in your backpack.");
      return 0;
   endif

   if ( !ReserveItem(deed) )
      SendSysMessage(mobile, "Aborted. That item is already being used.");
      return 0;
   endif

   // code here to check to see if it's okay to create the
   // player vendor here. just return 0 if it's not okay.


   var player_vendor := CreateNpcFromTemplate("playervendor", mobile.x, mobile.y, mobile.z);

   if ( !player_vendor )
      SendSysMessage(mobile, "Unable to place vendor in that location.");
      return 0;
   endif

   var new_name := RequestInput(mobile, mobile.Backpack, "What would you like to name your vendor?");

   if ( !new_name )
      SendSysMessage(mobile, "Aborted.");
      KillMobile(player_vendor);
      return 0;
   endif

   if ( !DestroyItem(deed) )
      SendSysMessage(mobile, "Unable to create vendor.");
      KillMobile(player_vendor);
      return 0;
   else
      SendSysMessage(mobile, "You successfully placed your vendor.");
      SetObjProperty(player_vendor, "master", mobile.Serial);
      SetObjProperty(player_vendor, "mn", mobile.Name);
      SetObjProperty(player_vendor, "r", 1500);
      SetName(player_vendor, (new_name)+" (" + mobile.Name + ")");
      return 1;
   endif

endprogram

function KillMobile(mobile)

   RevokePrivilege(mobile, "invul");
   SetObjProperty(mobile, "guardkill", 1);
   ApplyRawDamage(mobile, (GetHp(mobile) + 5));
   return 1;

endfunction


future reference, this should be posted in Scripting Help forum along with core and scriptset(such as 095/096 distro) in the post. :D


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 25, 2008 6:05 pm 
Offline

Joined: Fri Apr 14, 2006 1:36 pm
Posts: 240
MontuZ wrote:
This should work....

Code:
use os;
use uo;

include "include/attributes";

program MakeVendor(mobile, deed)

   EraseObjProperty(mobile, "IsMeditating");
   EraseObjProperty(mobile, "HealTimer");

   if ( mobile.Backpack != deed.Container )
      SendSysMessage(mobile, "Aborted. That item must be in your backpack.");
      return 0;
   endif

   if ( !ReserveItem(deed) )
      SendSysMessage(mobile, "Aborted. That item is already being used.");
      return 0;
   endif

   // code here to check to see if it's okay to create the
   // player vendor here. just return 0 if it's not okay.


   var player_vendor := CreateNpcFromTemplate("playervendor", mobile.x, mobile.y, mobile.z);

   if ( !player_vendor )
      SendSysMessage(mobile, "Unable to place vendor in that location.");
      return 0;
   endif

   var new_name := RequestInput(mobile, mobile.Backpack, "What would you like to name your vendor?");

   if ( !new_name )
      SendSysMessage(mobile, "Aborted.");
      KillMobile(player_vendor);
      return 0;
   endif

   if ( !DestroyItem(deed) )
      SendSysMessage(mobile, "Unable to create vendor.");
      KillMobile(player_vendor);
      return 0;
   else
      SendSysMessage(mobile, "You successfully placed your vendor.");
      SetObjProperty(player_vendor, "master", mobile.Serial);
      SetObjProperty(player_vendor, "mn", mobile.Name);
      SetObjProperty(player_vendor, "r", 1500);
      SetName(player_vendor, (new_name)+" (" + mobile.Name + ")");
      return 1;
   endif

endprogram

function KillMobile(mobile)

   RevokePrivilege(mobile, "invul");
   SetObjProperty(mobile, "guardkill", 1);
   ApplyRawDamage(mobile, (GetHp(mobile) + 5));
   return 1;

endfunction


future reference, this should be posted in Scripting Help forum along with core and scriptset(such as 095/096 distro) in the post. :D



Sorry about it being in the wrong place but heres my code:
Code:
use os;
use uo;

include "include/attributes";

program MakeVendor(mobile, deed)

   EraseObjProperty(mobile, "IsMeditating");
   EraseObjProperty(mobile, "HealTimer");

   if ( mobile.Backpack != deed.Container )
      SendSysMessage(mobile, "Aborted. That item must be in your backpack.");
      return 0;
   endif

   if ( !ReserveItem(deed) )
      SendSysMessage(mobile, "Aborted. That item is already being used.");
      return 0;
   endif


foreach static in ListStaticsAtLocation(mobile.x, mobile.y, mobile.z, ITEMS_IGNORE_MULTIS, mobile.realm)
   var value := static.objtype;
   if(static.z == mobile.z)
      if(value != 0x4F6)
      return 0;
      endif
   endif
endforeach

   // code here to check to see if it's okay to create the
   // player vendor here. just return 0 if it's not okay.


   var player_vendor := CreateNpcFromTemplate("playervendor", mobile.x, mobile.y, mobile.z);

   if ( !player_vendor )
      SendSysMessage(mobile, "Unable to place vendor in that location.");
      return 0;
   endif

   var new_name := RequestInput(mobile, mobile.Backpack, "What would you like to name your vendor?");

   if ( !new_name )
      SendSysMessage(mobile, "Aborted.");
      KillMobile(player_vendor);
      return 0;
   endif

   if ( !DestroyItem(deed) )
      SendSysMessage(mobile, "Unable to create vendor.");
      KillMobile(player_vendor);
      return 0;
   else
      SetName(player_vendor, (new_name)+" (" + mobile.Name + ")");
      SendSysMessage(mobile, "You successfully placed your vendor.");
      SetObjProperty(player_vendor, "master", mobile.Serial);
      SetObjProperty(player_vendor, "mn", mobile.Name);
      SetObjProperty(player_vendor, "r", 1500);
      return 1;
   endif

endprogram

function KillMobile(mobile)

   RevokePrivilege(mobile, "invul");
   SetObjProperty(mobile, "guardkill", 1);
   ApplyRawDamage(mobile, (GetHp(mobile) + 5));
   return 1;

endfunction


And now they can place them anywhere


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 26, 2008 6:35 am 
Offline
Distro Developer
User avatar

Joined: Fri Feb 10, 2006 12:08 pm
Posts: 305
Location: Myrtle Beach, South Carolina
See what I did with your location check? Put it into a function, just return 0 if it's not a good location, return 1 if it is.

Code:
use os;
use uo;

include "include/attributes";

program MakeVendor(mobile, deed)

   EraseObjProperty(mobile, "IsMeditating");
   EraseObjProperty(mobile, "HealTimer");

   if ( mobile.Backpack != deed.Container )
      SendSysMessage(mobile, "Aborted. That item must be in your backpack.");
      return 0;
   endif

   if ( !ReserveItem(deed) )
      SendSysMessage(mobile, "Aborted. That item is already being used.");
      return 0;
   endif


   if ( !CanPlace(mobile) )
      SendSysMessage(mobile, "You cannot place a vendor here.");
      return 0;
   endif

   var player_vendor := CreateNpcFromTemplate("playervendor", mobile.x, mobile.y, mobile.z);

   if ( !player_vendor )
      SendSysMessage(mobile, "Unable to place vendor in that location.");
      return 0;
   endif

   var new_name := RequestInput(mobile, mobile.Backpack, "What would you like to name your vendor?");

   if ( !new_name )
      SendSysMessage(mobile, "Aborted.");
      KillMobile(player_vendor);
      return 0;
   endif

   if ( !DestroyItem(deed) )
      SendSysMessage(mobile, "Unable to create vendor.");
      KillMobile(player_vendor);
      return 0;
   else
      SetName(player_vendor, (new_name)+" (" + mobile.Name + ")");
      SendSysMessage(mobile, "You successfully placed your vendor.");
      SetObjProperty(player_vendor, "master", mobile.Serial);
      SetObjProperty(player_vendor, "mn", mobile.Name);
      SetObjProperty(player_vendor, "r", 1500);
      return 1;
   endif

endprogram

function CanPlace(mobile)

   foreach static in ListStaticsAtLocation(mobile.x, mobile.y, mobile.z, ITEMS_IGNORE_MULTIS, mobile.realm)
      if ( static.z == mobile.z )
         if( static.Objtype == 0x4F6 )
            return 1;
         endif
      endif
   endforeach

   return 0;

endfunction

function KillMobile(mobile)

   RevokePrivilege(mobile, "invul");
   SetObjProperty(mobile, "guardkill", 1);
   ApplyRawDamage(mobile, (GetHp(mobile) + 5));
   return 1;

endfunction


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 30, 2008 9:45 am 
Offline

Joined: Fri Apr 14, 2006 1:36 pm
Posts: 240
Alright, but now my problem is the part that is suppose to determine the tile i'm standing on does not work properly, any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 30, 2008 6:39 pm 
Offline
Distro Developer
User avatar

Joined: Fri Feb 10, 2006 12:08 pm
Posts: 305
Location: Myrtle Beach, South Carolina
The tile you want them to be standing, will it be static, maptile or just a regular world item that can be .created?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 4 hours


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl