تفضل
quest pet_exp begin
state start begin
function get_pet_info(itemVnum)
pet_info_map = {
-- [ITEM VNUM] MOB_VNUM, DEFAULT NAME, buff_idx, spawn_effect_idx
[55701] = { 34041, "'s قرد صغير", 0},
[55702] = { 34045, "'s عنكبوت صغير", 0},
[55703] = { 34049, "'s رزادور صغير", 0},
[55704] = { 34053, "'s نمير صغير", 0},
}
itemVnum = tonumber(itemVnum)
return pet_info_map[itemVnum]
end
when 20086.take with item.vnum >= 55701 and item.vnum <= 55705 begin
local pet_info = pet_exp . get_pet_info ( item . vnum )
if null ~= pet_info then
local mobVnum = pet_info [ 1 ]
local petName = pet_info [ 2 ]
if true == newpet . is_summon ( mobVnum ) then
newpet . unsummon ( mobVnum )
end
end
local idd = item.get_id()
chat(idd)
mysql_direct_query(string.format("UPDATE player.new_petsystem SET level = 120, evolution = 3, exp = 0, expi = 0, bonus0 = 95, bonus1 = 130, bonus2 = 95 WHERE id = %d;", item.get_id()));
end
end
end
يجب عليك ايضاً اضافة
int _mysql_direct_query(lua_State* L)
{
if (!lua_isstring(L, 1))
return 0;
int i=0, m=1;
MYSQL_ROW row;
MYSQL_FIELD * field;
MYSQL_RES * result;
std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery("%s", lua_tostring(L, 1)));
if (pMsg.get())
{
lua_pushnumber(L, pMsg->Get()->uiAffectedRows);
lua_newtable(L);
if ((result = pMsg->Get()->pSQLResult) &&
!(pMsg->Get()->uiAffectedRows == 0 || pMsg->Get()->uiAffectedRows == (uint32_t)-1))
{
while((row = mysql_fetch_row(result)))
{
lua_pushnumber(L, m);
lua_newtable(L);
while((field = mysql_fetch_field(result)))
{
lua_pushstring(L, field->name);
if (!(field->flags & NOT_NULL_FLAG) && (row[i]==NULL))
{
lua_pushnil(L);
}
else if (IS_NUM(field->type))
{
double val = NAN;
lua_pushnumber(L, (sscanf(row[i],"%lf",&val)==1)?val:NAN);
}
else if (field->type == MYSQL_TYPE_BLOB)
{
lua_newtable(L);
for (DWORD iBlob=0; iBlob < field->max_length; iBlob++)
{
lua_pushnumber(L, row[i][iBlob]);
lua_rawseti(L, -2, iBlob+1);
}
}
else
lua_pushstring(L, row[i]);
lua_rawset(L, -3);
i++;
}
mysql_field_seek(result, 0);
i=0;
lua_rawset(L, -3);
m++;
}
}
}
else {lua_pushnumber(L, 0); lua_newtable(L);}
return 2;
}
{ "mysql_direct_query", _mysql_direct_query },
في السورس ملف questlua_global.cpp