Hello. This script is supposed to:
1. Restore level to 70 if player is below that level.
2. Add equipment + supplies upon death or first login.
Only second part is working, why?
Note: I didn't post all item arrays for each vocation. That part is already working.
1. Restore level to 70 if player is below that level.
2. Add equipment + supplies upon death or first login.
Only second part is working, why?
Note: I didn't post all item arrays for each vocation. That part is already working.
Lua:
function onLogin(cid)
if getPlayerLevel(cid) < 70 then
doPlayerAddExperience(cid, getExperienceForLevel(70) - getPlayerExperience(cid))
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You can\'t downgrade below level 70.')
end
if getPlayerStorageValue(cid,1002) ~= 1 then
setPlayerStorageValue(cid, 1001, 0)
setPlayerStorageValue(cid, 1002, 1)
end
if getPlayerStorageValue(cid, 1001) == 0 then
local items = defaultItems[getPlayerVocation(cid)]
if getPlayerSlotItem(cid, 3).uid == 0 then
local mainBackpack = doPlayerAddItem(cid, 1988, 1)
for i = 1, #items do
if (items[i].type == ITEM) then
doAddContainerItem(mainBackpack, items[i].itemId, items[i].count)
elseif (items[i].type == BACKPACK) then
local bp = mainBackpack
local bpInside = doAddContainerItem(bp, items[i].bpId, 1)
for j=1, items[i].bpCount do
bp = bpInside
if (j < items[i].bpCount) then
bpInside = doAddContainerItem(bp, items[i].bpId, 1)
else
doAddContainerItem(bp, items[i].itemId, items[i].count)
end
for j=1, 19 do
doAddContainerItem(bp, items[i].itemId, items[i].count)
end
end
elseif (items[i].type == ITEMS) then
local bp = doAddContainerItem(mainBackpack, items[i].bpId, 1)
for j=1, #items[i] do
doAddContainerItem(bp, items[i][j].itemId, items[i][j].count)
end
end
end
end
for i = 1, #items do
if (items[i].type == SLOT) then
if getPlayerSlotItem(cid, items[i].slotId).uid == 0 then
doPlayerAddItem(cid, items[i].itemId, items[i].count)
end
end
end
setPlayerStorageValue(cid, 1001, 1)
end
--registerCreatureEvent(cid, "KillProtection")
registerCreatureEvent(cid, "PlayerDeath")
return TRUE
end