Venn
Member
- Joined
- Aug 16, 2009
- Messages
- 547
- Reaction score
- 20
crash server when loading mods. how to fix that ?
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Vip System" version="1.0" author="Kekox and Diorges" contact="" enabled="yes">
<config name="vipFunctions">
<![CDATA[
local config = {
vipVocation = true, -- Vip have new vocations?
vipPromotionStorage = 49159, -- Store if the player had promotion vip
isVipStorage = 49160, -- Storage to check if the player had or no vip
vipGroup = 1, -- not added yet
playerGroup = 1, -- not added yet
freeVip = false, -- not added yet
restoreStamina = false, -- restore ur stamina after relogin?
townId = 1 -- teleport the player to this town when player lost vip
}
function getPlayerVipDays(cid)
local Info = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
if Info:getID() ~= LUA_ERROR then
local days= Info:getDataInt("vipdays")
Info:free()
return days
end
return LUA_ERROR
end
function doAddVipDays(cid, days)
db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
function doRemoveVipDays(cid, days)
if (getPlayerVipDays(cid) <= days) then
db.executeQuery("UPDATE `accounts` SET `vipdays` = 0 WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
else
db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
end
]]></config>
<event type="login" name="vipRegister" event="script">
<![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "vipCheck")
return true
end
]]></event>
<event type="login" name="vipCheck" event="script">
<![CDATA[
domodlib('vipFunctions')
function onLogin(cid)
-- Add the storage of promotion to player
if(getPlayerStorageValue(cid, config.vipPromotionStorage) == -1 and config.vipVocation == true) then
setPlayerStorageValue(cid, config.vipPromotionStorage, 1)
end
if (getPlayerVipDays(cid) >= 1) then
-- Restore the stamina of player
if(config.restoreStamina) then
doPlayerSetStamina(cid, 2520)
end
-- Add a storage to player to check later if he had VIP
if(getPlayerStorageValue(cid, config.isVipStorage) == -1) then
setPlayerStorageValue(cid, config.isVipStorage, 1)
end
-- Add a storage to player to keep him promotion after he lose ur vipdays
if(config.vipVocation == true and getPlayerPromotionLevel(cid) == 2 and getPlayerStorageValue(cid, config.vipPromotionStorage) == 1) then
setPlayerStorageValue(cid, config.vipPromotionStorage, 2)
end
- -- Add back the old promotion of player if he buy more vipdays
if (config.vipVocation == true and getPlayerPromotionLevel(cid) == 1 and getPlayerStorageValue(cid, config.vipPromotionStorage) == 2) then
doPlayerSetPromotionLevel(cid, 2)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have '.. getPlayerVipDays(cid) ..' vip days left.')
else
-- Reset the promotion of player
if(getPlayerPromotionLevel(cid) > 1 and config.vipVocation == true) then
doPlayerSetPromotionLevel(cid, 1)
end
-- Teleport the player to town
if(getPlayerStorageValue(cid, config.isVipStorage) == 1) then
doPlayerSetTown(cid, config.townId)
doTeleportThing(cid, getTownTemplePosition(config.townId))
setPlayerStorageValue(cid, config.isVipStorage, 0)
end
end
return true
end
]]></event>
<globalevent name="VipDaysRemover" time="00:01" event="script">
<![CDATA[
function onTime()
db.executeQuery("UPDATE accounts SET vipdays = vipdays - 1 WHERE vipdays > 0;")
return true
end
]]></globalevent>
<action actionid="60043" event="script">
<![CDATA[
domodlib('vipFunctions')
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cidPosition = getCreaturePosition(cid)
if (item.actionid == 60043 and getPlayerVipDays(cid) >= 1) then
if getCreaturePosition(cid).y < toPosition.y then
doTeleportThing(cid, {x=toPosition.x,y=toPosition.y+1,z=toPosition.z}, TRUE)
else
doTeleportThing(cid, {x=toPosition.x,y=toPosition.y-1,z=toPosition.z}, TRUE)
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you are not a VIP player.")
end
return TRUE
end
]]></action>
<movevent type="StepIn" actionid="60043" event="script">
<![CDATA[
domodlib('vipFunctions')
function onStepIn(cid, item, position, fromPosition)
if (getPlayerVipDays(cid) == 0) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you are not a VIP player.")
doTeleportThing(cid, fromPosition, TRUE)
end
end
]]></movevent>
<talkaction words="/adddays; /removedays" access="5" event="script">
<![CDATA[
function onSay(cid, words, param, channel)
domodlib('vipFunctions')
if words == '/adddays' then
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
return true
end
local t = string.explode(param, ",")
t[1] = tonumber(t[1])
if(not t[1]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")
return true
end
local pid = cid
if(t[2]) then
pid = getPlayerByNameWildcard(t[2])
if(not pid) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.")
return true
end
end
if(t[1] > 365) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can only add max 365 vip days.")
return true
end
doAddVipDays(pid, t[1])
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have added ".. t[1] .." vip days to ".. t[2])
doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerName(cid) .." just added you ".. t[1] .." vip days.")
return true
elseif words == '/removedays' then
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
return true
end
local t = string.explode(param, ",")
t[1] = tonumber(t[1])
if(not t[1]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")
return true
end
local pid = cid
if(t[2]) then
pid = getPlayerByNameWildcard(t[2])
if(not pid) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.")
return true
end
end
if(t[1] > 365) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can only add max 365 vip days.")
return true
end
doRemoveVipDays(pid, t[1])
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have removed ".. t[1] .." vip days to ".. t[2])
doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerName(cid) .." just removed you ".. t[1] .." vip days.")
return true
end
end
]]></talkaction>
</mod>