Hallöchen, ich habe folgendes Problem:
immer wenn sich ein Spieler ausloggt von meinem DayZ Server lass ich alle Daten in der MySQL-DB abspeichern.
Wenn sich nun ein einzelner Spieler ausloggt /disconnectet lässt sich für ca 2-3 sek kein Fenster oder ähnliches öffnen, loggen sich nun 3-4 Spieler gleichzeitig aus habe ich es auch schon häufig erlebt, dass der Server sogar einen "Networktroubel" macht. Das eigentliche Probleme ist mir auch bewusst, dass der Server zu viele Anfragen an den MySQl-Server sendet, doch ich habe keine Ahnung wie ich das Problem am besten umgehen kann. Unten findet ihr mein Aktuelles Script. Ich hoffe ihr wisst einen Rat.
Vielen Dank im vorraus für eure Hilfe
[tabmenu]
Lua
local playerDataTable = {
{"alivetime"},
{"realservertime"},
{"skin"},
{"MAX_Slots"},
{"bandit"},
{"blood"},
{"food"},
{"thirst"},
{"temperature"},
{"currentweapon_1"},
{"currentweapon_2"},
{"currentweapon_3"},
{"bleeding"},
{"brokenbone"},
{"pain"},
{"drunk"},
{"cold"},
{"infection"},
{"humanity"},
{"deads"},
{"botkilled"},
{"totalbotkilled"},
{"zombieskilled"},
{"totalzombieskilled"},
{"animalkilled"},
{"totalanimalkilled"},
{"banditskilled"},
{"totalbanditskilled"},
{"headshots"},
{"totalheadshots"},
{"murders"},
{"totalmurders"},
{"Wood Pile"},
{"Bandage"},
{"Water Bottle"},
{"Pasta Can"},
{"Can Baked Beans"},
{"Can Frank & Beans"},
{"Burger"},
{"Box of Matches"},
{"M1911 Mag"},
{"M9 SD Mag"},
{"Desert Eagle Mag"},
{"M1911"},
{"M9 SD"},
{"Winchester 1866"},
{"Hunting Knife"},
{"Hatchet"},
{"Pizza"},
{"Morphine"},
{"Soda Bottle (Coke)"},
{"Soda Bottle (Pepsi)"},
{"Monster Energy"},
{"Mountain Dew"},
{"Wine"},
{"Tennessee Whiskey |40%|"},
{"Sardines Can"},
{"Soup Can"},
{"Unkown Can"},
{"Dog Food"},
{"Mandarins Can"},
{"Empty Gas Canister"},
{"Full Gas Canister"},
{"Roadflare"},
{"Chemlite (blue)"},
{"Chemlite (green)"},
{"Chemlite (red)"},
{"Chemlite (pink)"},
{"Milk"},
{"PDW Mag"},
{"MP5A5 Mag"},
{"CO2 Mag"},
{"Collor Mag"},
{"AK Mag"},
{"M4 Mag"},
{"Tear Gas"},
{"Grenade"},
{"Fire Extinguisher"},
{"Spraycan"},
{"Molotov Cocktails"},
{"Desert Eagle"},
{"Sawn-Off Shotgun"},
{"SPAZ-12 Combat Shotgun"},
{"MP5A5"},
{"Military Watch"},
{"Money"},
{"Medic Kit"},
{"Medic Bag"},
{"Heat Pack"},
{"Lee Enfield"},
{"PDW"},
{"TEC-9"},
{"AK-47"},
--{"M136 Rocket Launcher"},
{"Blood Bag"},
{"GPS"},
{"Thermal GPS"},
{"GPS Jammer"},
{"GPS Tracker"},
{"Mine Tracker"},
{"Map"},
{"MacBook"},
{"Toolbox"},
{"Wire Fence"},
{"Tank Trap Kit"},
{"Mine"},
{"Bear Trap"},
{"Tire"},
{"Scrap Metal"},
{"Main Rotor Assembly"},
{"Windscreen Glass"},
{"Engine"},
{"Tank Parts"},
--{"M136 Rocket"},
{"CZ 550 Mag"},
{"Lee Enfield Mag"},
{"M4"},
{"CZ 550"},
{"Infrared Goggles"},
{"Night Vision Goggles"},
{"Tent"},
{"Camo Tent"},
{"Big Tent"},
{"Small Camo Tent"},
{"Raw Meat"},
{"Cooked Meat"},
{"Raw Fish"},
{"Cooked Fish"},
{"Camouflage Clothing"},
{"S.W.A.T. Clothing"},
{"Ghillie Suit"},
{"Civilian Clothing"},
{"Survivor Clothing"},
{"female Cop Clothes"},
{"Cop Clothes"},
{"Firefighter Clothing"},
{"Researcher Clothing"},
{"female Researcher Clothing"},
{"female Survivor Clothing"},
{"female Civilian Clothing"},
{"female Camouflage Clothing"},
{"Painkiller"},
{"Aspirin"},
{"Binoculars"},
{"Empty Water Bottle"},
{"Empty Soda Cans"},
{"Trash"},
{"Empty Cola Can"},
{"Empty Tin Can"},
{"Empty Whiskey Bottle"},
{"USB Stick"},
{"Paper"},
{"Textile"},
{"Wooden Fence"},
{"Iron"},
{"Building Instructions |M4|"},
{"Building Instructions |AK-47|"},
{"Building Instructions |Lee Enfield|"},
{"Building Instructions |CZ 550|"},
{"Building Instructions |MP5A5|"},
{"Building Instructions |PDW|"},
{"Building Instructions |SPAZ-12 Combat Shotgun|"},
{"Building Instructions |Sawn-Off Shotgun|"},
{"Building Instructions |Winchester 1866|"},
{"Building Instructions |M9 SD|"},
{"Building Instructions |M1911|"},
{"Building Instructions |Desert Eagle|"},
{"Building Instructions |Binoculars|"},
{"Building Instructions |Tire|"},
{"Building Instructions |Main Rotor Assembly|"},
{"Building Instructions |Engine|"},
{"Building Instructions |Tank Parts|"},
{"Building Instructions |Small Camo Tent|"},
{"Building Instructions |Tent|"},
{"Building Instructions |Bear Trap|"},
{"Building Instructions |Parachute|"},
{"Building Instructions |Wire Fence|"},
{"Building Instructions |Tank Trap Kit|"},
{"Glass"},
{"Wire"},
{"Gunpowder"},
{"Aluminum"},
{"Silicium"},
{"Rubber"},
{"Nails"},
{"Leather"},
{"SD Card"},
{"Hobble"},
{"Scruffy Burgers"},
{"1866 Slug"},
{"2Rnd. Slug"},
{"SPAZ-12 Pellet"},
{"Radio Device"},
{"Baseball Bat"},
{"Shovel"},
{"Molotov Cocktails"},
{"Satchel Charges"},
{"Chainsaw"},
{"Nightstick"},
{"Golf Club"},
{"Machete"},
{"Crowbar"},
{"Fishing Rod"},
{"Flowers"},
{"Long Purple Dildo"},
{"Radio Device"},
{"Parachute"},
{"Assault Pack (ACU)"},
{"Alice Pack"},
{"Czech Backpack"},
{"Coyote Backpack"},
{"Survival ACU"},
{"British Assault Pack"},
{"Camouflage Assault Pack"},
{"Camp Backpack"},
{"Patrol Pack"},
{"Krysset Backpack"},{"Ghillie Pack"},
{"O.S Pack"},
{"Light Backpack"},
{"Military Vintage Backpack"},}
Alles anzeigen
[/tabmenu]
[tabmenu]
Lua
local database = "DayZ";local host = "127.0.0.1";local user = "DayZ";local pass = "Zensiert";databaseConnection = dbConnect('mysql', 'dbname='..database..';host='..host, user, pass);
[/tabmenu]
[tabmenu]
Lua
function saveAccounts () if getElementData(source,"logedin") then local account = getPlayerAccount(source) accname = getAccountName ( account ) if account then destroyElement(getElementData(source,"playerCol")) if getElementData(source,"ondutyadmin") or getElementData(source,"ondutysmod") or getElementData(source,"ondutymod") then setAccountData ( account, "lastonduty",5) else for i,data in ipairs(playerDataTable) do if data[1] == "brokenbone" or data[1] == "pain" or data[1] == "drunk" or data[1] == "cold" or data[1] == "infection" or data[1] == "currentweapon_1" or data[1] == "currentweapon_2" or data[1] == "currentweapon_3" or data[1] == "bandit" then if getElementData(source,data[1]) then dbExec(databaseConnection,"UPDATE userdata SET "..data[1].." = 1 WHERE accname LIKE '"..accname.."'" ) else dbExec(databaseConnection,"UPDATE userdata SET "..data[1].." = 0 WHERE accname LIKE '"..accname.."'" ) end else dbExec(databaseConnection,"UPDATE userdata SET `"..data[1].."` = "..getElementData(source,data[1]).." WHERE accname LIKE '"..accname.."'" ) end end local x,y,z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) dbExec(databaseConnection,"UPDATE userdata SET last_x = "..x.." WHERE accname LIKE '"..accname.."'" ) dbExec(databaseConnection,"UPDATE userdata SET last_y = "..y.." WHERE accname LIKE '"..accname.."'" ) dbExec(databaseConnection,"UPDATE userdata SET last_z = "..z.." WHERE accname LIKE '"..accname.."'" ) dbExec(databaseConnection,"UPDATE userdata SET dimension = "..getElementDimension(source).." WHERE accname LIKE '"..accname.."'" ) dbExec(databaseConnection,"UPDATE userdata SET interio = "..getElementInterior(source).." WHERE accname LIKE '"..accname.."'" ) dbExec(databaseConnection,"UPDATE userdata SET Spawn_Rot_Z = "..rz.." WHERE accname LIKE '"..accname.."'" ) local query = dbQuery(databaseConnection,"SELECT * FROM `serverstatistik` WHERE name LIKE 'Alivetime'" ) local result,irow = dbPoll(query,-1) local valuetime = result[1]["wert"] local oldplayer = result[1]["spieler"] if getElementData(source,"alivetime") >= valuetime then dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET wert = "..getElementData(source,"alivetime").." WHERE name LIKE 'Alivetime'" )) dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET spieler = CONCAT('"..accname.."') WHERE name LIKE 'Alivetime'" )) outputChatBox("Der Serverrekord ´Alivetime` von "..oldplayer.." mit "..(valuetime/60).."h wurde gebrochen!",root,255,0,0,true) outputChatBox("Neuer Rekordhalter ist "..accname.." mit "..(getElementData(source,"alivetime")/60).."h!",root,255,0,0,true) outputChatBox("Gratulation",root,255,0,0,true) end local query = dbQuery(databaseConnection,"SELECT * FROM `serverstatistik` WHERE name LIKE 'Murders'" ) local result,irow = dbPoll(query,-1) local valuetime = result[1]["wert"] local oldplayer = result[1]["spieler"] if getElementData(source,"totalmurders") >= valuetime then dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET wert = "..getElementData(source,"totalmurders").." WHERE name LIKE 'Murders'" )) dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET spieler = CONCAT('"..accname.."') WHERE name LIKE 'Murders'" )) outputChatBox("Der Serverrekord ´Murders` von "..oldplayer.." mit "..(valuetime).." wurde gebrochen!",root,255,0,0,true) outputChatBox("Neuer Rekordhalter ist "..accname.." mit "..(getElementData(source,"totalmurders")).."!",root,255,0,0,true) outputChatBox("Gratulation",root,255,0,0,true) end local query = dbQuery(databaseConnection,"SELECT * FROM `serverstatistik` WHERE name LIKE 'Zombiekills'" ) local result,irow = dbPoll(query,-1) local valuetime = result[1]["wert"] local oldplayer = result[1]["spieler"] if getElementData(source,"totalzombieskilled") >= valuetime then dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET wert = "..getElementData(source,"totalzombieskilled").." WHERE name LIKE 'Zombiekills'" )) dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET spieler = CONCAT('"..accname.."') WHERE name LIKE 'Zombiekills'" )) outputChatBox("Der Serverrekord ´Zombiekills` von "..oldplayer.." mit "..(valuetime).." wurde gebrochen!",root,255,0,0,true) outputChatBox("Neuer Rekordhalter ist "..accname.." mit "..(getElementData(source,"totalzombieskilled")).."!",root,255,0,0,true) outputChatBox("Gratulation",root,255,0,0,true) end local query = dbQuery(databaseConnection,"SELECT * FROM `serverstatistik` WHERE name LIKE 'Animalkills'" ) local result,irow = dbPoll(query,-1) local valuetime = result[1]["wert"] local oldplayer = result[1]["spieler"] if getElementData(source,"totalanimalkilled") >= valuetime then dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET wert = "..getElementData(source,"totalanimalkilled").." WHERE name LIKE 'Animalkills'" )) dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET spieler = CONCAT('"..accname.."') WHERE name LIKE 'Animalkills'" )) outputChatBox("Der Serverrekord ´Animalkills` von "..oldplayer.." mit "..(valuetime).." wurde gebrochen!",root,255,0,0,true) outputChatBox("Neuer Rekordhalter ist "..accname.." mit "..(getElementData(source,"totalanimalkilled")).."!",root,255,0,0,true) outputChatBox("Gratulation",root,255,0,0,true) end local query = dbQuery(databaseConnection,"SELECT * FROM `serverstatistik` WHERE name LIKE 'Soldatenkills'" ) local result,irow = dbPoll(query,-1) local valuetime = result[1]["wert"] local oldplayer = result[1]["spieler"] if getElementData(source,"totalbotkilled") >= valuetime then dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET wert = "..getElementData(source,"totalbotkilled").." WHERE name LIKE 'Soldatenkills'" )) dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET spieler = CONCAT('"..accname.."') WHERE name LIKE 'Soldatenkills'" )) outputChatBox("Der Serverrekord ´Soldatenkills` von "..oldplayer.." mit "..(valuetime).." wurde gebrochen!",root,255,0,0,true) outputChatBox("Neuer Rekordhalter ist "..accname.." mit "..(getElementData(source,"totalbotkilled")).."!",root,255,0,0,true) outputChatBox("Gratulation",root,255,0,0,true) end local query = dbQuery(databaseConnection,"SELECT * FROM `serverstatistik` WHERE name LIKE 'Deads'" ) local result,irow = dbPoll(query,-1) local valuetime = result[1]["wert"] local oldplayer = result[1]["spieler"] if getElementData(source,"deads") >= valuetime then dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET wert = "..getElementData(source,"deads").." WHERE name LIKE 'Deads'" )) dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET spieler = CONCAT('"..accname.."') WHERE name LIKE 'Deads'" )) outputChatBox("Der Serverrekord ´Deads` von "..oldplayer.." mit "..(valuetime).." wurde gebrochen!",root,255,0,0,true) outputChatBox("Neuer Rekordhalter ist "..accname.." mit "..(getElementData(source,"deads")).."!",root,255,0,0,true) outputChatBox("Gratulation",root,255,0,0,true) end local query = dbQuery(databaseConnection,"SELECT * FROM `serverstatistik` WHERE name LIKE 'Servertime'" ) local result,irow = dbPoll(query,-1) local valuetime = result[1]["wert"] local oldplayer = result[1]["spieler"] if getElementData(source,"realservertime") >= valuetime then dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET wert = "..getElementData(source,"realservertime").." WHERE name LIKE 'Servertime'" )) dbFree(dbQuery(databaseConnection,"UPDATE `serverstatistik` SET spieler = CONCAT('"..accname.."') WHERE name LIKE 'Servertime'" )) outputChatBox("Der Serverrekord ´Servertime` von "..oldplayer.." mit "..(valuetime/60).."h wurde gebrochen!",root,255,0,0,true) outputChatBox("Neuer Rekordhalter ist "..accname.." mit "..(getElementData(source,"realservertime")/60).."h!",root,255,0,0,true) outputChatBox("Gratulation",root,255,0,0,true) end end end setElementData(source,"logedin",false) endendaddEventHandler ( "onPlayerQuit", getRootElement(), saveAccounts )
[/tabmenu]