Jump to content
  • 0

Change Sex Script Problem


protoftw

Question

So here's a script for changing sex but i cant make it work ...any suggestions??

 

Anyone who could help let me know :)

 

ERROR:  https://postimg.org/image/43usurd33/

 

CODE:
 

import sys
from com.l2jfrozen import Config
from com.l2jfrozen.util.database import L2DatabaseFactory
from com.l2jfrozen.gameserver.datatables.sql import CharTemplateTable
from com.l2jfrozen.gameserver.communitybbs.Manager import RegionBBSManager
from com.l2jfrozen.gameserver.model import L2World
from com.l2jfrozen.gameserver.model.quest import State
from com.l2jfrozen.gameserver.model.quest import QuestState
from com.l2jfrozen.gameserver.model.quest.jython import QuestJython as JQuest
from com.l2jfrozen.gameserver.network.serverpackets import EtcStatusUpdate
from com.l2jfrozen.gameserver.network.serverpackets import PledgeShowInfoUpdate
from com.l2jfrozen.util.random import Rnd

qn = "8700_Services"

NPC = 300300


# Items
Item = 57
GenreCount = 10

print "INFO Loaded: 8700_Services"

def AutoChat(npc, text) :
  chars = npc.getKnownList().getKnownPlayers().values().toArray()
  if chars != None :
    for pc in chars :
      sm = NpcSay(npc.getObjectId(), 0, npc.getNpcId(), text)
      pc.sendPacket(sm)

class Quest (JQuest) :

  def __init__(self, id, name, descr) :
    JQuest.__init__(self, id, name, descr)

  def onAdvEvent(self, event, npc, player) :
    st = player.getQuestState(qn)
    htmltext = event

    if event == "changeGenre" :
      if st.getQuestItemsCount(Item) < GenreCount :
        htmltext = "cant.htm"
      elif player.isCursedWeaponEquipped() :
        AutoChat(npc, player.getName()+" you can't change your genre when you are equipped with a Cursed Weapon.")
        htmltext = "cant.htm"
      else :
        if player.getAppearance().getSex() == 1 :
          newGenre = 0
        else :
          newGenre = 1
        con = L2DatabaseFactory.getInstance().getConnection(None)
        offline = con.prepareStatement("UPDATE characters SET sex = ? WHERE charId = ?")
        offline.setInt(1, newGenre)
        offline.setInt(2, player.getObjectId())
        try :
          offline.executeUpdate()
          offline.close()
          con.close()
        except :
          try : con.close()
          except : pass
        player.store()
        player.broadcastUserInfo()
        player.decayMe()
        player.spawnMe(player.getX(), player.getY(), player.getZ())
	st.takeItems(Item, GenreCount)
        st.playSound("ItemSound.quest_finish")
        return "2.htm"
        st.exitQuest(1)
    
  
    
  
  def onTalk(self, npc, player) :
    htmltext = ""
    st = player.getQuestState(qn)
    if not st :
      st = self.newQuestState(player)
    htmltext = "2.htm"
    st.playSound("ItemSound.quest_accept")
    return htmltext

QUEST = Quest(8700,qn,"custom")

QUEST.addStartNpc(NPC)

QUEST.addTalkId(NPC)
Edited by protoftw
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

 

So here's a script for changing sex but i cant make it work ...any suggestions??

 

Anyone who could help let me know :)

 

ERROR:  https://postimg.org/image/43usurd33/

 

CODE:

 

import sys
from com.l2jfrozen import Config
from com.l2jfrozen.util.database import L2DatabaseFactory
from com.l2jfrozen.gameserver.datatables.sql import CharTemplateTable
from com.l2jfrozen.gameserver.communitybbs.Manager import RegionBBSManager
from com.l2jfrozen.gameserver.model import L2World
from com.l2jfrozen.gameserver.model.quest import State
from com.l2jfrozen.gameserver.model.quest import QuestState
from com.l2jfrozen.gameserver.model.quest.jython import QuestJython as JQuest
from com.l2jfrozen.gameserver.network.serverpackets import EtcStatusUpdate
from com.l2jfrozen.gameserver.network.serverpackets import PledgeShowInfoUpdate
from com.l2jfrozen.util.random import Rnd

qn = "8700_Services"

NPC = 300300


# Items
Item = 57
GenreCount = 10

print "INFO Loaded: 8700_Services"

def AutoChat(npc, text) :
  chars = npc.getKnownList().getKnownPlayers().values().toArray()
  if chars != None :
    for pc in chars :
      sm = NpcSay(npc.getObjectId(), 0, npc.getNpcId(), text)
      pc.sendPacket(sm)

class Quest (JQuest) :

  def __init__(self, id, name, descr) :
    JQuest.__init__(self, id, name, descr)

  def onAdvEvent(self, event, npc, player) :
    st = player.getQuestState(qn)
    htmltext = event

    if event == "changeGenre" :
      if st.getQuestItemsCount(Item) < GenreCount :
        htmltext = "cant.htm"
      elif player.isCursedWeaponEquipped() :
        AutoChat(npc, player.getName()+" you can't change your genre when you are equipped with a Cursed Weapon.")
        htmltext = "cant.htm"
      else :
        if player.getAppearance().getSex() == 1 :
          newGenre = 0
        else :
          newGenre = 1
        con = L2DatabaseFactory.getInstance().getConnection(None)
        offline = con.prepareStatement("UPDATE characters SET sex = ? WHERE charId = ?")
        offline.setInt(1, newGenre)
        offline.setInt(2, player.getObjectId())
        try :
          offline.executeUpdate()
          offline.close()
          con.close()
        except :
          try : con.close()
          except : pass
        player.store()
        player.broadcastUserInfo()
        player.decayMe()
        player.spawnMe(player.getX(), player.getY(), player.getZ())
	st.takeItems(Item, GenreCount)
        st.playSound("ItemSound.quest_finish")
        return "2.htm"
        st.exitQuest(1)
    
  
    
  
  def onTalk(self, npc, player) :
    htmltext = ""
    st = player.getQuestState(qn)
    if not st :
      st = self.newQuestState(player)
    htmltext = "2.htm"
    st.playSound("ItemSound.quest_accept")
    return htmltext

QUEST = Quest(8700,qn,"custom")

QUEST.addStartNpc(NPC)

QUEST.addTalkId(NPC)

con = L2DatabaseFactory.getInstance().getConnection(None) // delete none

Link to comment
Share on other sites

  • 0

now there are no problems but ,

the char is not changing sex ..all i get is the respawn

before player.store()

add this

player.getAppearance().setSex(newGenre)
Edited by melron
Link to comment
Share on other sites

  • 0

i was trying with the first one u said but then i saw u edited ur post and i was like cmon ...make it work hahaha

so now it;s working great !! ty :) :)

Link to comment
Share on other sites

  • 0

there;s a script error when u are equipped with cursed weapons(akamanah/zarihe) and you are trying to change sex

 

https://postimg.org/image/wlqltfs6x/

 

 

also how i can make the code get the char kicked after changing sex ??and also showing a message that he is going to get kicked

Edited by protoftw
Link to comment
Share on other sites

  • 0

there;s a script error when u are equipped with cursed weapons(akamanah/zarihe) and you are trying to change sex

 

https://postimg.org/image/wlqltfs6x/

 

 

also how i can make the code get the char kicked after changing sex ??and also showing a message that he is going to get kicked

drop the message, player.logout(true);

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Posts

    • I am selling the essence project which includes versions 388 and 439 that have been running for over 2 years or (447 as custom PVP like Pride). I have a test server for you to test them out. If you are really interested in it then contact my seller at discord: kiwi7106. Price: 4000 Euro P/s: This is a project that I have spent a lot of money and time developing, so if you are not interested in it, please get out of this topic, thank you. P/s 2: If you find the price too expensive, it's best to skip this article and find another project and don't comment negatively on my topic, thank you.
    • Someone ask me for this, it should work on any client that has Kamael race, preview:     Installation - there are two ways to install depending on how you want to use it:   Method 1: If you want to completely replace the original, do:   Copy all lines from your armorgrp to Notepad++, press Ctrl+H, check the "match whole word" option and replace:   kamael.Mkamael_m000_w_ad00   by:   AvengersKamaelWings.Avengers_MKamael_m001_w_ad00   Then replace:   MKamael.Mkamael_m000_t00_w   by:   AvengersKamaelWings.MKamael_m001_t00_w   Now repeat the same process with the female, replace:   kamael.Fkamael_m000_w_ad00   by:   AvengersKamaelWings.Avengers_FKamael_m001_w_ad00   Then replace:   FKamael.Fkamael_m000_t00_w   by:   AvengersKamaelWings.FKamael_m001_t00_w   You're done, paste everything back into File Edit and save!   Method 2: If you only want to replace in specific sets, execute the above process only on the armorgrp of those sets.   Repack by: AvengersTeamBr Password: LadrãoDeFrango      
    • 用于解密、加密和编辑 .u 文件的工具。
    • It's always awesome when you find someone who not only delivers great quality but also does it way ahead of schedule. Makes you feel like you hit the jackpot, right? I'm new around here, just stumbled upon this forum, and seeing posts like yours really gives me hope that there are some real pros hanging out in this community.
  • Topics

×
×
  • Create New...