• 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!

Query

Fire Element

Member
Joined
Sep 10, 2010
Messages
193
Reaction score
22
Location
Brazil
A query (not function(doPlayerAddSkill)) that adds 10 skill of sword in the player who clicks on the chest.

sorry for my english
 
Function doPlayerAddSkill doesn't work right =/

I even tried to make a:

LUA:
local id = {club = 1, sword = 2, axe = 3, distance = 4, shield = 5}
local pid = getPlayerGUID(cid)

db.executeQuery("UPDATE `player_skills` SET `value` = `value` + 10 WHERE `player_id` = "..pid.." and `skillid` = "..id.sword..";")
 
or maybe the sword player skill is bugged, that usually happens in TFS
LUA:
db.query('UPDATE player_skills SET value = value+10 WHERE skillid = 2 AND player_id = ' .. getPlayerGUID(cid))
 
doesn't work =/

I tested in TFS 0.3.6pl1

LUA:
function onUse(cid, item)

if getPlayerItemCount(cid,1) then
   db.executeQuery('UPDATE player_skills SET value = value+10 WHERE skillid = 1 AND player_id = ' .. getPlayerGUID(cid))
   doRemoveItem(item.uid)
else
   return false
   end
end
 
LUA:
local STORAGE = 12455

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getCreatureStorage(cid, STORAGE) > 0 then
		return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
	end
	
	local p = getThingPos(cid)
	local positions = 
	{
        [1] = {
			{x=p.x+1,y=p.y,z=p.z}, 100, 900
		},
        [2] = {
			{x=p.x+1,y=p.y+1,z=p.z}, 200, 980
		},
        [3] = {
			{x=p.x,y=p.y+1,z=p.z}, 300, 1060
		},
        [4] = {
			{x=p.x-1,y=p.y+1,z=p.z}, 400, 1140
		},
        [5] = {
			{x=p.x-1,y=p.y,z=p.z}, 500, 1220
		},
        [6] = {
			{x=p.x-1,y=p.y-1,z=p.z}, 600, 1300
		},
        [7] = {
			{x=p.x,y=p.y-1,z=p.z}, 700, 1380
		},
        [8] = {
			{x=p.x+1,y=p.y-1,z=p.z}, 800, 1460
		} 
	}
 
    for i = 1, 8 do
        addEvent(doSendDistanceShoot, positions[i][2], positions[i][1], p, 24)
        addEvent(doSendDistanceShoot, positions[i][3], positions[i][1], p, 24)
    end
 
    doCreatureSetStorage(cid, STORAGE, 1)
	addEvent(doSendMagicEffect, 900, p, 49)	
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a reward of ten sword skill levels.')
	db.executeQuery('UPDATE player_skills SET value = value+10 WHERE skillid = 2 AND player_id = ' .. getPlayerGUID(cid))
	return true
end
 
Sorry for the inconvenience, one guy told me he had to ask.

LUA:
doRemoveCreature(cid,true) -- This =P
db.executeQuery("UPDATE `player_skills` SET `value` = `value` + ".. w.count .." WHERE `player_id` = ".. pid .. " and `skillid` = ".. id.sword ..";")

Thanks.

edit --

if anyone needs, I transform to function =)

LUA:
function doPlayerAddSkill(cid, skill, amount)
        local pid = getPlayerGUID(cid)
        doRemoveCreature(cid,true)
        db.executeQuery("UPDATE `player_skills` SET `value` = `value` + ".. amount .." WHERE `player_id` = ".. pid .. " and `skillid` = ".. skill ..";")
end

LUA:
function doPlayerRemoveSkill(cid, skill, amount)
        local pid = getPlayerGUID(cid)
        doRemoveCreature(cid,true)
        db.executeQuery("UPDATE `player_skills` SET `value` = `value` - ".. amount .." WHERE `player_id` = ".. pid .. " and `skillid` = ".. skill ..";")
end
 
Last edited:
Back
Top