User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 7 of 9

Thread: 2.4.3 Race Change Script

  1. #1
    Emulation Addict
    Join Date
    Jul 2016
    Posts
    34
    XP
    535
    Level
    5
    Thanks
    7
    Thanked 4 Times in 2 Posts

    2.4.3 Race Change Script

    Hello,

    I've been using this forum for a while now along my brother and still haven't made an account Anyways, him and I attempted to code a Race/Faction changer. It seems that it doesn't execute the actual SQL Query or if it does when the player gets kicked, it gets overridden?
    We have been stumped for quite a while about this and would like any assistance at all
    Code:
    --[[
    
    	Race Change Script
    	Developed for CMaNGOS 2.4.3
    	
    	Developers: Grim, Render1982
    	
    ]]
    
    
    local NPC_ENTRY = 60010
    
    function ChangeRaceMenu(event, player, unit)
        if player:GetGender() == 0 then
            player:GossipMenuAddItem(0, "Change Race to Orc", 0, 1)
      --  else
     --       player:GossipMenuAddItem(0, "Change Race to Human", 0, 2)
        end
        player:GossipMenuAddItem(0, "Nevermind..", 0, 3)
        player:GossipSendMenu(1, unit)
    end
    
    function ChangeRaceSelect(event, player, unit, sender, intid, code)
        if (intid == 1) then
    		player:KickPlayer()
    		CharDBQuery("UPDATE `characters`.`characters` SET `race`=2 WHERE  `guid`="..player:GetGUIDLow()..";")
       -- elseif (intid == 2) then
    		
       -- elseif (intid == 3) then
         
        end
    end
    
    
    RegisterCreatureGossipEvent(NPC_ENTRY, 1, ChangeRaceMenu)
    RegisterCreatureGossipEvent(NPC_ENTRY, 2, ChangeRaceSelect)
    EDIT: If the GUID is set to default value other than the current player's GUID it works without a flaw. Might've also wanted to pointed that out
    Last edited by Grim; 07-19-2016 at 04:31 AM.
    Achievements:
    Level I Member 3 months registered Level V

  2. #2
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Posts
    7,391
    XP
    3,449,104
    Level
    378
    Thanks
    889
    Thanked 1,858 Times in 1,120 Posts
    Why not tell the player to relog in a message instead of kicking them? The logic behind that script is that you are kicking the player before you run the query, so I don't think it will work like that since the player is no longer in the world when you are trying to use the player variable. You could probably create a timed event and when the query executes then kick the player.

  3. The Following 2 Users Say Thank You to Tommy For This Useful Post:


  4. #3
    Exalted Member Syphex's Avatar
    Join Date
    Dec 2014
    Location
    Sweden GMT + 1
    Posts
    302
    XP
    169,161
    Level
    105
    Thanks
    50
    Thanked 37 Times in 29 Posts
    As Tommy said, tell the player to relog, i find nothing worse than being forced of the server rather than willingly.
    Look at it from the bright side, when blizzard did race,faction changes etc back in the days you even had to log out from your account for the changes and updates to work.

  5. The Following User Says Thank You to Syphex For This Useful Post:


  6. #4
    Original Poster
    Emulation Addict
    Join Date
    Jul 2016
    Posts
    34
    XP
    535
    Level
    5
    Thanks
    7
    Thanked 4 Times in 2 Posts
    Code:
    --[[
    
    	Race Change Script
    	Developed for CMaNGOS 2.4.3
    	
    	Developers: Grim, Render1982
    	
    ]]
    
    
    local NPC_ENTRY = 60010
    
    function ChangeRaceMenu(event, player, unit)
        if player:GetGender() == 0 then
            player:GossipMenuAddItem(0, "Change Race to Orc", 0, 1)
      --  else
     --       player:GossipMenuAddItem(0, "Change Race to Human", 0, 2)
        end
        player:GossipMenuAddItem(0, "Nevermind..", 0, 3)
        player:GossipSendMenu(1, unit)
    end
    
    function ChangeRaceSelect(event, player, unit, sender, intid, code)
        if (intid == 1) then
    	local pGUID = player:GetGUIDLow()
    		CharDBQuery("UPDATE `characters`.`characters` SET `race`=2 WHERE  `guid`="..pGUID..";")
    		player:SendBroadcastMessage("|cFFFFA500Please Relog!")
       -- elseif (intid == 2) then
    		
       -- elseif (intid == 3) then
         
        end
    end
    
    
    RegisterCreatureGossipEvent(NPC_ENTRY, 1, ChangeRaceMenu)
    RegisterCreatureGossipEvent(NPC_ENTRY, 2, ChangeRaceSelect)
    Still doesn't do anything. I think the problem was relogging cause it may be querying it then when the player logs out it saves the char to the DB which may override it.
    It simply just say "Please Relog" and when you do actually relog nothing happens.
    Last edited by Grim; 07-19-2016 at 02:36 PM.
    Achievements:
    Level I Member 3 months registered Level V

  7. #5
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Posts
    7,391
    XP
    3,449,104
    Level
    378
    Thanks
    889
    Thanked 1,858 Times in 1,120 Posts
    Quote Originally Posted by Grim View Post
    Code:
    --[[
    
    	Race Change Script
    	Developed for CMaNGOS 2.4.3
    	
    	Developers: Grim, Render1982
    	
    ]]
    
    
    local NPC_ENTRY = 60010
    
    function ChangeRaceMenu(event, player, unit)
        if player:GetGender() == 0 then
            player:GossipMenuAddItem(0, "Change Race to Orc", 0, 1)
      --  else
     --       player:GossipMenuAddItem(0, "Change Race to Human", 0, 2)
        end
        player:GossipMenuAddItem(0, "Nevermind..", 0, 3)
        player:GossipSendMenu(1, unit)
    end
    
    function ChangeRaceSelect(event, player, unit, sender, intid, code)
        if (intid == 1) then
    	local pGUID = player:GetGUIDLow()
    		CharDBQuery("UPDATE `characters`.`characters` SET `race`=2 WHERE  `guid`="..pGUID..";")
    		player:SendBroadcastMessage("|cFFFFA500Please Relog!")
       -- elseif (intid == 2) then
    		
       -- elseif (intid == 3) then
         
        end
    end
    
    
    RegisterCreatureGossipEvent(NPC_ENTRY, 1, ChangeRaceMenu)
    RegisterCreatureGossipEvent(NPC_ENTRY, 2, ChangeRaceSelect)
    Still doesn't do anything. I think the problem was relogging cause it may be querying it then when the player logs out it saves the char to the DB which may override it.
    It simply just say "Please Relog" and when you do actually relog nothing happens.
    Yeah, you'd have to probably give the player the race change flag. Not sure if you are wanting to do only Orc and Human race change which will make the race change flag pointless since you can change to any race you want.

  8. The Following User Says Thank You to Tommy For This Useful Post:


  9. #6
    Administrator
    Join Date
    May 2013
    Location
    yes
    Posts
    257
    XP
    1,838,387
    Level
    244
    Thanks
    6
    Thanked 110 Times in 67 Posts
    Just store the GUID in a variable before kicking the player and then use it in the query.

    If you plan on using all races and giving them the ability to customize the change, just give them the race change flag instead.

  10. The Following 2 Users Say Thank You to Jpp For This Useful Post:


  11. #7
    Original Poster
    Emulation Addict
    Join Date
    Jul 2016
    Posts
    34
    XP
    535
    Level
    5
    Thanks
    7
    Thanked 4 Times in 2 Posts
    So I added this line under the NPC entry variable and still got nothing.

    And this is patch 2.4.3 so the race change flag doesn't exist...yet.

    I did the orc and human as a test I'ma add the rest of races with a class check so people can't make Orc Paladins but, right now I'm just wanting to make it at least work with the script I got.
    Last edited by Grim; 07-19-2016 at 08:17 PM. Reason: Spelling Error
    Achievements:
    Level I Member 3 months registered Level V

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •