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

Why cant it change back?

Exiled Pain

Fervid Learner
Joined
Jan 8, 2008
Messages
552
Reaction score
4
Sup, I'm using this to change characters sex with an item, It works fine to jump to the next sex section, but It won't go back to the original sex...

Females standard sex is = 0 and secundary is = 2
Males standard sex is = 1 and secundary is = 3

So it works, but when I try to go back from 2 -> 0 or from 3->1 it won't change. Please help.

Code:
function onUse(cid, item, frompos, item2, topos)
  local playerPos = getCreaturePosition(cid)
  local playerSex = getPlayerSex(cid)
		if playerSex == 0 then --female 1
			doPlayerSetSex(cid, 2)
			doRemoveCreature(cid,true)
		elseif playerSex == 2 then --female 2
			doPlayerSetSex(cid, 0)
			doRemoveCreature(cid,true)
		elseif playerSex == 1 then --male 1
			doPlayerSetSex(cid, 3)
			doRemoveCreature(cid,true)
		elseif playerSex == 3 then --male 2
			doPlayerSetSex(cid, 1)

		else --other sex
			doSendAnimatedText(playerPos, 'Cant change', TEXTCOLOR_GOLD)
		end
	return TRUE
end
 
Try this

Try this man, it is a mod. Open a XML file in your mod folder and add this:
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Change Sex System" version="1.0" author="Yohan" contact="otland.net" enabled="yes">
	<config name="sex_config"><![CDATA[
		config = {
			female1 = 0
			female2 = 2
			male1 = 1
			male2 = 3
		}
	]]></config>
	<event type="use" name="ChangeSex" event="script"><![CDATA[
		domodlib('sex_config')

		function onUse(cid, item, frompos, item2, topos)

                if item.itemid == XXXX then -- change here
		if getPlayerSex(cid) == config.female1 then
		doPlayerSetSex(cid, config.female2)
		elseif getPlayerSex(cid) == config.female2 then
		doPlayerSetSex(cid, config.female1)
		end

		if getPlayerSex(cid) == config.male1 then
		doPlayerSetSex(cid, config.male2)
		elseif getPlayerSex(cid) == config.male2 then
		doPlayerSetSex(cid, config.male1)
		end

		doSendAnimatedText(getPlayerPosition(cid), "Can't change", TEXTCOLOR_GOLD)

                end
		return true
		end
	]]></event>
</mod>
And then put in your actions.xml a tag with the itemid of the item...
then save and start you OT... Intending to have helped...
 
Back
Top