Server Help

Bot Questions - LVZ toggling with mervbot

Maverick - Thu Jun 02, 2005 4:39 pm
Post subject: LVZ toggling with mervbot
I thought lately someone had updated the lvz toggling of Mervbot because it didn't work (it crashed the bot). Now it doesn't crash the bot but it doesn't toggle the right objects.

Here is some more detailed information:

I try to toggle the following objects:
Code: Show/Hide
8:BOT>Mavbot> +123
8:BOT>Mavbot> +138
8:BOT>Mavbot> +142
8:BOT>Mavbot> +150


And what I get is (from the console):
Code: Show/Hide
BOT>Mavbot  Object number 123 enabled
BOT>Mavbot  Object number 19917 disabled
BOT>Mavbot  Object number 138 enabled
BOT>Mavbot  Object number 19917 disabled


I'm pretty sure I am using the right methods in the right way with the right numbers.

Someone has the same problem or can help me fix this?

EDIT: Yes, I'm using the latest core sa_tongue.gif
Muskrat - Thu Jun 02, 2005 5:28 pm
Post subject:
What method are you using?
Code: Show/Hide
   queue_enable(id);
   toggle_objects();

Works for me, make sure your max objects is high enough for it.

Or even this works.
Code: Show/Hide
   objectInfo oi;
   oi.id = objid;
   oi.disabled = 0;
   tell(makeToggleObjects(UNASSIGNED,(Uint16 *)&oi,1));

Solo Ace - Thu Jun 02, 2005 8:56 pm
Post subject:
objoff(Maverick);
Muskrat - Thu Jun 02, 2005 9:17 pm
Post subject:
LvzObject SoloAce;
SoloAce.change_layer = 1;
Soloace.Layer = LAYER_BelowAll;
Solo Ace - Thu Jun 02, 2005 9:20 pm
Post subject:
Wow you really suck at this, where does the "Soloace" come from?
Muskrat - Thu Jun 02, 2005 9:24 pm
Post subject:
From my shift key sucking, I was going to edit it but you beat me
Solo Ace - Thu Jun 02, 2005 9:24 pm
Post subject:
I knew you were gonna try to, haha, easy. sa_tongue.gif
CypherJF - Thu Jun 02, 2005 10:28 pm
Post subject:
Comon guys, Solo, please stop spaming the forums with useless chit-chat that doesn't have anything to do w/ solving the issue presented. I have put up w/o saying anything over the past couple days but it's becoming very irritating and I'd appreciate it if you'd only post messages that would help aid in a solution. I mean I know this is all in the name of fun and whatnot but it's getting old.
Maverick - Fri Jun 03, 2005 2:41 am
Post subject:
how odd.. Yes i'm using the correct methods "queue_enable()" and "toggle_objects()".
The queue_enable methods are used inside a for loop, the chat output tells me that that is working ok.

I will try this evening in a clean plugin again. Might it be caused by me using an older tutorial plugin?
Muskrat - Fri Jun 03, 2005 2:44 am
Post subject:
Care to post your code?
Maverick - Fri Jun 03, 2005 2:55 am
Post subject:
Sure, I will do this evening because I'm at work right now.
Solo Ace - Fri Jun 03, 2005 4:26 am
Post subject:
You could've said it earlier, Cypher. sa_tongue.gif

I don't think you should let anything happening here get to you; But if it's really so irritating for you I'll just take it easy with the nonsense, and FOCUS ON THE REAL BUSINESS.

Couldn't you just do sendPublic("*objon ..."); ? sa_tongue.gif Guess not.
Maverick - Fri Jun 03, 2005 4:36 am
Post subject:
Seems like you don't know the difference, Solo Ace.
Solo Ace - Fri Jun 03, 2005 4:52 am
Post subject:
I'm sure I knew it when I was trying to figure out how it worked, "Maverick".
I can think of a bunch of things it would do, but whatever, my question wasn't serious as you could see.
D1st0rt - Fri Jun 03, 2005 1:05 pm
Post subject:
I tried using the object packets a while ago in a plugin, and I used the proper syntax, but it didn't seem to work. I ended up just making a macro for objons and objoffs sa_tongue.gif
Maverick - Fri Jun 03, 2005 2:14 pm
Post subject:
Well you should always use *objset above *objon and *objoff sa_tongue.gif

ok here is my code that I use:
Code: Show/Hide

void botInfo::updateLVZ(String jackpot) {
   //First turn off old lvz
   String oldjp = String(jp),tmp;
   int len = 8-oldjp.len;
   int i =0;
   if(jp>0) {
      for(i=0;i<oldjp.len;i++) {
         //sendPublic("*objoff 1"+String(i+1+len)+String(oldjp[i]-48));
         tmp = "1"+String(i+1+len)+String(oldjp[i]-48);
         queue_disable(atoi(tmp));
         sendChannel("-1"+String(i+1+len)+String(oldjp[i]-48));
      }
   }


   //Then turn on new lvz   
   len = 8-jackpot.len;
   for(i=0;i<jackpot.len;i++) {
      //sendPublic("*objon 1"+String(i+1+len)+String(jackpot[i]-48));
      tmp = "1"+String(i+1+len)+String(jackpot[i]-48);
      queue_enable(atoi(tmp));
      sendChannel("+1"+String(i+1+len)+String(jackpot[i]-48));
   }

   //Apply the lvz changes
   toggle_objects();
}


The function is called with f.ex:
Code: Show/Hide
updateLVZ("3820");

Mr Ekted - Fri Jun 03, 2005 3:10 pm
Post subject:
You should really be using the binary packet for this. Sending so much text is a waste of bandwidth.
Maverick - Fri Jun 03, 2005 3:51 pm
Post subject:
Doesn't Mervbot do that with the toggle_objects(); methods?
Muskrat - Fri Jun 03, 2005 4:52 pm
Post subject:
Mav, make sure your MAX_OBJECTS in spawn.h is higher than 16, it was 1 on old plugin versions because Ctm .37 only allowed toggling 1 object at a time. You are trying to toggle up to 16 at once.
Maverick - Fri Jun 03, 2005 5:12 pm
Post subject:
Raised it to 255, still same problem.

Also, max lvz number doesn't explain how it disables object numbers 19917. Seems like a bug to me.
Does someone know where the code is located that actually does tell(makeToggleObjects()) ?

BTW. Have the same problem in another, similar plugin.
Purge - Fri Jun 03, 2005 5:38 pm
Post subject:
Try and look in clientprot.h.
Muskrat - Fri Jun 03, 2005 5:49 pm
Post subject:
Code: Show/Hide
clientMessage *generateObjectToggle      (Uint16 player, objectInfo *objects, Uint16 num_objects)
{   clientMessage *ret = new clientMessage(4 + 2 * num_objects);
   if (ret == NULL) return NULL;
   char *msg = ret->msg;

   /*   Field   Length   Description
      0      1      Type byte: 0x0a
      1      2      Player ident (-1 = all players)
      3      1      LVZ type byte: 0x35
   The following are repeated until the end of the message
      4      2      LVZ bitfield
   */

   msg[0] = 0x0a;
   *(Uint16*)&msg[1] = player;
   msg[3] = 0x35;

   memcpy(msg + 4, objects, 2 * num_objects);

   return ret;
}


also
Code: Show/Hide
void botInfo::toggle_objects()
{
   Player *p = object_dest;

   if (!p)   tell(makeToggleObjects(UNASSIGNED, (Uint16 *)object_array, num_objects));
   else   tell(makeToggleObjects(p->ident, (Uint16 *)object_array, num_objects));

   num_objects = 0;
}

void botInfo::queue_enable(int id)
{
   if (num_objects == MAX_OBJECTS)
      toggle_objects();

   object_array[num_objects].id = id;
   object_array[num_objects].disabled = false;
   ++num_objects;
}


If its going to send the same amount of object queues each time, I'd suggest making MAX_OBJECTS that number, then you wont even need the toggle_objects() in yours.
Underlord - Fri Jun 03, 2005 6:00 pm
Post subject:
looks like the bug from old core/spawn.h

the bug dealt with the union objectInfo incorrectly set. compare your spawn.h and clientprot.h to this...

Code: Show/Hide

union objectInfo
{
   struct
   {
      Uint16 id            : 15;   // Object ident
      Uint16 disabled         : 1;   // 1=off, 0=on
   };

   Uint16 n;
};

#define MAX_OBJECTS 20

Maverick - Sat Jun 04, 2005 10:49 am
Post subject:
Woo biggrin.gif Got the problem solved.

Seems like I was using older tutorial code as a base - especially spawn.h. I replaced all code with the newest from the tutorial bot from catid.ssihosting.com and it works now grav_cool-hands.gif

Thanks alot for helping me, guys icon_wink.gif
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group