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

Lua Changesex

guigui768

New Member
Joined
Oct 11, 2010
Messages
81
Reaction score
1
I would like that this scrpit of changesex discount 3 VIP Days and not Premium days..
I use system vip By Kyndrai



function onSay(cid, words, param)
if getPlayerPremiumDays(cid) > 2 then
doPlayerRemovePremiumDays(cid, 3)
if getPlayerSex(cid) == 0 then
doPlayerSetSex(cid, 1)
else
doPlayerSetSex(cid, 0)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have changed your sex and lost three days of premium account.")
else
doPlayerSendCancel(cid, "You do not have enough premium days, changing sex costs three of your premium days.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
end
 
LUA:
function onSay(cid, words, param)
	if getVipDaysByAccount(acc) > 2 then
		doRemoveVipDaysByAccount(acc, 3)
		if getPlayerSex(cid) == 0 then
			doPlayerSetSex(cid, 1)
		else
			doPlayerSetSex(cid, 0)
		end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have changed your sex and lost three days of vip account.")
	else
		doPlayerSendCancel(cid, "You do not have enough vip days, changing sex costs three of your vip days.")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
end

divisor.png

 
a error in distro...when i say !changesex,it apear in tfs:

Data/lib/vip account.lua.51 attempt to concanate local acc..

Some think like that..
My system vip is by account
 
post your vip account.lua file
(data/lib/vip account.lua)

but triy out this one, should work:
PHP:
function onSay(cid, words, param)
 local acc = getAccountIdByName(name)
	if getVipDaysByAccount(acc) > 2 then
		doRemoveVipDaysByAccount(acc, 3)
		if getPlayerSex(cid) == 0 then
			doPlayerSetSex(cid, 1)
		else
			doPlayerSetSex(cid, 0)
		end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have changed your sex and lost three days of vip account.")
	else
		doPlayerSendCancel(cid, "You do not have enough vip days, changing sex costs three of your vip days.")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
end
divisor.png

 
No,didnt work...
Im going to put my vipaccount.lua


Code:
--[[
        Name: Vip System by Account
        Version: 1.0
        Author: Kydrai
        Forum: [url=http://www.xtibia.com/forum/topic/136543-vip-system-by-account-v10/]Vip System By Account V1.0 - XTibia - A sua comunidade de Tibia e OTserv[/url]
        
        [Functions]
                -- Install
                installVip()
                
                -- By Account
                doTeleportPlayersByAccount(acc, topos)
                getVipTimeByAccount(acc)
                setVipTimeByAccount(acc, time)
                getVipDaysByAccount(acc)
                isVipAccount(acc)
                addVipDaysByAccount(acc, days)
                doRemoveVipDaysByAccount(acc, days)
                getVipDateByAccount(acc)
                
                -- By Player
                doTeleportPlayers(cid, topos)
                getVipTime(cid)
                setVipTime(cid, time)
                getVipDays(cid)
                isVip(cid)
                addVipDays(cid, days)
                doRemoveVipDays(cid, days)
                getVipDate(cid)
]]--

-- Install
function installVip()
        if db.executeQuery("ALTER TABLE `accounts` ADD viptime INT(15) NOT NULL DEFAULT 0;") then
                print("[Vip System] Vip System instalado com sucesso!")
                return TRUE
        end
        print("[Vip System] Não foi possível instalar o Vip System!")
        return FALSE
end

-- By Account
function doTeleportPlayersByAccount(acc, topos)
        if db.executeQuery("UPDATE `players` SET `posx` = "..topos.x..", `posy` = "..topos.y..", `posz` = "..topos.z.." WHERE `account_id` = "..acc..";") then
                return TRUE
        end
        return FALSE
end

function getVipTimeByAccount(acc)
        local vip = db.getResult("SELECT `viptime` FROM `accounts` WHERE `id` = "..acc..";")
        if vip:getID() == -1 then
                print("[Vip System] Account not found!")
                return FALSE
        end
        return vip:getDataInt("viptime")
end

function setVipTimeByAccount(acc, time)
        if db.executeQuery("UPDATE `accounts` SET `viptime` = "..time.." WHERE `id` = "..acc..";") then
                return TRUE
        end
        return FALSE
end

function getVipDaysByAccount(acc)
        local vipTime = getVipTimeByAccount(acc)
        local timeNow = os.time()
        local days = math.ceil((vipTime - timeNow)/(24 * 60 * 60))
        return days <= 0 and 0 or days
end

function isVipAccount(acc)
        return getVipDaysByAccount(acc) > 0 and TRUE or FALSE
end

function addVipDaysByAccount(acc, days)
        if days > 0 then
                local daysValue = days * 24 * 60 * 60
                local vipTime = getVipTimeByAccount(acc)
                local timeNow = os.time()
                local time = getVipDaysByAccount(acc) == 0 and (timeNow + daysValue) or (vipTime + daysValue)
                setVipTimeByAccount(acc, time)
                return TRUE
        end
        return FALSE
end

function doRemoveVipDaysByAccount(acc, days)
        if days > 0 then
                local daysValue = days * 24 * 60 * 60
                local vipTime = getVipTimeByAccount(acc)
                local time = vipTime - daysValue
                setVipTimeByAccount(acc, (time <= 0 and 1 or time))
                return TRUE
        end
        return FALSE
end

function getVipDateByAccount(acc)
        if isVipAccount(acc) then
                local vipTime = getVipTimeByAccount(acc)
                return os.date("%d/%m/%y %X", vipTime)
        end
        return FALSE
end

-- By Player
function doTeleportPlayers(cid, topos)
        doTeleportPlayersByAccount(getPlayerAccountId(cid), topos)
end

function getVipTime(cid)
        return getVipTimeByAccount(getPlayerAccountId(cid))
end

function setVipTime(cid, time)
        return setVipTimeByAccount(getPlayerAccountId(cid), time)
end

function getVipDays(cid)
        return getVipDaysByAccount(getPlayerAccountId(cid))
end

function isVip(cid)
        return isVipAccount(getPlayerAccountId(cid))
end

function addVipDays(cid, days)
        return addVipDaysByAccount(getPlayerAccountId(cid), days)
end

function doRemoveVipDays(cid, days)
        return doRemoveVipDaysByAccount(getPlayerAccountId(cid), days)
end

function getVipDate(cid)
        return getVipDateByAccount(getPlayerAccountId(cid))
end
 
Last edited by a moderator:
Theese scripts should work:

remove vipdays by Account
LUA:
function onSay(cid, words, param)
 local acc = getAccountIdByName(name)
	if getVipDaysByAccount(acc) > 2 then
		doRemoveVipDaysByAccount(acc, 3)
		if getPlayerSex(cid) == 0 then
			doPlayerSetSex(cid, 1)
		else
			doPlayerSetSex(cid, 0)
		end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have changed your sex and lost three days of vip account.")
	else
		doPlayerSendCancel(cid, "You do not have enough vip days, changing sex costs three of your vip days.")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
end

Remove vipdays by player:
LUA:
function onSay(cid, words, param)
	if getVipDays(cid) >= 3 then
		doRemoveVipDays(cid, 3)
		if getPlayerSex(cid) == 0 then
			doPlayerSetSex(cid, 1)
		else
			doPlayerSetSex(cid, 0)
		end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have changed your sex and lost three days of vip account.")
	else
		doPlayerSendCancel(cid, "You do not have enough vip days, changing sex costs three of your vip days.")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
end
divisor.png
 

Similar threads

Back
Top