• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Gender changer

4Muki4

HOROHOROHORO
Joined
May 1, 2012
Messages
757
Reaction score
72
im looking for an easy script

item id XXXX i click on it so changes your gender

1.should have 1 minute exhaust
2.can be used 5 times

rep++ ofc who can solve this to me
 
Edit: removed old script, it's not what author requested
I'm almost done with new one and I'll edit this post within 30 minutes
working on addEvent to make exhaust

Edit2: done
actions.xml:
XML:
<action itemid="xxxx" event="script" value="genderchange.lua"/>
xxxx is your itemid

genderchange.lua:

Edit3: works if player doesn't log out, if he does addevent returns console error and makes his status pernament exhausted, I have no idea how to fix it, tried with exhaust condition, but it poisons player instead

here is script without exhaustion:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local firstaction = 11985 -- actionid which begins charges chain
local limit = 5 -- charges of item
setConditionParam(exhaust, CONDITION_PARAM_TICKS, exhausttime * 60 * 1000)

		if (item.actionid < limit + firstaction) then
			doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
			if item.actionid < firstaction then
				doSetItemActionId(item.uid, firstaction + 2)
					if limit - 1 == 1 then
					plural = ''
					else
					plural = 's'
					end
				doCreatureSay(cid, 'You have changed your gender. The item has ' .. limit - 1 .. ' charge' .. plural .. ' left.', TALKTYPE_ORANGE_1)
				doSetItemSpecialDescription(item.uid, 'It has ' .. limit -1 ..' charge' .. plural .. ' left.')
			else
				doSetItemActionId(item.uid, item.actionid + 1)
					if ((firstaction + limit) - item.actionid) == 1 then
					plural = ''
					else
					plural = 's'
					end
				doCreatureSay(cid, 'You have changed your gender. The item has ' .. ((firstaction + limit) - item.actionid) .. ' charge'.. plural ..' left.', TALKTYPE_ORANGE_1)
				doSetItemSpecialDescription(item.uid, 'It has ' .. (firstaction + limit) - item.actionid ..' charge'.. plural ..' left.')
			end
		else
		doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
		doRemoveItem(item.uid, 1)
		doCreatureSay(cid, 'You have changed your gender. The item is out of charges.', TALKTYPE_ORANGE_1)
		end
	return true
end
 
Last edited:
Edit: removed old script, it's not what author requested
I'm almost done with new one and I'll edit this post within 30 minutes
working on addEvent to make exhaust

Edit2: done
actions.xml:
XML:
<action itemid="xxxx" event="script" value="genderchange.lua"/>
xxxx is your itemid

genderchange.lua:

Edit3: works if player doesn't log out, if he does addevent returns console error and makes his status pernament exhausted, I have no idea how to fix it, tried with exhaust condition, but it poisons player instead

here is script without exhaustion:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local firstaction = 11985 -- actionid which begins charges chain
local limit = 5 -- charges of item
setConditionParam(exhaust, CONDITION_PARAM_TICKS, exhausttime * 60 * 1000)

		if (item.actionid < limit + firstaction) then
			doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
			if item.actionid < firstaction then
				doSetItemActionId(item.uid, firstaction + 2)
					if limit - 1 == 1 then
					plural = ''
					else
					plural = 's'
					end
				doCreatureSay(cid, 'You have changed your gender. The item has ' .. limit - 1 .. ' charge' .. plural .. ' left.', TALKTYPE_ORANGE_1)
				doSetItemSpecialDescription(item.uid, 'It has ' .. limit -1 ..' charge' .. plural .. ' left.')
			else
				doSetItemActionId(item.uid, item.actionid + 1)
					if ((firstaction + limit) - item.actionid) == 1 then
					plural = ''
					else
					plural = 's'
					end
				doCreatureSay(cid, 'You have changed your gender. The item has ' .. ((firstaction + limit) - item.actionid) .. ' charge'.. plural ..' left.', TALKTYPE_ORANGE_1)
				doSetItemSpecialDescription(item.uid, 'It has ' .. (firstaction + limit) - item.actionid ..' charge'.. plural ..' left.')
			end
		else
		doPlayerSetSex(cid, getPlayerSex(cid) == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
		doRemoveItem(item.uid, 1)
		doCreatureSay(cid, 'You have changed your gender. The item is out of charges.', TALKTYPE_ORANGE_1)
		end
	return true
end

this script didnt work.

its for TFS 0.4
 
For 0.3 and 0.4 you can use this for exhaustion
LUA:
if exhaustion.check(cid, 1000) then
	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	doPlayerSendCancel(cid, "You need to wait "..exhaustion.get(cid, 1000).." seconds before you can use it again.")
	return true
end

exhaustion.set(cid, 1000, 60)
 
Last edited:
any console errors?


sorry for late response was afk

only 1 error

PHP:
[error - Action interface]
data/actions/scripts/genderchange.lua:onUse
Description:
Data/actions/scripts/genderchange.lua:4: attempt to preform arithmetic on global 'exhausttime' <a nill value>
stack trackback:
data/actions/scripts/genderchange.lua:4 in function <data/actions/scripts/genderchange.lua:1>

- - - Updated - - -

For 0.3 and 0.4 you can use this for exhaustion
LUA:
if exhaustion.check(cid, 1000) then
	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	doPlayerSendCancel(cid, "You need to wait "..exhaustion.get(cid, 1000).." before you can use it again.")
	return true
end

exhaustion.set(cid, 1000, 60)

Will try this and get back to you guys.

- - - Updated - - -

Dont know where to put ur exhaust bit
 
Back
Top