Page 1 of 1

Need some help with function please

Posted: Thu Dec 08, 2011 8:15 pm
by dragon slayer
Okay here is what i got so far

Code: Select all

function onDropItemOnNpc( pDropper, pDroppedOn, iDropped )
{
  pDroppedOn.TurnToward( pDropper ); 
  var taskLevel = pDropper.GetTag( "IT_LEVEL" ); 
  if( taskLevel ) 
  { 
    var numToGet = pDropper.GetTag( "IT_numToGet" ); 
    if( numToGet > 0)
    {
        var myGump = new Gump; // create a new gump  

        myGump.AddPage(0);
        myGump.AddBackground( 0, 0, 400, 350, 0xA28 );
        myGump.AddBackground( 30, 115, 350, 170, 0x0bb8 );
        myGump.AddGump( 130, 20, 0x64 ); // Sign Image
        myGump.AddText( 150, 30, 0, "Kill Task" );
        myGump.AddText( 180, 60, 0, "Unfinished" );
        myGump.AddText( 82, 120, 0, "Alas, you still have "+NumToString( numToGet )+" more" );
        myGump.AddText( 30, 140, 0, "to get before you receive your reward!" );
        myGump.AddText( 35, 300, 0, "Keep Going" );
        myGump.AddText( 160, 300, 0, "Quite" );
        myGump.AddButton( 200, 300, 0x0fa5, 1, 0, 2 ); //quite
        myGump.AddButton( 100, 300, 0x0fa5, 1, 0, 3 ); // keep going
        myGump.Send( pDropper ); // send this gump to client now 
        myGump.Free(); // clear this gump from uox-memory 
        return 0; 
    }
    else
    {
      if(iDropped = 0x0f78);
      {
       pDroppedOn.TextMessage( "Wonderful work my friend, here is your reward." ); 
       var goldToGive = 0; 
       switch( taskLevel ) 
       { 
       case 1:      goldToGive = 500;      break; 
       case 2:      goldToGive = 1000;      break; 
       case 3:      goldToGive = 2000;      break; 
       case 4:      goldToGive = 4000;      break; 
       } 
       CreateDFNItem( pDropper.socket, pDropper, "0x0EED", goldToGive, "ITEM", true ); 
       pDropper.SoundEffect( 0x0037, false ); 
       pDropper.SetTag( "IT_numToGet", 0 ); 
       pDropper.SetTag( "IT_IDTOGET", 0 ); 
       pDropper.SetTag( "IT_LEVEL", 0 );
       return 1;
      }
    }
  }
     pDroppedOn.TextMessage( "thats not the item I'm looking for." );
     return 0;
}
say player A gets 7 buttnuggets and i need to him to return to the quest person well i got it where checks for the ID of the item but how do i get it make it remove 7 buttnuggests when player drops on npc?

Posted: Thu Dec 08, 2011 8:31 pm
by Xuri
Hm. One way would be to do return 0 to drop the item back into the player's inventory, then use pUser.UseResource( #, 0x0f78 ) to remove the number of items (#) you want the player to "give" to the NPC.

Posted: Thu Dec 08, 2011 8:54 pm
by dragon slayer
aw thank you hehe i guess i wasnt to far off i keep forgeting we have useresource