Advertisement
Guest User

ShowVend

a guest
Mar 1st, 2016
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.44 KB | None | 0 0
  1. Index: src/map/clif.c
  2. ===================================================================
  3. --- src/map/clif.c  (revision 1177)
  4. +++ src/map/clif.c  (working copy)
  5. @@ -3947,6 +3947,8 @@
  6.                 clif_specialeffect_single(bl,423,sd->fd);
  7.             else if( nd->size == 1 )
  8.                 clif_specialeffect_single(bl,421,sd->fd);
  9. +         if( nd->vend.vends == true )
  10. +        clif_showvendingboard( &nd->bl, nd->vend.vending, sd->fd );
  11.         }
  12.         break;
  13.     case BL_MOB:
  14. Index: src/map/npc.h
  15. ===================================================================
  16. --- src/map/npc.h   (revision 1177)
  17. +++ src/map/npc.h   (working copy)
  18. @@ -63,6 +63,12 @@
  19.             unsigned short mapindex; // destination map
  20.         } warp;
  21.     } u;
  22. +
  23. +  struct {
  24. +  char vending[NAME_LENGTH+1]; //vending name
  25. +  bool vends; //does he vend?
  26. +  } vend;
  27. +
  28.  };
  29. Index: src/map/script.c
  30. ===================================================================
  31. --- src/map/script.c    (revision 1177)
  32. +++ src/map/script.c    (working copy)
  33. @@ -15527,6 +15527,50 @@
  34.     return 0;
  35.  }
  36.  
  37. +  BUILDIN_FUNC( showvend ) {
  38. +  struct npc_data *nd;
  39. +  const char * message;
  40. +  const char * name;
  41. +  unsigned char buf[NAME_LENGTH+1];
  42. +  int flag;
  43. +
  44. +  name = script_getstr( st, 2 );
  45. +  flag = script_getnum( st, 3 );
  46. +
  47. +    if( flag && !script_hasdata( st, 4 ) ) {
  48. +    ShowError( "showvend: want to create vendingboard without name.\n" );
  49. +    script_reportsrc( st );
  50. +    st->state = END; //Script stops
  51. +    return -1;
  52. + }
  53. +    else if( flag )
  54. +    message = script_getstr( st, 4 );
  55. +
  56. +    nd = npc_name2id( name );
  57. +
  58. +    if( nd == NULL ) {
  59. +    ShowError( "showvend: no npc found!\n" );
  60. +    script_pushint( st, 0 ); //Fail return 0
  61. +    return 0;
  62. + }
  63. +
  64. +  switch( flag ) {
  65. +  case 0:
  66. +  clif_closevendingboard( &nd->bl, 0 );
  67. +  nd->vend.vends = false;
  68. +  break;
  69. +  default:
  70. +  memcpy( buf, message, NAME_LENGTH + 1 );
  71. +  clif_showvendingboard( &nd->bl, buf, 0 );
  72. +  nd->vend.vends = true;
  73. +  memcpy( nd->vend.vending, message, NAME_LENGTH + 1 );
  74. +  break;
  75. +  }
  76. +
  77. +  script_pushint( st, 1 ); //Success return 1
  78. +  return 0;
  79. + }
  80. +
  81.  /*==========================================
  82.   * Custom Fonts
  83.   *------------------------------------------*/
  84. @@ -16283,5 +16401,6 @@
  85.      //brAthena Modificações
  86.     BUILDIN_DEF(sc_check,"i"),
  87.     BUILDIN_DEF(makerune,"i"),
  88. +   BUILDIN_DEF(showvend, "si?" ), 
  89.     {NULL,NULL,NULL},
  90.  };
  91. Index: src/map/vending.c
  92. ===================================================================
  93. --- src/map/vending.c   (revision 1177)
  94. +++ src/map/vending.c   (working copy)
  95. @@ -15,6 +15,7 @@
  96.  #include "skill.h"
  97.  #include "battle.h"
  98.  #include "log.h"
  99. +#include "npc.h"
  100.  
  101.  #include <stdio.h>
  102.  #include <string.h>
  103. @@ -47,7 +48,24 @@
  104.  void vending_vendinglistreq(struct map_session_data* sd, int id)
  105.  {
  106.     struct map_session_data* vsd;
  107. +   struct npc_data *nd_sd;
  108.     nullpo_retv(sd);
  109. +  
  110. +if( nd_sd = (TBL_NPC*) map_id2bl( id ) ) { //It's an NPC
  111. +   if( nd_sd->vend.vends == true ) {
  112. +   char event_name[64 + 23 + 1];
  113. +     if( nd_sd->subtype == CASHSHOP ) //Act as if it was clicked
  114. +     npc_click( sd, nd_sd );
  115. +if( nd_sd->subtype == SHOP ) //Open Buy-Windows directly
  116. +     npc_buysellsel( sd, nd_sd->bl.id, 0 );
  117. +if( nd_sd->subtype == SCRIPT ) { //Trigger OnVendingClick event
  118. +     sprintf( event_name, "%s::OnVendingClick", &nd_sd->name );
  119. +     npc_event( sd, event_name, 0 );
  120. + return;
  121. + }
  122. + }
  123. + return; //WARP will just return
  124. + }
  125.  
  126.     if( (vsd = map_id2sd(id)) == NULL )
  127.         return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement