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

Pvp-e support please.

Nightimarez

New Member
Joined
Jul 24, 2008
Messages
287
Reaction score
2
Alright so, I'm making a Pvp-E server using TFS.
I need players to reset their level 100 every time they relog.
I'd still like them to save their outfit, but not their equipment.

How could these things be done?
 
Add in login.lua:
LUA:
	if getPlayerExperience(cid) ~= getExperienceForLevel(100) then
		doPlayerAddExperience(cid, getExperienceForLevel(100) - getPlayerExperience(cid))
	end
Add this in whichever script you use for adding items to players on login, but before the actual process takes place:
LUA:
	for i = 1, 10 do
		local v = getPlayerSlotItem(cid, i).uid
		if v > 0 then
			doRemoveItem(v)
		end
	end
 
I thought you'd ask. It's not possible to remove skills or magic level with a Lua function.

Try this creaturescript instead:
LUA:
function getStats(lvl, stat, voc)
	local cfg, value = {
		k = {4,8},
		d = {2,6},
		s = {1,5},
		p = {3,7}
	}
	if stat == 'health' then
		if isInArray(cfg.p, voc) then
			value = lvl * 10 + 105 
		elseif isInArray(cfg.d, voc) or isInArray(cfg.s, voc) then
			value = lvl * 5 + 145 
		elseif isInArray(cfg.k, voc) then
			value = lvl * 15 + 65
		end
	elseif stat == 'mana' then
		if isInArray(cfg.p, voc) then
			value = lvl * 15 - 85 
		elseif isInArray(cfg.d, voc) or isInArray(cfg.s, voc) then
			value = lvl * 30 - 205 
		elseif isInArray(cfg.k, voc) then
			value = lvl * 5 - 5
		end
	elseif stat == 'cap' then
		if isInArray(cfg.p, voc) then
			value = lvl * 20 + 310
		elseif isInArray(cfg.d, voc) or isInArray(cfg.s, voc) then
			value = lvl * 10 + 390 
		elseif isInArray(cfg.k, voc) then
			value = lvl * 25 + 270
		end
	end
	return value
end

function onLogout(cid)
	local lvl, voc, id = getPlayerLevel(cid), getPlayerVocation(cid), getPlayerGUID(cid)
	db.executeQuery('UPDATE players SET level = 100, health = ' .. getStats(lvl, 'health', voc) .. ', healthmax = ' .. getStats(lvl, 'health', voc) .. ', experience = ' .. getExperienceForLevel(100) .. ', maglevel = 0, mana = ' .. getStats(lvl, 'mana', voc) .. ', manamax = ' .. getStats(lvl, 'mana', voc) .. ', manaspent = 0, soul = 200, posx = 0, posy = 0, posz = 0, cap = ' .. getStats(lvl, 'cap', voc) .. ' WHERE id = ' .. id .. ' LIMIT 1;')
	db.executeQuery('DELETE FROM player_items WHERE player_id = ' .. id .. ';')
	db.executeQuery('DELETE FROM player_skills WHERE player_id = ' .. id .. ';')
	return true
end
 
Last edited:
Try
LUA:
function onLogout(cid)
	local v = getCreatureOutfit(cid)
	db.executeQuery('UPDATE players SET looktype = ' .. v.lookType .. ', lookhead = ' .. v.lookHead .. ', lookbody = ' .. v.lookBody .. ', looklegs = ' .. v.lookLegs .. ', lookfeet = ' .. v.lookFeet .. ', lookaddons = ' .. v.lookAddons .. ' WHERE id = ' .. getPlayerGUID(cid) .. ' LIMIT 1;')
	return true
end
 
For this,
LUA:
function getStats(lvl, stat, voc)
	local cfg, value = {
		k = {4,8},
		d = {2,6},
		s = {1,5},
		p = {3,7}
	}
	if stat == 'health' then
		if isInArray(cfg.p, voc) then
			value = lvl * 10 + 105 
		elseif isInArray(cfg.d, voc) or isInArray(cfg.s, voc) then
			value = lvl * 5 + 145 
		elseif isInArray(cfg.k, voc) then
			value = lvl * 15 + 65
		end
	elseif stat == 'mana' then
		if isInArray(cfg.p, voc) then
			value = lvl * 15 - 85 
		elseif isInArray(cfg.d, voc) or isInArray(cfg.s, voc) then
			value = lvl * 30 - 205 
		elseif isInArray(cfg.k, voc) then
			value = lvl * 5 - 5
		end
	elseif stat == 'cap' then
		if isInArray(cfg.p, voc) then
			value = lvl * 20 + 310
		elseif isInArray(cfg.d, voc) or isInArray(cfg.s, voc) then
			value = lvl * 10 + 390 
		elseif isInArray(cfg.k, voc) then
			value = lvl * 25 + 270
		end
	end
	return value
end
 
function onLogout(cid)
	local lvl, voc, id = getPlayerLevel(cid), getPlayerVocation(cid), getPlayerGUID(cid)
	db.executeQuery('UPDATE players SET level = 100, health = ' .. getStats(lvl, 'health', voc) .. ', healthmax = ' .. getStats(lvl, 'health', voc) .. ', experience = ' .. getExperienceForLevel(100) .. ', maglevel = 0, mana = ' .. getStats(lvl, 'mana', voc) .. ', manamax = ' .. getStats(lvl, 'mana', voc) .. ', manaspent = 0, soul = 200, posx = 0, posy = 0, posz = 0, cap = ' .. getStats(lvl, 'cap', voc) .. ' WHERE id = ' .. id .. ' LIMIT 1;')
	db.executeQuery('DELETE FROM player_items WHERE player_id = ' .. id .. ';')
	db.executeQuery('DELETE FROM player_skills WHERE player_id = ' .. id .. ';')
	return true
end

I got this error,

[25/11/2010 02:45:07] [Warning - Event::loadScript] Event onLogin not found (data/creaturescripts/scripts/skills.lua)
 
It should be type="logout" @ creaturescripts.xml :p! But you should only use that if they have save=1 in database.
 
facepalm.jpg
 
Try this :p:p
LUA:
function getStats(lvl, stat, voc)
	local cfg, value = {
		k = {4,8},
		d = {2,6},
		s = {1,5},
		p = {3,7}
	}
	if stat == 'health' then
		if isInArray(cfg.p, voc) then
			value = lvl * 10 + 105 
		elseif isInArray(cfg.d, voc) or isInArray(cfg.s, voc) then
			value = lvl * 5 + 145 
		elseif isInArray(cfg.k, voc) then
			value = lvl * 15 + 65
		end
	elseif stat == 'mana' then
		if isInArray(cfg.p, voc) then
			value = lvl * 15 - 85 
		elseif isInArray(cfg.d, voc) or isInArray(cfg.s, voc) then
			value = lvl * 30 - 205 
		elseif isInArray(cfg.k, voc) then
			value = lvl * 5 - 5
		end
	elseif stat == 'cap' then
		if isInArray(cfg.p, voc) then
			value = lvl * 20 + 310
		elseif isInArray(cfg.d, voc) or isInArray(cfg.s, voc) then
			value = lvl * 10 + 390 
		elseif isInArray(cfg.k, voc) then
			value = lvl * 25 + 270
		end
	end
	return value
end
 
function onLogout(cid)
	local lvl, voc, id = getPlayerLevel(cid), getPlayerVocation(cid), getPlayerGUID(cid)
	addEvent(db.executeQuery, 100, 'UPDATE players SET level = 100, health = ' .. getStats(lvl, 'health', voc) .. ', healthmax = ' .. getStats(lvl, 'health', voc) .. ', experience = ' .. getExperienceForLevel(100) .. ', maglevel = 0, mana = ' .. getStats(lvl, 'mana', voc) .. ', manamax = ' .. getStats(lvl, 'mana', voc) .. ', manaspent = 0, soul = 200, posx = 0, posy = 0, posz = 0, cap = ' .. getStats(lvl, 'cap', voc) .. ' WHERE id = ' .. id .. ' LIMIT 1;')
	addEvent(db.executeQuery, 100, 'DELETE FROM player_items WHERE player_id = ' .. id .. ';')
	addEvent(db.executeQuery, 100, 'UPDATE player_skills SET value = 10, count = 0 WHERE player_id = ' .. id .. ' LIMIT 7;')
	return true
end
 
Last edited:
Okay, that deletes the items. But I think I want to do it this way.
Save "0"
Outfits Save, ty.
First time player logs in, set save to 0, add items, and skills. Everything depending on their vocation.

Oh and that still didn't update skills
 
It's only supposed to delete the skills. Oh wait, deleting the rows would screw the skill saving totally.

BTW It's not supposed to update (add) them. You need another script for items, and adding skills.
 
Last edited:
Got this working..

LUA:
function onLogin(cid)
  if getPlayerGroupId(cid) < 2 then
    local hasReceivedSave = getPlayerStorageValue(cid, 5473)

    if hasReceivedSave ~= 1 then
	db.executeQuery('UPDATE players SET save = 0 WHERE group_id = 1;')

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Welcome to Mortal War!")
      end
      setPlayerStorageValue(cid, 5473, 1)
  end
  return TRUE
end
 
Last edited:
Back
Top