View difference between Paste ID: YxbSNRzW and 7HxUdJWD
SHOW: | | - or go back to the newest paste.
1-
--[[ 1 first is beginning section checking if the location exsists in the -->sql<-- 
1+
-- arcemu core using ALE
2-
     if it doesn't then it creates it using CreateLocation.
2+
3-
     if it does exsist then it gets location entryid using GetLocationId ]]--
3+
ACCDATA = {} -- Table that contains all data
4-
function GWcommands(event, pPlayer, msg, type, language)
4+
5-
local Xentrydb = WorldDBQuery("SELECT `entry` FROM guild_warz.zones WHERE `map_id` = '"..pPlayer:GetMapId().."' AND `area_id` = '"..pPlayer:GetAreaId().."' AND `zone_id` = '"..pPlayer:GetZoneId().."';");
5+
function LoadAccDataFromDB()
6-
	if(Xentrydb==nil)then
6+
    ACCDATA = {} -- For reload case, empty table
7-
		CreateLocation(pPlayer:GetMapId(), pPlayer:GetAreaId(), pPlayer:GetZoneId())
7+
    local Q = WorldDBQuery("SELECT acct, login, vip, votes, mg FROM logon.accounts;");
8-
		end
8+
    if(Q)then
9-
local LocId = GetLocationId(pPlayer)
9+
        repeat
10
            -- Save account data under account name in ACCDATA lua table
11-
--[[ 2 this again scans sql to get the location id.
11+
            local name = Q:GetColumn(1):GetString() -- (vip column) num value 1-20
12-
      I have been trying to get it to scan the table to match up the 
12+
            ACCDATA[name] = {
13-
       map,area,zone values to the players map,area,zone with no luck so far. 
13+
                acct = Q:GetColumn(0):GetULong(), -- (vip column) num value 1-20
14-
       if I can get it to find the location by table then I can 
14+
                vip = Q:GetColumn(2):GetULong(), -- (vip column) num value 1-20
15-
       get it to check if it exists in the table and if not then CreateLocation.
15+
                votes = Q:GetColumn(3):GetULong(), -- (vote column) total votes count
16-
	even tried to create a table just for this trying to use multiple keys(location mapid,areaid,zoneid
16+
                mg = Q:GetColumn(4):GetULong(), -- (mg column) total magic gold
17-
	but it fell flat on its face lol even tried sub table setup GWTloc.map.area.zone.Entryid
17+
            }
18-
local function GetLocationId(player, unit)
18+
        until not Q:NextRow()
19-
local Locdb=WorldDBQuery("SELECT `entry` FROM guild_warz.zones WHERE `map_id`='"..player:GetMapId().."' AND `area_id`='"..player:GetAreaId().."' and `zone_id`='"..player:GetZoneId().."';");
19+
    end
20-
return Locdb:GetColumn(0):GetULong() or 0;
20+
21
LoadAccDataFromDB()
22
23-
--[[ 3 this should be fine it does only insert/update
23+
function GetAcct(player)
24-
local function CreateLocation(map, area, zone)
24+
    -- Returns acct or 0
25-
local CLentrydb = WorldDBQuery("SELECT `entry` FROM guild_warz.zones;");
25+
    local name = player:GetAccountName()
26-
		repeat
26+
    return ACCDATA[name] and ACCDATA[name].acct or 0
27-
			CLentry = CLentrydb:GetColumn(0):GetLong()
27+
28-
			until(CLentrydb:NextRow()~=true)
28+
29-
	CLentry=(CLentry+1)
29+
function GetVip(player)
30-
	WorldDBQuery("INSERT INTO guild_warz.zones SET `entry` = '"..CLentry.."';");
30+
    -- Returns vip or 0
31-
	WorldDBQuery("UPDATE guild_warz.zones SET `map_id` = '"..map.."' WHERE `entry` = '"..CLentry.."';");
31+
    local name = player:GetAccountName()
32-
	WorldDBQuery("UPDATE guild_warz.zones SET `area_id` = '"..area.."' WHERE `entry` = '"..CLentry.."';");
32+
    return ACCDATA[name] and ACCDATA[name].vip or 0 
33-
	WorldDBQuery("UPDATE guild_warz.zones SET `zone_id` = '"..zone.."' WHERE `entry` = '"..CLentry.."';");
33+
34-
	WorldDBQuery("UPDATE guild_warz.zones SET `guild_name` = '"..Server.."' WHERE `entry` = '"..CLentry.."';");
34+
35-
	GWARZ[CLentry] = {}
35+
local function Viptest(event, pPlayer, msg, type, language)
36-
	GWARZ[CLentry].Entryid = CLentry
36+
    local command = ".vip"
37-
	GWARZ[CLentry].Mapid = map
37+
    if (msg == command)then
38-
	GWARZ[CLentry].Areaid = area
38+
        local name = pPlayer:GetAccountName()
39-
	GWARZ[CLentry].Zoneid = zone
39+
        print("acctid direct request value")
40-
	GWARZ[CLentry].Guildname = Server
40+
        print(ACCDATA[name]) -- table that contains the account data
41-
	GWARZ[CLentry].Team = 2
41+
        print(ACCDATA[name].acct) -- accessing data inside the table
42-
	GWARZ[CLentry].Buildingcnt = 0
42+
        print(ACCDATA[name].vip)
43-
	GWARZ[CLentry].Pigcnt = 0
43+
        print(ACCDATA[name].votes)
44-
	GWARZ[CLentry].Guardcnt = 0
44+
        print(ACCDATA[name].mg)
45-
	GWARZ[CLentry].Flagid = 0
45+
        print()
46-
print(""..CLentry..": created")	
46+
        print("custom function request values")
47-
end
47+
        print(GetAcct(player))
48
        print(GetVip(player))
49
        print()
50
        print("Alternate way to print contents")
51
        for k, v in pairs(ACCDATA[name] or {}) do
52
            print(k, v)
53
        end
54
    end
55
end
56
57
RegisterServerHook(16, Viptest)