• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

NPC swich item [7.6]

Stefx

New Member
Joined
Apr 30, 2016
Messages
16
Reaction score
0
Hi,
I need help with script. Player should lose one selected item and get other (not cash).
I have DeadTouch 1.9 Engine - I know is old and TalkAction with command like AddPlayerItem/RemoveItem
are not working. Any one have idea how can I resolved this problem.
Here I attach some codes that I was trying test without effect

Lua:
if msgcontains(msg, 'present box') then
            talk_state = 1
                    selfSay('Do you have a suitable present box for me?')
            elseif talk_state == 1 then
             if (msgcontains(msg, 'yes')) then
            if (doPlayerRemoveItem(cid, 1990, 1)) then
            if (doPlayerAddItem(cid, 2480, 1)) then
                selfSay('Thanks!')
            else
                selfSay('Helmet is your reward!')
            end
        else
        selfSay('Sorry you do not have that item!')
        end
Here I got error "isItemStackable <nil value>"

I try also this code:

Lua:
(...)
if (msgcontains(msg, 'yes')) then
          sell(cid, 1990, 1, 0) 
           buy(cid, 2480, 1, 0) 
                selfSay('Thanks!')
(...)
Here the probelm is when I don't have first item with ID 1990 I allways got second with ID 2480.
How to set if first is not in my inventory then I will not get second ?
If you have any ideas how to solved this problem I will be grateful.
 
Your code doesn't seem to contain any isStackable line, sounds like either you didn't include that part of the code OR it is contained within a nother function meaning you are using one or more functions incorrectly in your code.


Also, why don't you program it like this:

if(doPlayerRemoveItem(cid, 1990, 1) and doPlayerAddItem(cid, 2480, 1)) then
selfSay("Thanks!")
else
selfSay("Helmet is your reward!")
end
  1. if (doPlayerRemoveItem(cid, 1990, 1)) then
  2. if (doPlayerAddItem(cid, 2480, 1)) then
  3. selfSay('Thanks!')
  4. else
  5. selfSay('Helmet is your reward!')
  6. end
  7. end
 
Code:
function creatureSayCallback(cid, type, msg)
    if(cid ~= npcHandler.focus) then
        return false
    end

    if msgcontains(msg, 'crystal') then
        npcHandler:say("Did you bring me a magic crystal?", 1)
        talk_state = 4
    elseif talk_state == 4 and msgcontains(msg, 'yes') then
        if getPlayerItemCount(cid, 2177) >= 1 then
            doPlayerRemoveItem(cid,2177, 1)
            doPlayerAddItem(cid,2168, 1)
            npcHandler:say("Make good use of it.", 1)
        else
            npcHandler:say("Humm... You don't have the crystal!", 1)
        end
    end       
    return true
end
 
Any of your tips not working, I did try with just remove item and also don't work. NPC work like he should, he even say "Thanks", engine don't show any error, but item is still on my inventory.
Lua:
        if msgcontains(msg, 'yes') then
             doPlayerRemoveItem(cid, 1990, 1)
            selfSay("Thanks!")

any ideas what also can be wrong ?
 
Do you have the source code to your server? If so, post luascript.cpp or any other Lua-related sheet
 
luascript.cpp
C++:
//////////////////////////////////////////////////////////////////////
// OpenTibia - an opensource roleplaying game
//////////////////////////////////////////////////////////////////////
// class which takes care of all data which must get saved in the player
//////////////////////////////////////////////////////////////////////
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//////////////////////////////////////////////////////////////////////


#include <string>
#include <iostream>

#include "luascript.h"
#include "player.h"

LuaScript::LuaScript()
{
  luaState = NULL;
}


LuaScript::~LuaScript()
{
  if (luaState)
      lua_close(luaState);
}


int LuaScript::OpenFile(const char *filename)
{
    luaState = lua_open();

    if (lua_dofile(luaState, filename))
        return false;
        ADVANCE_ANI = getGlobalString("animations") == "yes";
        EFFECT_ATACK = getGlobalString("extraeffects") == "yes";
        SUMMON_BODIES = getGlobalString("summonhavebody") == "yes";
        EXTRA_MSG_DEAD = getGlobalString("extradiemsg") == "yes";       
        MSG_DEAD = getGlobalString("diemsg") == "yes";
        DROP_RATE = getGlobalNumber("droprate",1);

#ifdef YUR_MULTIPLIERS
    EXP_MUL = getGlobalNumber("expmul",1);
    EXP_MUL_PVP = getGlobalNumber("expmulpvp",1);
    HEALTH_TICK_MUL = getGlobalNumber("healthtickmul",1);
    MANA_TICK_MUL = getGlobalNumber("manatickmul",1);
    ROHHEALTH = getGlobalNumber("RoHHealth",1);
    ROHMANA = getGlobalNumber("RoHMana",1);
    LIFERINGHEALTH = getGlobalNumber("LifeRingHealth",1);
    LIFERINGMANA = getGlobalNumber("LifeRingMana",1);
    DIVIDER = getGlobalNumber("DmgDivider",30);

    CAP_GAIN[VOCATION_NONE] = atoi(getGlobalStringField("capgain", VOCATION_NONE + 1, "10").c_str());
    CAP_GAIN[VOCATION_SORCERER] = atoi(getGlobalStringField("capgain", VOCATION_SORCERER + 1, "10").c_str());
    CAP_GAIN[VOCATION_DRUID] = atoi(getGlobalStringField("capgain", VOCATION_DRUID + 1, "10").c_str());
    CAP_GAIN[VOCATION_PALADIN] = atoi(getGlobalStringField("capgain", VOCATION_PALADIN + 1, "20").c_str());
    CAP_GAIN[VOCATION_KNIGHT] = atoi(getGlobalStringField("capgain", VOCATION_KNIGHT + 1, "25").c_str());

    MANA_GAIN[VOCATION_NONE] = atoi(getGlobalStringField("managain", VOCATION_NONE + 1, "5").c_str());
    MANA_GAIN[VOCATION_SORCERER] = atoi(getGlobalStringField("managain", VOCATION_SORCERER + 1, "30").c_str());
    MANA_GAIN[VOCATION_DRUID] = atoi(getGlobalStringField("managain", VOCATION_DRUID + 1, "30").c_str());
    MANA_GAIN[VOCATION_PALADIN] = atoi(getGlobalStringField("managain", VOCATION_PALADIN + 1, "15").c_str());
    MANA_GAIN[VOCATION_KNIGHT] = atoi(getGlobalStringField("managain", VOCATION_KNIGHT + 1, "5").c_str());

    HP_GAIN[VOCATION_NONE] = atoi(getGlobalStringField("hpgain", VOCATION_NONE + 1, "5").c_str());
    HP_GAIN[VOCATION_SORCERER] = atoi(getGlobalStringField("hpgain", VOCATION_SORCERER + 1, "5").c_str());
    HP_GAIN[VOCATION_DRUID] = atoi(getGlobalStringField("hpgain", VOCATION_DRUID + 1, "5").c_str());
    HP_GAIN[VOCATION_PALADIN] = atoi(getGlobalStringField("hpgain", VOCATION_PALADIN + 1, "10").c_str());
    HP_GAIN[VOCATION_KNIGHT] = atoi(getGlobalStringField("hpgain", VOCATION_KNIGHT + 1, "15").c_str());

    WEAPON_MUL[VOCATION_NONE] = atoi(getGlobalStringField("weaponmul", VOCATION_NONE+1, "1").c_str());
    WEAPON_MUL[VOCATION_SORCERER] = atoi(getGlobalStringField("weaponmul", VOCATION_SORCERER+1, "1").c_str());
    WEAPON_MUL[VOCATION_DRUID] = atoi(getGlobalStringField("weaponmul", VOCATION_DRUID+1, "1").c_str());
    WEAPON_MUL[VOCATION_PALADIN] = atoi(getGlobalStringField("weaponmul", VOCATION_PALADIN+1, "1").c_str());
    WEAPON_MUL[VOCATION_KNIGHT] = atoi(getGlobalStringField("weaponmul", VOCATION_KNIGHT+1, "1").c_str());

    DIST_MUL[VOCATION_NONE] = atoi(getGlobalStringField("distmul", VOCATION_NONE+1, "1").c_str());
    DIST_MUL[VOCATION_SORCERER] = atoi(getGlobalStringField("distmul", VOCATION_SORCERER+1, "1").c_str());
    DIST_MUL[VOCATION_DRUID] = atoi(getGlobalStringField("distmul", VOCATION_DRUID+1, "1").c_str());
    DIST_MUL[VOCATION_PALADIN] = atoi(getGlobalStringField("distmul", VOCATION_PALADIN+1, "1").c_str());
    DIST_MUL[VOCATION_KNIGHT] = atoi(getGlobalStringField("distmul", VOCATION_KNIGHT+1, "1").c_str());

    SHIELD_MUL[VOCATION_NONE] = atoi(getGlobalStringField("shieldmul", VOCATION_NONE+1, "1").c_str());
    SHIELD_MUL[VOCATION_SORCERER] = atoi(getGlobalStringField("shieldmul", VOCATION_SORCERER+1, "1").c_str());
    SHIELD_MUL[VOCATION_DRUID] = atoi(getGlobalStringField("shieldmul", VOCATION_DRUID+1, "1").c_str());
    SHIELD_MUL[VOCATION_PALADIN] = atoi(getGlobalStringField("shieldmul", VOCATION_PALADIN+1, "1").c_str());
    SHIELD_MUL[VOCATION_KNIGHT] = atoi(getGlobalStringField("shieldmul", VOCATION_KNIGHT+1, "1").c_str());

    MANA_MUL[VOCATION_NONE] = atoi(getGlobalStringField("manamul", VOCATION_NONE+1, "1").c_str());
    MANA_MUL[VOCATION_SORCERER] = atoi(getGlobalStringField("manamul", VOCATION_SORCERER+1, "1").c_str());
    MANA_MUL[VOCATION_DRUID] = atoi(getGlobalStringField("manamul", VOCATION_DRUID+1, "1").c_str());
    MANA_MUL[VOCATION_PALADIN] = atoi(getGlobalStringField("manamul", VOCATION_PALADIN+1, "1").c_str());
    MANA_MUL[VOCATION_KNIGHT] = atoi(getGlobalStringField("manamul", VOCATION_KNIGHT+1, "1").c_str());
#endif //YUR_MULTIPLIERS

#ifdef TR_ANTI_AFK
    KICK_TIME = getGlobalNumber("kicktime",15)*60000;
#endif //TR_ANTI_AFK

#ifdef YUR_LEARN_SPELLS
    LEARN_SPELLS = getGlobalString("learnspells") == "yes";
#endif //YUR_LEARN_SPELLS

#ifdef TLM_HOUSE_SYSTEM
    ACCESS_HOUSE = getGlobalNumber("accesshouse",3);
    MAX_HOUSE_TILE_ITEMS = getGlobalNumber("maxhousetileitems",10);
#endif //TLM_HOUSE_SYSTEM

#ifdef TR_SUMMONS
    SUMMONS_ALL_VOC = getGlobalString("summonsallvoc") == "yes";
    MAX_SUMMONS = (size_t)getGlobalNumber("maxsummons",2);
#endif //TR_SUMMONS

#ifdef TLM_SKULLS_PARTY
    HIT_TIME = getGlobalNumber("hittime",1)*60000;
    WHITE_TIME = getGlobalNumber("whitetime",15)*60000;
    RED_TIME = getGlobalNumber("redtime",5*60)*60000;
    FRAG_TIME = getGlobalNumber("fragtime",10*60)*60000;
    RED_UNJUST = getGlobalNumber("redunjust",3);
    BAN_UNJUST = getGlobalNumber("banunjust",6);
#endif //TLM_SKULLS_PARTY

#ifdef SD_BURST_ARROW
    BURST_DMG_LVL = atof(getGlobalStringField("burstarrowdmg", 1, "2.0").c_str());
    BURST_DMG_MLVL = atof(getGlobalStringField("burstarrowdmg", 2, "3.0").c_str());
    BURST_DMG_LO = atof(getGlobalStringField("burstarrowdmg", 3, "0.24").c_str());
    BURST_DMG_HI = atof(getGlobalStringField("burstarrowdmg", 4, "0.55").c_str());
#endif //SD_BURST_ARROW

#ifdef YUR_CONFIG_CAP
    CAP_SYSTEM = getGlobalString("capsystem") == "yes";
#endif //YUR_CONFIG_CAP

#ifdef BDB_REPLACE_SPEARS
    SPEAR_LOSE_CHANCE = getGlobalNumber("spearlosechance",50);
#endif //BDB_REPLACE_SPEARS

#ifdef YUR_PREMIUM_PROMOTION
    FREE_PREMMY = getGlobalString("freepremmy") == "yes";
    QUEUE_PREMMY = getGlobalString("queuepremmy") == "yes";
#endif //YUR_PREMIUM_PROMOTION

#ifdef YUR_CVS_MODS
    VOCATIONS[VOCATION_KNIGHT] = getGlobalStringField("vocations",VOCATION_KNIGHT);
    VOCATIONS[VOCATION_PALADIN] = getGlobalStringField("vocations",VOCATION_PALADIN);
    VOCATIONS[VOCATION_SORCERER] = getGlobalStringField("vocations",VOCATION_SORCERER);
    VOCATIONS[VOCATION_DRUID] = getGlobalStringField("vocations",VOCATION_DRUID);

    PROMOTED_VOCATIONS[VOCATION_KNIGHT] = getGlobalStringField("promoted_vocations",VOCATION_KNIGHT);
    PROMOTED_VOCATIONS[VOCATION_PALADIN] = getGlobalStringField("promoted_vocations",VOCATION_PALADIN);
    PROMOTED_VOCATIONS[VOCATION_SORCERER] = getGlobalStringField("promoted_vocations",VOCATION_SORCERER);
    PROMOTED_VOCATIONS[VOCATION_DRUID] = getGlobalStringField("promoted_vocations",VOCATION_DRUID);

    DIE_PERCENT_EXP = atoi(getGlobalStringField("diepercent",1,"7").c_str());
    DIE_PERCENT_MANA = atoi(getGlobalStringField("diepercent",2,"7").c_str());
    DIE_PERCENT_SKILL = atoi(getGlobalStringField("diepercent",3,"7").c_str());
    DIE_PERCENT_EQ = atoi(getGlobalStringField("diepercent",4,"7").c_str());
    DIE_PERCENT_BP = atoi(getGlobalStringField("diepercent",5,"100").c_str());

    ACCESS_PROTECT = getGlobalNumber("accessprotect",3);
    ACCESS_REMOTE = getGlobalNumber("accessremote",3);
    ACCESS_TALK = getGlobalNumber("accesstalk",3);
    ACCESS_ENTER = getGlobalNumber("accessenter",3);
    ACCESS_LOOK = getGlobalNumber("accesslook",3);

    EXHAUSTED = getGlobalNumber("exhausted",0);
    EXHAUSTED_ADD = getGlobalNumber("exhaustedadd",0);
    EXHAUSTED_HEAL = getGlobalNumber("exhaustedheal",0);

    PZ_LOCKED = getGlobalNumber("pzlocked",0);
    MAX_DEPOT_ITEMS = getGlobalNumber("maxdepotitem",1000);
    DATA_DIR = getGlobalString("datadir");
#endif //YUR_CVS_MODS

#ifdef JD_DEATH_LIST
    MAX_DEATH_ENTRIES = getGlobalNumber("maxdeathentries",10);
#endif //JD_DEATH_LIST

#ifdef JD_WANDS
    MANA_SNAKEBITE = atoi(getGlobalStringField("rodmana", 1, "2").c_str());
    MANA_MOONLIGHT = atoi(getGlobalStringField("rodmana", 2, "3").c_str());
    MANA_VOLCANIC = atoi(getGlobalStringField("rodmana", 3, "5").c_str());
    MANA_QUAGMIRE = atoi(getGlobalStringField("rodmana", 4, "8").c_str());
    MANA_TEMPEST = atoi(getGlobalStringField("rodmana", 5, "13").c_str());

    MANA_VORTEX = atoi(getGlobalStringField("wandmana", 1, "2").c_str());
    MANA_DRAGONBREATH = atoi(getGlobalStringField("wandmana", 2, "3").c_str());
    MANA_PLAGUE = atoi(getGlobalStringField("wandmana", 3, "5").c_str());
    MANA_COSMIC = atoi(getGlobalStringField("wandmana", 4, "8").c_str());
    MANA_INFERNO = atoi(getGlobalStringField("wandmana", 5, "13").c_str());
    ITEM_MDOWNHELMET = getGlobalNumber("MagicDmg_HELMET",20);
    ITEM_MDOWNARMOR = getGlobalNumber("MagicDmg_ARMOR",20);
    ITEM_MDOWNLEGS = getGlobalNumber("MagicDmg_LEGS",20);
    ITEM_MDOWNBOOTS = getGlobalNumber("MagicDmg_BOOTS",20);
    ITEM_MDOWNRING = getGlobalNumber("MagicDmg_RING",20);
    ITEM_MDOWNAMU = getGlobalNumber("MagicDmg_AMU",20);
    MGITEMHELMET = getGlobalNumber("ID_HELMET",0);
    MGITEMARMOR = getGlobalNumber("ID_ARMOR",0);
    MGITEMLEGS = getGlobalNumber("ID_LEGS",0);
    MGITEMBOOTS = getGlobalNumber("ID_BOOTS",0);
    MGITEMAMU = getGlobalNumber("ID_AMULET",0);
    MGITEMRINGS = getGlobalNumber("ID_RING",0);
    MGITEMS = getGlobalString("MGDMG_Items") == "yes";
    MGTYPE = getGlobalString("MGTYPE");
    SKILLNUMBER = getGlobalString("AdvanceSkill_ShowNumbers") == "yes";

    RANGE_SNAKEBITE = atoi(getGlobalStringField("rodrange", 1, "4").c_str());
    RANGE_MOONLIGHT = atoi(getGlobalStringField("rodrange", 2, "3").c_str());
    RANGE_VOLCANIC = atoi(getGlobalStringField("rodrange", 3, "2").c_str());
    RANGE_QUAGMIRE = atoi(getGlobalStringField("rodrange", 4, "1").c_str());
    RANGE_TEMPEST = atoi(getGlobalStringField("rodrange", 5, "3").c_str());

    RANGE_VORTEX = atoi(getGlobalStringField("wandrange", 1, "4").c_str());
    RANGE_DRAGONBREATH = atoi(getGlobalStringField("wandrange", 2, "3").c_str());
    RANGE_PLAGUE = atoi(getGlobalStringField("wandrange", 3, "2").c_str());
    RANGE_COSMIC = atoi(getGlobalStringField("wandrange", 4, "1").c_str());
    RANGE_INFERNO = atoi(getGlobalStringField("wandrange", 5, "3").c_str());
#endif //JD_WANDS

    return true;
}


std::string LuaScript::getGlobalString(std::string var, const std::string &defString)
{
    lua_getglobal(luaState, var.c_str());

  if(!lua_isstring(luaState, -1))
        return defString;

    int len = (int)lua_strlen(luaState, -1);
    std::string ret(lua_tostring(luaState, -1), len);
    lua_pop(luaState,1);

    return ret;
}

int LuaScript::getGlobalNumber(std::string var, const int defNum)
{
    lua_getglobal(luaState, var.c_str());

  if(!lua_isnumber(luaState, -1))
        return defNum;

    int val = (int)lua_tonumber(luaState, -1);
    lua_pop(luaState,1);

    return val;
}


int LuaScript::setGlobalString(std::string var, std::string val)
{
    return false;
}

int LuaScript::setGlobalNumber(std::string var, int val){
    lua_pushnumber(luaState, val);
    lua_setglobal(luaState, var.c_str());
    return true;
}

std::string LuaScript::getGlobalStringField (std::string var, const int key, const std::string &defString) {
      lua_getglobal(luaState, var.c_str());

      lua_pushnumber(luaState, key);
      lua_gettable(luaState, -2);  /* get table[key] */
      if(!lua_isstring(luaState, -1))
        return defString;
      std::string result = lua_tostring(luaState, -1);
      lua_pop(luaState, 2);  /* remove number and key*/
      return result;
}

int LuaScript::getField (const char *key) {
      int result;
      lua_pushstring(luaState, key);
      lua_gettable(luaState, -2);  /* get table[key] */
      result = (int)lua_tonumber(luaState, -1);
      lua_pop(luaState, 1);  /* remove number and key*/
      return result;
}

void LuaScript::setField (const char *index, int val) {
      lua_pushstring(luaState, index);
      lua_pushnumber(luaState, (double)val);
      lua_settable(luaState, -3);
    }


int LuaScript::getField (lua_State *L , const char *key) {
      int result;
      lua_pushstring(L, key);
      lua_gettable(L, -2);  /* get table[key] */
      result = (int)lua_tonumber(L, -1);
      lua_pop(L, 1);  /* remove number and key*/
      return result;
}

void LuaScript::setField (lua_State *L, const char *index, int val) {
      lua_pushstring(L, index);
      lua_pushnumber(L, (double)val);
      lua_settable(L, -3);
    }

Header

C++:
//////////////////////////////////////////////////////////////////////
// OpenTibia - an opensource roleplaying game
//////////////////////////////////////////////////////////////////////
// class which takes care of all data which must get saved in the player
//////////////////////////////////////////////////////////////////////
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//////////////////////////////////////////////////////////////////////


#ifndef __LUASCRIPT_H__
#define __LUASCRIPT_H__

#include <string>
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}

extern "C" struct lua_State;

#ifdef YUR_HIGH_LEVELS
typedef __int64 exp_t;
#else
typedef unsigned long exp_t;
#endif //YUR_HIGH_LEVELS

class LuaScript
{
public:
    LuaScript();
    ~LuaScript();
    bool ADVANCE_ANI;
    bool EFFECT_ATACK;
    bool SUMMON_BODIES;
    bool EXTRA_MSG_DEAD;
    bool MSG_DEAD;


#ifdef YUR_MULTIPLIERS
    exp_t EXP_MUL;
    exp_t EXP_MUL_PVP;
    int HEALTH_TICK_MUL;
    int MANA_TICK_MUL;
    int ROHHEALTH;
    int ROHMANA;
    int LIFERINGHEALTH;
    int LIFERINGMANA;
    int CAP_GAIN[5];
    int MANA_GAIN[5];
    int HP_GAIN[5];
    int WEAPON_MUL[5];
    int SHIELD_MUL[5];
    int DIST_MUL[5];
    int MANA_MUL[5];
    int DROP_RATE;
    int DIVIDER;
#endif //YUR_MULTIPLIERS

#ifdef TR_ANTI_AFK
    int KICK_TIME;
#endif //TR_ANTI_AFK

#ifdef YUR_LEARN_SPELLS
    bool LEARN_SPELLS;
#endif //YUR_LEARN_SPELLS

#ifdef TLM_HOUSE_SYSTEM
    int ACCESS_HOUSE;
    int MAX_HOUSE_TILE_ITEMS;
#endif //TLM_HOUSE_SYSTEM

#ifdef TR_SUMMONS
    bool  SUMMONS_ALL_VOC;
    size_t MAX_SUMMONS;
#endif //TR_SUMMONS

#ifdef TLM_SKULLS_PARTY
    int HIT_TIME;
    int WHITE_TIME;
    int RED_TIME;
    int FRAG_TIME;
    int RED_UNJUST;
    int BAN_UNJUST;
#endif //TLM_SKULLS_PARTY

#ifdef SD_BURST_ARROW
    double BURST_DMG_LVL;
    double BURST_DMG_MLVL;
    double BURST_DMG_LO;
    double BURST_DMG_HI;
#endif //SD_BURST_ARROW

#ifdef YUR_CONFIG_CAP
    bool CAP_SYSTEM;
#endif //YUR_CONFIG_CAP

#ifdef BDB_REPLACE_SPEARS
    int SPEAR_LOSE_CHANCE;
#endif //BDB_REPLACE_SPEARS

#ifdef YUR_PREMIUM_PROMOTION
    bool FREE_PREMMY;
    bool QUEUE_PREMMY;
#endif //YUR_PREMIUM_PROMOTION

#ifdef YUR_CVS_MODS
    std::string VOCATIONS[5];
    std::string PROMOTED_VOCATIONS[5];
    int DIE_PERCENT_EXP;
    int DIE_PERCENT_MANA;
    int DIE_PERCENT_SKILL;
    int DIE_PERCENT_EQ;
    int DIE_PERCENT_BP;
    long PZ_LOCKED;
    long EXHAUSTED;
    long EXHAUSTED_ADD;
    long EXHAUSTED_HEAL;
    int ACCESS_PROTECT;
    int ACCESS_REMOTE;
    int ACCESS_TALK;
    int ACCESS_ENTER;
    int ACCESS_LOOK;
    int MAX_DEPOT_ITEMS;
    std::string DATA_DIR;
#endif //YUR_CVS_MODS

#ifdef JD_DEATH_LIST
    size_t MAX_DEATH_ENTRIES;
#endif //JD_DEATH_LIST

#ifdef JD_WANDS
    int MANA_SNAKEBITE;
    int MANA_MOONLIGHT;
    int MANA_VOLCANIC;
    int MANA_QUAGMIRE;
    int MANA_TEMPEST;

    int MANA_VORTEX;
    int MANA_DRAGONBREATH;
    int MANA_PLAGUE;
    int MANA_COSMIC;
    int MANA_INFERNO;
   
    int ITEM_MDOWNHELMET;
    int ITEM_MDOWNARMOR;
    int ITEM_MDOWNLEGS;
    int ITEM_MDOWNBOOTS;
    int ITEM_MDOWNAMU;
    int ITEM_MDOWNRING;
    int MGITEMHELMET;
    int MGITEMARMOR;
    int MGITEMLEGS;
    int MGITEMBOOTS;
    int MGITEMAMU;
    int MGITEMRINGS;
    bool MGITEMS;
    std::string MGTYPE;   
    bool SKILLNUMBER;

    int RANGE_SNAKEBITE;
    int RANGE_MOONLIGHT;
    int RANGE_VOLCANIC;
    int RANGE_QUAGMIRE;
    int RANGE_TEMPEST;

    int RANGE_VORTEX;
    int RANGE_DRAGONBREATH;
    int RANGE_PLAGUE;
    int RANGE_COSMIC;
    int RANGE_INFERNO;
#endif //JD_WANDS

  int OpenFile(const char* file);
  int getField (const char *key);
  void LuaScript::setField (const char *index, int value);
  //static version
  static int getField (lua_State *L , const char *key);
  static void setField (lua_State *L, const char *index, int val);
  // get a global string
  std::string getGlobalString(std::string var, const std::string &defString = "");
  int getGlobalNumber(std::string var, const int defNum = 0);
  std::string getGlobalStringField (std::string var, const int key, const std::string &defString = "");
  // set a var to a val
  int setGlobalString(std::string var, std::string val);
  int setGlobalNumber(std::string var, int val);

protected:
    std::string luaFile;   // the file we represent
    lua_State*  luaState;  // our lua state
};


#endif  // #ifndef __LUASCRIPT_H__
 
Hard to tell where the Lua functions are located. Didn't your server came with an example NPC when you downloaded it? If so, post that example here and let us see if we can make any sense out of it.
 
I do not have any sample code that contains the possible functions used by the NPC system. I only have basic codes like: buy, sell, found guild, buy promotions etc. Nothing special with functions "doPlayerAddItem", "doPLayerRemoveItem" etc. ofc. we talk about TalkActions system, but in Actions all scripts contains those function doPlayer work correctly.
I have no idea why only in NPC system I have problem with this....
 
I do not have any sample code that contains the possible functions used by the NPC system. I only have basic codes like: buy, sell, found guild, buy promotions etc. Nothing special with functions "doPlayerAddItem", "doPLayerRemoveItem" etc. ofc. we talk about TalkActions system, but in Actions all scripts contains those function doPlayer work correctly.
I have no idea why only in NPC system I have problem with this....
post actions.cpp

Hard to tell where the Lua functions are located. Didn't your server came with an example NPC when you downloaded it? If so, post that example here and let us see if we can make any sense out of it.
lua functions on 7.6 server is on actions.cpp you forget it?
 
Back
Top