VO

Doplayersetskill

Por Vodkart, 08 de fev. de 2011 em Mods, funções e outros

13
3.7k
VodkartV
08 de fevereiro de 2011 às 21:36

Função para mudar a quantidade de skills ou magic level do jogador.

 

lib/050-function

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

function doPlayerSetMagic(cid, amount)
local pid = getPlayerGUID(cid)  
doRemoveCreature(cid,true) 
db.executeQuery("UPDATE `players` SET `maglevel` = " .. amount .. " WHERE `id` = "..pid)
return TRUE
end

 

exemplo de uso

 

 

function onSay(cid, words, param)
return doPlayerSetMagic(cid, 100) -- mudara o magic level do jogador para 100
end

 

vocês também podem fazer calculo para adicionar por exemplo +10 de magic level ou skills,muito facil

 

function onSay(cid, words, param)
local add = 10 -- quanto vc quer adicionar de magic level
doPlayerSetMagic(cid, getPlayerMagLevel(cid)+add)
return TRUE 
end

 

agora a função para skill:

 

lista:

SKILL_FIST (0) = Fist Fighting

SKILL_CLUB (1) = Club Fighting

SKILL_SWORD (2) = Sword Fighting

SKILL_AXE (3) = Axe Fighting

SKILL_DISTANCE (4) = Distance Fighting

SKILL_SHIELD (5) = Shielding

SKILL_FISHING (6) = Fishing

 

ex:

function onSay(cid, words, param)
return doPlayerSetSkill(cid, 2, 50) -- mudei a skill de sword do jogador para 50
end

 

ou add + x de skill...

 

ex adicionando + 5 de skill sword

function onSay(cid, words, param)
return doPlayerSetSkill(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD)+5) -- adicionei 5 de skill de sword
end

 

 

Saymon14S
08 de fevereiro de 2011 às 22:24

Muito mais facil e gostoso de mudar o skill, e sem precisar de storage, certo ?

VodkartV
08 de fevereiro de 2011 às 23:12

yeah

meubkM
09 de fevereiro de 2011 às 07:59

só funciona depois que reloga ?

VodkartV
09 de fevereiro de 2011 às 10:35

é porque é pela database do player,ai só funciona com ele deslogado.

2 meses depois...
SubwatS
03 de abril de 2011 às 17:07

cara fico perfeito esse sistema.

2 meses depois...
guixapG
17 de junho de 2011 às 13:39

Tu poderia fazer um comando agora xD...



Muita gente procura comando de venda de skill de ml onde. Só druid e sorc compra ml e com limite de 200, só pally compra distance com limite de 350 e só kina compra de club, sword e axe com limite de 350.

6 meses depois...
KombosaboK
15 de dezembro de 2011 às 12:22

Otimo function '-' usando no meu server

soh uma duvida:

 

"Se jogador for sorcerer e tiver magic level menor que 70, set magic level to 70."

ta certo isso ai?

 

 

if playerVoc == 1 and getPlayerSkill(cid, 7) <= 70 then
doPlayerSetMagic(cid, 70)

Editado Dezembro 15 por Kombosabo OT Server

VodkartV
17 de dezembro de 2011 às 13:17
if getPlayerVocation(cid) == 1 and getPlayerMagLevel(cid) < 70 then
return doPlayerSetMagic(cid, 70)
end

KombosaboK
24 de dezembro de 2011 às 11:42

if getPlayerVocation(cid) == 1 and getPlayerMagLevel(cid) < 70 then
return doPlayerSetMagic(cid, 70)
end

 

 

 

 

REP+ smile_positivo.gif

72asdf7
28 de dezembro de 2011 às 21:27

muito obrigado pela contribuição.

02 de janeiro de 2012 às 21:32

SET é meio sem utilidade, acho que add ficaria melhor, ah e arrumei o TRUE porque nas últimas versões do tfs ele foi repassado por true

function doPlayerSetSkill(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)  
return true
end

function doPlayerSetMagic(cid, amount)
local pid = getPlayerGUID(cid)  
doRemoveCreature(cid, true)
db.executeQuery("UPDATE `players` SET `maglevel` = `maglevel` + " .. amount .. " WHERE `id` = ".. pid)
return true
end

 

Um modo de fazer essa função sem laggar o servidor é assim:

function playerAddSkill(cid, skill, amount, round)
if(skill == SKILL__LEVEL) then
	return doPlayerAddLevel(cid, amount, round)
end
for i = 1, amount do
	if(skill == SKILL__MAGLEVEL) then
		return doPlayerAddMagLevel(cid, i)
	end
	return doPlayerAddSkill(cid, skill, i)
end
end

Editado Janeiro 26 por fireelement

3 anos depois...
jvcasarinJ
06 de dezembro de 2015 às 00:50

Desculpa reviver o tópico, mas preciso muito dessa ajuda!

 

Olhem, me ajudem com esse script:

 

function onSay(cid, words, param)

 

if (getTilePzInfo(getCreaturePosition(cid)) == FALSE) then
doPlayerSendTextMessage(cid,22,"você precisa estar em protection zone pra poder usar este comando.")
return TRUE
end
if doPlayerRemoveItem(cid,2160,500) and getPlayerVocation(cid) == 8 then
doPlayerSetSkill(cid, 3, 400)
doCreatureSay(cid, "AXE FULL KNIGHT!", TALKTYPE_ORANGE_1)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MORTAREA)
else
doPlayerSendCancel(cid, 'voce precisa de 5kk para usar este comando e ser Kina.')
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FLAMEAREA)
end
end

 

 

Mais informações para os erros que aparecem: http://www.xtibia.com/forum/topic/238114-erro-erros-com-talkactions/