Conditional Statement Regarding Class [Resolved] menu

User Tag List

Results 1 to 4 of 4
  1. #1
    Devoncroix's Avatar Private
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Conditional Statement Regarding Class [Resolved]

    I've been reading over several different threads explaining certain aspects of lua scripting and while reading I thought maybe I should use a conditional statement so that only Shamans receive the Gossip menu item that will add totems to their inventory.

    Reading into GetPlayerClass() will return a number of the class, So I created a shaman and checked in my database and saw that the shaman I created had the value of "7" in the class column. So i plugged that into my script and this is what I have for the moment. Problem is that it is not showing for the shaman I created once I restarted the server and what not.

    Code:
            if(player:GetPlayerClass() == 7) then
                    unit:GossipMenuAddItem(1, "Totems please!", 12, 0)
            end
    Any insight and/or suggestions would be greatly appreciated.
    Last edited by Devoncroix; 09-13-2010 at 04:39 AM.

    Conditional Statement Regarding Class [Resolved]
  2. #2
    Zymus's Avatar Active Member
    Reputation
    15
    Join Date
    Sep 2009
    Posts
    87
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know how WoW server's are programmed, but I think it should be
    Code:
            if(player:GetPlayerClass() == 7) then
                    playerGossipMenuAddItem(1, "Totems please!", 12, 0);<-- not sure if there's supposed to be a semi-colon here. also, what is the 1, 12, and 0?
            end

  3. #3
    Devoncroix's Avatar Private
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well the documentation that I read on GetPlayerClass() was actually wrong, I tried this and it worked like a charm.

    Code:
        if(player:GetPlayerClass() == "Shaman") then
            unit:GossipMenuAddItem(1, "Totems please!", 12, 0)
        end
    and to answer your question the "1" is the icon next to the option on the menu and "12" is a value thats being passed to a variable so that the script knows which option was clicked and therefore knows what operations to perform and so this is what 12 is.

    Code:
    if(intid == 12) then
            player:RemoveItem(5177,1)
            player:RemoveItem(5178,1)
            player:RemoveItem(5175,1)
            player:RemoveItem(5176,1)
            player:AddItem(5177,1)
            player:AddItem(5178,1)
            player:AddItem(5175,1)
            player:AddItem(5176,1)
            player:GossipComplete()
    end
    Basically removes the four totems and then gives them back. This is so a player does not get more of the totem, Cause as you may or may not be aware, Totems cant be deleted or destroyed from your inventory. At least not when I tried which was why I did it like that.

  4. #4
    Zymus's Avatar Active Member
    Reputation
    15
    Join Date
    Sep 2009
    Posts
    87
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Couldn't you do something like:

    Code:
    int[] totems = new int[] {
        5175, 5176, 5177, 5178
    };
    for(int totem : totems) {
        if(!player.getInventory().contains(totem)) {
            player.getInventory().add(totem);
        } 
    }
    At least, that's what I would do so that it doesn't delete and add them every time. It only adds the ones that are missing. Assuming that there's enough space of course. So a modified version would be something like this:
    Code:
    int[] totems = new int[] {//Declare the totem IDs
        5175, 5176, 5177, 5178
    };
    for(int totem : totems) {//cycle through every totem in totems
        if(!player.getInventory().contains(totem)) {//if the player doesn't have the totem in their inventory
            if(player.getInventory().freeSlots() >= 1) {//if there's at least one slot available
                player.getInventory().add(totem);//add the totem to their inventory
    	}
        } 
    }
    	
    //OR*************
    int[] totems = new int[] {//Declare the totem IDs
        5175, 5176, 5177, 5178
    };
    if(player.getInventory().getFreeSlots() < 4) {
        player.sendWarning("You don't have enough room");
    } else {
        for(int totem : totems) {//cycle through every totem in totems
            if(!player.getInventory().contains(totem)) {//if the player doesn't have the totem in their inventory
                if(player.getInventory().freeSlots() >= 1) {//if there's at least one slot available
                    player.getInventory().add(totem);//add the totem to their inventory
                }
            }
        }
    Last edited by Zymus; 09-13-2010 at 04:48 AM.

Similar Threads

  1. [Trinity] A few questions regarding class quests and mail system 3.3.5
    By Visarion in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 10-26-2013, 08:35 AM
  2. [C++] Need help regarding classes
    By klamor in forum Programming
    Replies: 2
    Last Post: 10-20-2010, 05:17 PM
  3. What class do you play as?
    By janzi9 in forum Community Chat
    Replies: 28
    Last Post: 11-13-2006, 04:03 PM
  4. Whats your favorite class?
    By Bossman4 in forum World of Warcraft General
    Replies: 32
    Last Post: 11-07-2006, 09:48 AM
  5. Full Guide for Dungeon Set 1 items (all classes)
    By Cush in forum World of Warcraft Guides
    Replies: 13
    Last Post: 09-07-2006, 03:07 PM
All times are GMT -5. The time now is 03:40 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search