[Lua] Saving Values per player? menu

Shout-Out

User Tag List

Results 1 to 5 of 5
  1. #1
    thetrueman2's Avatar Active Member
    Reputation
    16
    Join Date
    Nov 2008
    Posts
    26
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Lua] Saving Values per player?

    Hello Mmowned

    I'm abit stuck on a luascript im working on. The idea is to create 2 objects, which are spawned in Booty bay and Everlook. the player has to follow hints throughout azeroth to reach the other object, and if both of them are clicked the player gets a collectors item as reward.

    There is a problem tho.. if a player (we'll call him player 1) clicks the object in BB, and another player (player 2) clicks the object in everlook player 2 gets the reward straight away, because player 1 has set the local value for BB to 1 for "has clicked it"

    is there a way to save the values per player, or a workaround so everyone has to click both?

    teh code:

    Code:
    local GO_Explore1_ID = 17189225
    local GO_Explore2_ID = 17189226
    local ClickedObject1 = 0
    local ClickedObject2 = 0
    
    function ClickObject_Everlook(pGameObject, Event, Player)
      if (Player:GetItemCount(870263) >= 1) then
        Player:SendBroadcastMessage("You already have the reward!")
      else
       ClickedObject1 = 1
         Player:SendBroadcastMessage("Congratulations! A Pet has been added to your inventory.")
           if (ClickedObject1 == 1) and (ClickedObject2 == 1) then
             Player:AddItem(870263, 1)
           end
      end
    end
    
    function ClickObject_Bootybay(pGameObject, Event, Player)
      if (Player:GetItemCount(870263) >= 1) then
        Player:SendBroadcastMessage("You already have the reward!")
      else
       ClickedObject2 = 1
         Player:SendBroadcastMessage("Congratulations! A Pet has been added to your inventory.")
           if (ClickedObject1 == 1) and (ClickedObject2 == 1) then
             Player:AddItem(870263, 1)
           end
      end
    end
    
    RegisterGameObjectEvent(GO_Explore1_ID, 4, "ClickObject_Everlook")
    RegisterGameObjectEvent(GO_Explore2_ID, 4, "ClickObject_Bootybay")
    Ofcourse +rep to those that try to help

    thanks!
    If you’re going to convict us, convict us of disorganised crime. - Peter Sunde

    [Lua] Saving Values per player?
  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)
    top of script:

    local PlayerA = nil

    function blablabla
    if playerA == nil then
    playerA = Player
    end
    do stuff
    end

    then later on / in same function if you want to check if it is the same player:

    if playerA ~= Player then
    do stuff
    end

    since the variable we assigned can not be the variable that is using the gossip menu.

    If you want to make it for lots of people, save the players guid (Player:GetGuid()) into a table then if the guid isn't in the table do stuff, if his guide is in the table then don't do stuff. >.>

    Hope that explains a solution ish, I only skim read your post!

  3. #3
    Dynashock's Avatar Contributor

    Reputation
    176
    Join Date
    Nov 2007
    Posts
    203
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd recommend the table solution as it would support an unlimited amount of players (well, until you run out of memory eh). You can either use the player's guid, as stone pointed out, or the userdata cast to a string, like tostring(Player).
    Ignorance is bliss.

  4. #4
    thetrueman2's Avatar Active Member
    Reputation
    16
    Join Date
    Nov 2008
    Posts
    26
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've never used tables before with lua, so that's going to be.. interesting
    but I guess there are plenty of tuts out there on how to, so I'll get to work.

    +Rep to both (also to stone once I spread some more ><)

    thanks alot
    If you’re going to convict us, convict us of disorganised crime. - Peter Sunde

  5. #5
    Kirth's Avatar Active Member
    Reputation
    58
    Join Date
    Nov 2007
    Posts
    274
    Thanks G/R
    2/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Dynashock View Post
    I'd recommend the table solution as it would support an unlimited amount of players (well, until you run out of memory eh). You can either use the player's guid, as stone pointed out, or the userdata cast to a string, like tostring(Player).
    If said table get's a bit too stuffed, or when one'd be dealing with a large player base: use of the SQL database would be useful .

    Either cache a part of the table, or immediately store the information in the database. (Seperate table?). I think the method for that would be CharDBQuery().



Similar Threads

  1. Can Lua detect when a player gets an honorable kill?
    By Wheeze201 in forum WoW EMU Questions & Requests
    Replies: 4
    Last Post: 07-31-2009, 07:22 AM
  2. LUA Teleporter Get the players Faction
    By Yoshiya in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 04-09-2009, 10:16 AM
  3. [Request] Per-Player-Uplink Charts
    By Submit in forum WoW EMU Questions & Requests
    Replies: 0
    Last Post: 03-03-2009, 02:41 PM
  4. [C++ and LUA Patch] 6 Custom Player Functions
    By Gastricpenguin in forum WoW EMU General Releases
    Replies: 10
    Last Post: 03-02-2009, 08:06 AM
  5. LUA command that makes players pay ?
    By Wheeze201 in forum WoW EMU Questions & Requests
    Replies: 5
    Last Post: 01-18-2009, 04:07 AM
All times are GMT -5. The time now is 08:33 AM. 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