Lua Table menu

User Tag List

Thread: Lua Table

Results 1 to 4 of 4
  1. #1
    ak47sigh's Avatar Corporal
    Reputation
    12
    Join Date
    Jun 2011
    Posts
    20
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lua Table

    How can I get the players from the database table using only names?


    It looks like this code:
    I want to get all the players from there, multiply.

    Code:
    GetNPlayers = CharDBQuery("SELECT * FROM table_name;") -- getting table
    NPlayers = GetNPlayers:GetColumn(1):GetString() -- this column stores character name
     plr = GetPlayer(NPlayers)
    
    if(NPlayers == nil) then
    -- nothing
    else
    plr:SendBroadcastMessage("Hello")
    end


    I have tried with this too:

    Code:
    for k,v in ipairs(NPlayers) do
    end
    If anyone could help, I will appreciate

    Lua Table
  2. #2
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Well this is a really, really bad way to do this. Whatever you are using this for, you should think of redesigning the system.

    However in answer to your question:

    Code:
    local GetNPlayers = CharDBQuery("SELECT `name` FROM `table_name`;") -- getting table
    local NPlayers = GetNPlayers:GetColumn(1):GetString() -- this column stores character name
    
    if NPlayers then
    	local player = nil
    	for _,plr in pairs(GetPlayersInWorld()) do
    		if plr:GetName() == NPlayers then
    			player = plr
    			break
    		end
    	end
    	if player then
    		player:SendBroadcastMessage("Hello")
    	end
    end

  3. #3
    ak47sigh's Avatar Corporal
    Reputation
    12
    Join Date
    Jun 2011
    Posts
    20
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using for a battleground que and solved. Thanks alot , Rochet helped me

  4. #4
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ak47sigh View Post
    Using for a battleground que and solved. Thanks alot , Rochet helped me
    Why would you use SQL for a battleground queue?

Similar Threads

  1. [Question] Lua Callback: Return table of values
    By DrakeFish in forum WoW Memory Editing
    Replies: 6
    Last Post: 06-18-2011, 10:44 PM
  2. [Lua Script] Lua Tables.
    By shadowslayer133 in forum WoW EMU Questions & Requests
    Replies: 0
    Last Post: 06-08-2010, 04:38 PM
  3. [Release] LUA-Commands as SQL DB-Table
    By sheepking in forum WoW EMU General Releases
    Replies: 4
    Last Post: 10-16-2009, 07:46 AM
  4. [Lua] A small introduction to tables
    By Dynashock in forum WoW EMU Guides & Tutorials
    Replies: 10
    Last Post: 07-12-2009, 06:31 PM
  5. Table Of Contents
    By oninuva in forum World of Warcraft Guides
    Replies: 0
    Last Post: 04-23-2006, 01:45 PM
All times are GMT -5. The time now is 08:36 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