function Dragon(FamilyID, action, value, query_flag, RoleID) local actions = {} actions[1] = function() sql = "INSERT INTO dragon (FamilyID,DragonLv,chek,Exp) VALUES ('%s', 1, 0,0)" con:execute(sql:format(FamilyID)) sql = "INSERT INTO dragon_role_skill (RoleID,cel) VALUES ('%s', 0)" con:execute(sql:format(RoleID)) end actions[2] = function() sql = "Update dragon set chek = 1 where FamilyID = '%s'" con:execute(sql:format(FamilyID)) end actions[3] = function() sql = "Update dragon set chek = 0 where FamilyID = '%s'" con:execute(sql:format(FamilyID)) end actions[4] = function() sql = "Update dragon set DragonLv = '%s' where FamilyID = '%s'" con:execute(sql:format(value, FamilyID)) end actions[5] = function() sql = "Update dragon set Exp = Exp+'%s',day = Now() where FamilyID = '%s'" con:execute(sql:format(value, FamilyID)) end actions[6] = function() sql = "Update dragon_role_skill set cel = cel+'%s' where RoleID = '%s'" con:execute(sql:format(value, RoleID)) end Sql_con() local dragon_level = 0 local dragon_check = 0 local dragon_exp = 0 local role_cel = 0 if query_flag == 1 then for level in rows(con, string.format("SELECT DragonLv FROM dragon WHERE FamilyID = %s", FamilyID)) do dragon_level = level end for check in rows(con, string.format("SELECT chek FROM dragon WHERE FamilyID = %s", FamilyID)) do dragon_check = check end for exp in rows(con, string.format("SELECT Exp FROM dragon WHERE FamilyID = %s", FamilyID)) do dragon_exp = exp end for cel in rows(con, string.format("SELECT cel FROM dragon_role_skill WHERE RoleID = %s", RoleID)) do role_cel = cel end end if action ~= 0 and actions[action] then actions[action]() end con:close() env:close() return dragon_level, dragon_check, dragon_exp, role_cel end