Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ 1 first is beginning section checking if the location exsists in the -->sql<--
- if it doesn't then it creates it using CreateLocation.
- if it does exsist then it gets location entryid using GetLocationId ]]--
- function GWcommands(event, pPlayer, msg, type, language)
- local Xentrydb = WorldDBQuery("SELECT `entry` FROM guild_warz.zones WHERE `map_id` = '"..pPlayer:GetMapId().."' AND `area_id` = '"..pPlayer:GetAreaId().."' AND `zone_id` = '"..pPlayer:GetZoneId().."';");
- if(Xentrydb==nil)then
- CreateLocation(pPlayer:GetMapId(), pPlayer:GetAreaId(), pPlayer:GetZoneId())
- end
- local LocId = GetLocationId(pPlayer)
- --[[ 2 this again scans sql to get the location id.
- I have been trying to get it to scan the table to match up the
- map,area,zone values to the players map,area,zone with no luck so far.
- if I can get it to find the location by table then I can
- get it to check if it exists in the table and if not then CreateLocation.
- even tried to create a table just for this trying to use multiple keys(location mapid,areaid,zoneid
- but it fell flat on its face lol even tried sub table setup GWTloc.map.area.zone.Entryid
- local function GetLocationId(player, unit)
- local Locdb=WorldDBQuery("SELECT `entry` FROM guild_warz.zones WHERE `map_id`='"..player:GetMapId().."' AND `area_id`='"..player:GetAreaId().."' and `zone_id`='"..player:GetZoneId().."';");
- return Locdb:GetColumn(0):GetULong() or 0;
- end
- --[[ 3 this should be fine it does only insert/update
- local function CreateLocation(map, area, zone)
- local CLentrydb = WorldDBQuery("SELECT `entry` FROM guild_warz.zones;");
- repeat
- CLentry = CLentrydb:GetColumn(0):GetLong()
- until(CLentrydb:NextRow()~=true)
- CLentry=(CLentry+1)
- WorldDBQuery("INSERT INTO guild_warz.zones SET `entry` = '"..CLentry.."';");
- WorldDBQuery("UPDATE guild_warz.zones SET `map_id` = '"..map.."' WHERE `entry` = '"..CLentry.."';");
- WorldDBQuery("UPDATE guild_warz.zones SET `area_id` = '"..area.."' WHERE `entry` = '"..CLentry.."';");
- WorldDBQuery("UPDATE guild_warz.zones SET `zone_id` = '"..zone.."' WHERE `entry` = '"..CLentry.."';");
- WorldDBQuery("UPDATE guild_warz.zones SET `guild_name` = '"..Server.."' WHERE `entry` = '"..CLentry.."';");
- GWARZ[CLentry] = {}
- GWARZ[CLentry].Entryid = CLentry
- GWARZ[CLentry].Mapid = map
- GWARZ[CLentry].Areaid = area
- GWARZ[CLentry].Zoneid = zone
- GWARZ[CLentry].Guildname = Server
- GWARZ[CLentry].Team = 2
- GWARZ[CLentry].Buildingcnt = 0
- GWARZ[CLentry].Pigcnt = 0
- GWARZ[CLentry].Guardcnt = 0
- GWARZ[CLentry].Flagid = 0
- print(""..CLentry..": created")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement