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

Some can help me with this?

Stewie

Family Guy # ;3
Joined
May 3, 2010
Messages
786
Reaction score
12
Location
TV
i would like show many resets player have in name description here the npc of reset:

LUA:
-- SCRIPT FEITO POR YUNIE
-- config
local minlevel = 850 -- level para resetar
local minlevel_vip = 700
local price = 100000
local newlevel = 10 -- level após reset
local newexp = 9300 -- nova experiencia após reset
-- end config

function addReset(cid)
	return setPlayerStorageValue(cid, 36874, getResets(cid) + 1)
end

function getResets(cid)
	return math.max(0, getPlayerStorageValue(cid, 36874))
end

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end

	if msgcontains(msg, 'resetar') then
		selfSay('Voce aceita o reset? se voce confirmar tera que deslogar para que o reset tenha efeito. voce tera que pagar a quantia de '..price..' GP para o reset.', cid)
		talkState[cid] = 1
	elseif(msgcontains(msg, 'yes') and talkState[cid] == 1) then
		if getPlayerMoney(cid) < price then
			selfSay('You must pay '..price..' gold coins to reset.', cid)
		elseif getPlayerLevel(cid) < (vip.hasVip(cid) and minlevel_vip or minlevel) then
			selfSay('Voce precisa ter no minimo level '.. minlevel ..' para o reset.', cid)
		else
			doPlayerRemoveMoney(cid,price)
			addReset(cid)
			playerid = getPlayerGUID(cid)
			doRemoveCreature(cid)
			db.executeQuery("UPDATE `players` SET `level`="..newlevel..",`experience`="..newexp.." WHERE `players`.`id`= ".. playerid .."")
		end
		talkState[cid] = 0
	elseif msgcontains(msg, 'no') and isInArray({1}, talkState[cid]) then
		talkState[cid] = 0
		selfSay('Yes', cid)
	elseif msgcontains(msg, 'resets') then
		selfSay('Voce tem '..getResets(cid)..' reset(s).', cid)
	end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
do you mean like when a player looks at you it will say:
"You see [Name here]. He is a [Vocation Here], Level: [lvl], Resets: [amount]"
if so, it's not on a NPC but on a creaturescript onLook and use storage
Reset = getPlayerStorageValue(cid, [key])
 
look.lua:
Code:
function onLook(cid, thing, position, lookDistance)
	if isPlayer(thing.uid) then
		doPlayerSendTextMessage(cid, 25, 'Resets: ' .. math.max(0, getPlayerStorageValue(thing.uid, 36874)))
	end
	return true
end
creaturescripts.xml
Code:
	<event type="look" name="Look" event="script"  value="look.lua"/>
login.lua:
Code:
	registerCreatureEvent(cid, 'Look')
 
Last edited:
Code:
function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) then
        doPlayerSendTextMessage(cid, 25, 'Resets: ' .. math.max(0, getPlayerStorageValue([COLOR=Red]cid[/COLOR], 36874)))
    end
    return true
end
?
 
no resets = -1
even if I set value to 1 or any number, before getting the storage
value, it will return -1?
Edit:
LOL, fail on my behalf, I get it know so if a new player is looked
at even if he has -1 on his storage with math.max it will return
the max value, in this case since -1 is smaller than 0 it will
return 0.
 
Back
Top