• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Change Sex [per Items, premium days or money]

Shalk

Royal Angels ATS
Joined
Sep 19, 2007
Messages
214
Reaction score
4
Location
Brazil
Hello guys!
Here is npc for change your sex!

go to data/npcs/scripts and create a lua file named change_sex.lua

1)NPC change your sex for premium days:
Code:
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

[COLOR="#FF0000"]local priceindays = 3[/COLOR]

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if(msgcontains(msg, 'sex') or msgcontains(msg, 'change')) then
selfSay('I can change your sex per '..priceindays..' days of premium account! Do you want?', cid)
talkState[talkUser] = 40
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 40) then
if(getPlayerSex(cid) >= 2) then
			selfSay('You cannot change your gender.', cid)
			return
		end

		if(getPlayerPremiumDays(cid) < priceindays) then
			selfSay('Sorry, not enough '..priceindays..' days of premium account.', cid)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
			return
		end

		if(getPlayerPremiumDays(cid) < 65535) then
			doPlayerAddPremiumDays(cid, -priceindays)
		end

		doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
		selfSay('You have changed your gender and lost '..priceindays..' days of premium time.', cid)
talkState[talkUser] = 0
		doSendMagicEffect(getCreaturePosition(cid), 35)
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Config:
priceindays = number of days will be removed from the account to be exchanged sex

2)Change Sex per Money (gold, platinum, crystal coins...)
Code:
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

[COLOR="#FF0000"]local priceinmoney = 30000[/COLOR]

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if(msgcontains(msg, 'change') or msgcontains(msg, 'sex')) then
selfSay('I can change your sex per '..priceinmoney..' gold pieces! Do you want?', cid)
talkState[talkUser] = 4
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then
if(doPlayerRemoveMoney(cid, priceinmoney) == TRUE) then
doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
doSendMagicEffect(getCreaturePosition(cid), 35)
selfSay('You have changed your gender and lost '..priceinmoney..' days of premium time.', cid)
else
selfSay('Sorry, not enough '..priceinmoney..' gold pieces.', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Config:
priceinmoney = price in gold pieces (ex: 30000 = 30k).

3)Change you sex per "x" Item

Code:
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

[COLOR="#FF0000"]local itemtochange = 9971[/COLOR]
[COLOR="#800080"]local counttochange = 10[/COLOR]

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if(msgcontains(msg, 'change') or msgcontains(msg, 'sex')) then
selfSay('I can change your sex per '..counttochange..' [COLOR="#00FFFF"][B]ITEMNAME[/B][/COLOR] gold pieces! Do you want?', cid)
talkState[talkUser] = 7
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 7) then
if(getPlayerItemCount(cid, itemtochange) >= counttochange) then
doPlayerRemoveItem(cid, itemtochange, counttochange)
doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
doSendMagicEffect(getCreaturePosition(cid), 35)
selfSay('You have changed your gender and lost '..counttochange..' [COLOR="#00FFFF"][B]ITEMNAME[/B][/COLOR].', cid)
else
selfSay('Sorry, not enough '..counttochange..' of [COLOR="#00FFFF"][B]ITEMNAME[/B][/COLOR].', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Config:
local itemtochange = id of "x" item
local counttochange = amount of "x" item to change
ITEMNAME = name of "x" item

Go to data/npcs and create a sex_changer.xml and place:
Code:
<?xml version="1.0"?>
<npc name="Lovely" script="data/npc/scripts/change_sex.lua" walkinterval="50000" floorchange="0">
<health now="100" max="100"/>
<look type="324" head="78" body="90" legs="0" feet="19" addons="1" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|.I {change} your sex!" /> 
</parameters>
</npc>

4)All in one:
Go to post: http://otland.net/f83/change-sex-per-items-premium-days-money-136936/#post1329126

READY!!

/s sex_changer
attachment.php


I know it's a simple NPCs, but many people may need it. If you help REP ++
 

Attachments

Last edited:
Thanks for posting this, it's something I have been looking for, for a long time.

Much better to have gender change by an npc instead of just a command
 
You should combine them all in to one NPC - let the player choose while speaking.
 
You should combine them all in to one NPC - let the player choose while speaking.

Here you are, not testei but should work...

4) All in one

goto data/npcs/scripts/npc.lua and create a change_sex.lua and paste:
Code:
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

[COLOR="#FF0000"][B]local priceindays = 3
local priceinmoney = 30000
local itemtochange = 9971
local counttochange = 10[/B]
[/COLOR]

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if(msgcontains(msg, 'changeperpremium') or msgcontains(msg, 'change_premmy')) then
selfSay('I can change your sex per '..priceindays..' days of premium account! Do you want?', cid)
talkState[talkUser] = 40
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 40) then
if(getPlayerSex(cid) >= 2) then
			selfSay('You cannot change your gender.', cid)
			return
		end

		if(getPlayerPremiumDays(cid) < priceindays) then
			selfSay('Sorry, not enough '..priceindays..' days of premium account.', cid)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
			return
		end

		if(getPlayerPremiumDays(cid) < 65535) then
			doPlayerAddPremiumDays(cid, -priceindays)
		end

		doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
		selfSay('You have changed your gender and lost '..priceindays..' days of premium time.', cid)
talkState[talkUser] = 0
		doSendMagicEffect(getCreaturePosition(cid), 35)
end

if(msgcontains(msg, 'changepermoney') or msgcontains(msg, 'change_money')) then
selfSay('I can change your sex per '..priceinmoney..' gold pieces! Do you want?', cid)
talkState[talkUser] = 4
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then
if(doPlayerRemoveMoney(cid, priceinmoney) == TRUE) then
doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
doSendMagicEffect(getCreaturePosition(cid), 35)
selfSay('You have changed your gender and lost '..priceinmoney..' days of premium time.', cid)
else
selfSay('Sorry, not enough '..priceinmoney..' gold pieces.', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end

if(msgcontains(msg, 'changeperitem') or msgcontains(msg, 'change_item')) then
selfSay('I can change your sex per '..counttochange..' ITEMNAME gold pieces! Do you want?', cid)
talkState[talkUser] = 7
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 7) then
if(getPlayerItemCount(cid, itemtochange) >= counttochange) then
doPlayerRemoveItem(cid, itemtochange, counttochange)
doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
doSendMagicEffect(getCreaturePosition(cid), 35)
selfSay('You have changed your gender and lost '..counttochange..' ITEMNAME.', cid)
else
selfSay('Sorry, not enough '..counttochange..' of ITEMNAME.', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

and go to data/npcs and create a sex_changer.xml and paste:
Code:
<?xml version="1.0"?>
<npc name="Lovely" script="data/npc/scripts/change_sex.lua" walkinterval="50000" floorchange="0">
<health now="100" max="100"/>
<look type="324" head="78" body="90" legs="0" feet="19" addons="1" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|.I change your sex: per item({change_item}), per money ({change_money}) and per premium account days ({change_premmy})" /> 
</parameters>
</npc>
 
Back
Top