Hallo,
Wenn ich mein Server Restarte oder nur die Ressource refreshe, und es steht ein auto auf der Map rum.
bekomm ich eine Meldung in der Log und im Debugscript 3
[2015-06-30 12:15:26] ERROR: [BL]/BL/mysql.lua:1036: attempt to index a boolean value
Das Fahrzeug wirt abgespeichert, aber nur da wo es spawnt, also es werden nicht die neuen x,y,z,rx,ry,rz Cordinaten übernommen.
Beim Refreshen verdoppeln sich die Fahrzeuge auch, aber ich weiss nicht ob es an diesem Fehler liegt.
Lua
-----------------------
---(c) 2013 Backland---
------Scripted by------
------KryPtoHolYx------
-----------------------
---All Right Reserved--
-----------------------
ad = { { { { "as" } } } } function ad:as() return "ab" end ad:as()
dbConnection = dbConnect("mysql", "dbname=DB;host=127.0.0.1", "User", "PW")
if(dbConnection ~= false)then
outputServerLog("Successfully connected to MySQL!")
else
outputServerLog("Failed to connect to MySQL!")
end
debugmode = false
local spawnPositions = {
{
-278.6669921875,
-2882.1572265625,
32.104232788086
},
{
-958.5595703125,
-2887.9912109375,
64.82421875
},
{
-1816.9375,
-2748.18359375,
1.7327127456665
},
{
-2816.166015625,
-2439.0546875,
2.4004096984863
},
{
-2941.5673828125,
-1206.2373046875,
2.7848854064941
},
{
-2911.51171875,
-895.22265625,
2.4013109207153
},
{
-2185.6669921875,
2957.380859375,
11.474840164185
},
{
272.2265625,
2928.505859375,
1.3713493347168
},
{
2803.943359375,
595.9365234375,
7.7612648010254
},
{
2883.7509765625,
-178.4658203125,
3.2714653015137
},
{
-233.46484375,
-1735.8173828125,
1.5520644187927
},
{
-1056.8720703125,
2939.068359375,
42.311294555664
},
}
local playerDataTable = {
{"alivetime","alivetime"},
{"skin","skin"},
{"MAX_Slots","MAX_Slots"},
{"bandit","bandit"},
{"blood","blood"},
{"food","food"},
{"thirst","thirst"},
{"temperature","temperature"},
{"bleeding","bleeding"},
{"brokenbone","brokenbone"},
{"pain","pain"},
{"cold","cold"},
{"infection","infection"},
{"humanity","humanity"},
{"zombieskilled","zombieskilled"},
{"headshots","headshots"},
{"murders","murders"},
{"banditskilled","banditskilled"},
{"Wood","Wood"},
{"Bandage","Bandage"},
{"Water Bottle","WaterBottle"},
{"Pasta Can","PastaCan"},
{"Beans Can","BeansCan"},
{"Burger","Burger"},
{"Lighter","Lighter"},
{"Pistol Ammo","PistolAmmo"},
{"Pistol","Pistol"},
{"Silenced Pistol","SilencedPistol"},
{"Shotgun","Shotgun"},
{"Uzi","Uzi"},
{"Knife","Knife"},
{"Katana","Katana"},
{"Pizza","Pizza"},
{"Morphine","Morphine"},
{"Soda Bottle","SodaBottle"},
{"Empty Patrol Canister","EmptyPatrolCanister"},
{"Full Patrol Canister","FullPatrolCanister"},
{"Roadflare","Roadflare"},
{"Milk","Milk"},
{"Smg Ammo","SmgAmmo"},
{"Assault Ammo","AssaultAmmo"},
{"Tear Gas","TearGas"},
{"Grenade","Grenade"},
{"Desert Eagle","DesertEagle"},
{"Sawn-Off Shotgun","SawnOffShotgun"},
{"SPAZ-12 Combat Shotgun","SPAZ12CombatShotgun"},
{"MP5","MP5"},
{"Watch","Watch"},
{"Medic Kit","MedicKit"},
{"Heat Pack","HeatPack"},
{"Country Rifle","CountryRifle"},
{"Uzi","Uzi"},
{"TEC-9","TEC9"},
{"AK-47","AK47"},
{"Rocket Launcher","RocketLauncher"},
{"Blood Bag","BloodBag"},
{"GPS","GPS"},
{"Map","Map"},
{"Toolbox","Toolbox"},
{"Wire Fence","WireFence"},
{"Tire","Tire"},
{"Engine","Engine"},
{"Rocket Ammo","RocketAmmo"},
{"Sniper Ammo","SniperAmmo"},
{"M4","M4"},
{"Sniper Rifle","SniperRifle"},
{"Heat-Seeking RPG","HeatSeekingRPG"},
{"Satchel","Satchel"},
{"Infrared Goggles","InfraredGoggles"},
{"Night Vision Goggles","NightVisionGoggles"},
{"Tent","Tent"},
{"Raw Meat","RawMeat"},
{"Cooked Meat","CookedMeat"},
{"Army Skin","ArmySkin"},
{"Sniper Skin","SniperSkin"},
{"Civilian Skin","CivilianSkin"},
{"Standart Skin","StandartSkin"},
{"Painkiller","Painkiller"},
{"Binocular","Binocular"},
{"Empty Water Bottle","EmptyWaterBottle"},
{"Empty Soda Cans","EmptySodaCans"},
{"Scruffy Burgers","ScruffyBurgers"},
{"Shotgun Ammo","ShotgunAmmo"},
{"Radio Device","RadioDevice"},
{"vipCash","cash"},
}
local playerDataTableAlter = {
{"alivetime"},
{"skin"},
{"MAX_Slots"},
{"bandit"},
{"blood"},
{"food"},
{"thirst"},
{
"temperature"
},
{
"currentweapon_1"
},
{
"currentweapon_2"
},
{
"currentweapon_3"
},
{"bleeding"},
{"brokenbone"},
{"pain"},
{"cold"},
{"infection"},
{"humanity"},
{
"zombieskilled"
},
{"headshots"},
{"murders"},
{
"banditskilled"
},
{"Wood"},
{"Bandage"},
{
"Water Bottle"
},
{"Pasta Can"},
{"Beans Can"},
{"Burger"},
{"Lighter"},
{
"Pistol Ammo"
},
{"Pistol"},
{
"Silenced Pistol"
},
{"Shotgun"},
{"Uzi"},
{"Knife"},
{"Katana"},
{"Pizza"},
{"Morphine"},
{
"Soda Bottle"
},
{
"Empty Patrol Canister"
},
{
"Full Patrol Canister"
},
{"Roadflare"},
{"Milk"},
{"Smg Ammo"},
{
"Assault Ammo"
},
{"Tear Gas"},
{"Grenade"},
{
"Desert Eagle"
},
{
"Sawn-Off Shotgun"
},
{
"SPAZ-12 Combat Shotgun"
},
{"MP5"},
{"Watch"},
{"Medic Kit"},
{"Heat Pack"},
{
"Country Rifle"
},
{"Uzi"},
{"TEC-9"},
{"AK-47"},
{
"Rocket Launcher"
},
{"Blood Bag"},
{"GPS"},
{"Map"},
{"Toolbox"},
{"Wire Fence"},
{"Tire"},
{"Engine"},
{
"Rocket Ammo"
},
{
"Sniper Ammo"
},
{"M4"},
{
"Sniper Rifle"
},
{
"Heat-Seeking RPG"
},
{"Satchel"},
{
"Infrared Goggles"
},
{
"Night Vision Goggles"
},
{"Tent"},
{"Raw Meat"},
{
"Cooked Meat"
},
{"Army Skin"},
{
"Sniper Skin"
},
{
"Civilian Skin"
},
{
"Standart Skin"
},
{"Painkiller"},
{"Binocular"},
{
"Empty Water Bottle"
},
{
"Empty Soda Cans"
},
{
"Scruffy Burgers"
},
{
"Shotgun Ammo"
},
{
"Radio Device"
}
}
local debugDatabaseCurrentWeapon = {
{"Pistol","Pistol"},
{"Silenced Pistol","SilencedPistol"},
{"Shotgun","Shotgun"},
{"Uzi","Uzi"},
{"Knife","Knife"},
{"Katana","Katana"},
{"Tear Gas","TearGas"},
{"Grenade","Grenade"},
{"Desert Eagle","DesertEagle"},
{"Sawn-Off Shotgun","SawnOffShotgun"},
{"SPAZ-12 Combat Shotgun","SPAZ12CombatShotgun"},
{"MP5","MP5"},
{"Country Rifle","CountryRifle"},
{"Uzi","Uzi"},
{"TEC-9","TEC9"},
{"AK-47","AK47"},
{"Rocket Launcher","RocketLauncher"},
{"M4","M4"},
{"Sniper Rifle","SniperRifle"},
{"Heat-Seeking RPG","HeatSeekingRPG"},
}
function playerRegisterb(username, pass, player)
---
qr = dbQuery(dbConnection, "SELECT * FROM users")
result = dbPoll(qr, -1)
for v,k in ipairs(result) do
if k['Name'] == getPlayerName(player) then return end
end
--
qh = dbQuery(dbConnection, "SELECT id FROM users")
idresult = dbPoll(qh, -1)
local id = table.getn(idresult)+1
setElementData(player,"id",id)
username = tostring(username)
serial = getPlayerSerial(player)
local number = math.random(table.size(spawnPositions))
local x, y, z = spawnPositions[number][1], spawnPositions[number][2], spawnPositions[number][3]
spawnPlayer(player, x, y, z, math.random(0, 360), 73, 0, 0)
fadeCamera(player, true)
setCameraTarget(player, player)
local playerCol = createColSphere(x, y, z, 1.5)
attachElements(playerCol, player, 0, 0, 0)
setElementData(playerCol, "parent", player)
setElementData(playerCol, "player", true)
for i, data in ipairs(playerDataTable) do
if data[1] == "Bandage" then
setElementData(player, data[1], 2)
elseif data[1] == "Painkiller" then
setElementData(player, data[1], 1)
elseif data[1] == "vipCash" then
setElementData(player, data[1], 5)
elseif data[1] == "MAX_Slots" then
setElementData(player, data[1], 10)
elseif data[1] == "skin" then
setElementData(player, data[1], 73)
elseif data[1] == "blood" then
setElementData(player, data[1], 12000)
elseif data[1] == "temperature" then
setElementData(player, data[1], 37)
elseif data[1] == "brokenbone" then
setElementData(player, data[1], false)
elseif data[1] == "pain" then
setElementData(player, data[1], false)
elseif data[1] == "cold" then
setElementData(player, data[1], false)
elseif data[1] == "infection" then
setElementData(player, data[1], false)
elseif data[1] == "food" then
setElementData(player, data[1], 100)
elseif data[1] == "thirst" then
setElementData(player, data[1], 100)
elseif data[1] == "currentweapon_1" then
setElementData(player, data[1], false)
elseif data[1] == "currentweapon_2" then
setElementData(player, data[1], false)
elseif data[1] == "currentweapon_3" then
setElementData(player, data[1], false)
elseif data[1] == "bandit" then
setElementData(player, data[1], false)
elseif data[1] == "humanity" then
setElementData(player, data[1], 2500)
else
setElementData(player, data[1], 0)
end
end
setElementData(player, "logedin", true)
createZombieTable(player)
local x,y,z = getElementPosition(player)
local _,_,rz = getElementRotation(player)
local querry = dbQuery(dbConnection, "INSERT INTO users VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
id,
username, -- USERNAME
serial, -- SERIAL
md5(pass),--PASSWORD
0,
tonumber(x),
tonumber(y),
tonumber(z),
tonumber(rz),
false, -- is Dead
5, -- cash
0, --alivetime
73, --skin
10, --MAX_Slots
"false", --bandit
12000, --blood
100, --food
100, --thirst
37, --temperature
"false", --currentweapon_1
"false", --currentweapon_2
"false", --currentweapon_2
0, --bleeding
"false", --brokenbone
"false", --pain
"false", --cold
"false", --infection
0, --humanity
0, --zombieskilled
0, --headshots
0, --murders
0, --banditskilled
0, --Wood
2, --Bandage
0, --Water Bottle
0, --Pasta Can
0, --Beans Can
0, --Burger
0, --Lighter
0, --Pistol Ammo
0, --Pistol
0, --Silenced Pistol
0, --Shotgun
0, --Uzi
0, --Knife
0, --Katana
0, --Pizza
0, --Morphine
0, --Soda Bottle
0, --Empty Patrol Canister
0, --Full Patrol Canister
0, --Roadflare
0, --Milk
0, --Smg Ammo
0, --Assault Ammo
0, --Tear Gas
0, --Grenade
0, --Desert Eagle
0, --Sawn-Off Shotgun
0, --SPAZ-12 Combat Shotgun
0, --MP5
0, --Watch
0, --Medic Kit
0, --Heat Pack
0, --Country Rifle
0, --TEC-9
0, --AK-47
0, --Rocket Launcher
0, --Blood Bag
0, --GPS
0, --Map
0, --Toolbox
0, --Wire Fence
0, --Tire
0, --Engine
0, --Rocket Ammo
0, --Sniper Ammo
0, --M4
0, --Sniper Rifle
0, --Heat-Seeking RPG
0, --Satchel
0, --Infrared Goggles
0, --Night Vision Goggles
0, --Tent
0, --Raw Meat
0, --Cooked Meat
0, --Army Skin
0, --Sniper Skin
0, --Civilian Skin
0, --Standart Skin
1, --Painkiller
0, --Binocular
0, --Empty Water Bottle
0, --Empty Soda Cans
0, --Scruffy Burgers
0, --Shotgun Ammo
0 --Radio Device
)
local result = dbPoll( querry, 10 )
end
addEvent("onPlayerDayZRegister",true)
addEventHandler("onPlayerDayZRegister", getRootElement(), playerRegisterb)
function getTablePositionMySQL ( data )
for index,daten in ipairs(playerDataTable) do
if (data == daten[2]) then
return daten[1]
end
end
end
function getTablePositionMySQL1 ( data )
for index,daten in ipairs(playerDataTable) do
if (data == daten[1]) then
return daten[2]
end
end
end
function playerLogibn(username, pass, player)
qr = dbQuery(dbConnection, "SELECT * FROM users WHERE Name ='"..getPlayerName(player).."'")
result = dbPoll(qr, -1)
password = result[1]['password']
if (password ~= md5(pass)) then kickPlayer(player,"password wrong") end
qrb = dbQuery(dbConnection, "SELECT * FROM users WHERE Name ='"..getPlayerName(player).."'")
resultqrb = dbPoll(qrb, -1)
spawnPlayer(player, resultqrb[1]['x'],resultqrb[1]['y'],resultqrb[1]['z'], resultqrb[1]['rz'], skin, 0, 0)
fadeCamera(player, true)
setElementData(player,"id",resultqrb[1]['id'])
setCameraTarget(player, player)
local x,y,z = getElementPosition(player)
local playerColshape = createColSphere(x, y, z, 1.5)
setElementData(player, "playerCol", playerColshape)
attachElements(playerColshape, player, 0, 0, 0)
setElementData(playerColshape, "parent", player)
setElementData(playerColshape, "player", true)
setElementPosition(player,resultqrb[1]['x'],resultqrb[1]['y'],resultqrb[1]['z'])
setElementRotation(player,0,0,resultqrb[1]['rz'])
if (resultqrb[1]['rank'] == "1") then
setElementData(player,"admin",false)
setElementData(player,"supporter",true)
outputDebugString(resultqrb[1]['rank'])
elseif (resultqrb[1]['rank'] == "2") then
setElementData(player,"admin",true)
setElementData(player,"supporter",false)
local account = getAccount ( username, pass )
if ( account ~= false ) then
logIn ( player, account, pass )
outputChatBox("",player)
outputChatBox("",player)
outputChatBox("",player)
outputChatBox("",player)
outputChatBox("",player)
outputChatBox("",player)
outputChatBox("",player)
outputChatBox("",player)
outputChatBox("",player)
outputChatBox("",player)
end
outputDebugString(resultqrb[1]['rank'])
elseif (resultqrb[1]['rank'] == "3") then
setElementData(player,"owner",true)
end
for i, datensatz in ipairs(playerDataTable) do
if (datensatz[1] == "bandit") or (datensatz[1] == "brokenbone") or (datensatz[1] == "currentweapon_1") or (datensatz[1] == "currentweapon_2") or (datensatz[1] == "currentweapon_3") or (datensatz[1] == "pain") or (datensatz[1] == "cold") or (datensatz[1] == "infection") then
if (resultqrb[1][datensatz[2]] == "1") then
dayzDate = true
outputDebugString(datensatz[1].." ; "..resultqrb[1][datensatz[2]])
elseif (resultqrb[1][datensatz[2]] == "0") then
dayzDate = false
outputDebugString(datensatz[1].." ; "..resultqrb[1][datensatz[2]])
end
else
dayzDate = tonumber(resultqrb[1][datensatz[2]])
end
setElementData(player,datensatz[1],dayzDate)
end
createZombieTable(player)
if result[1]['isDead'] == "1" then
spawnDayZPlayer(player)
dbPoll(dbQuery(dbConnection, "UPDATE users SET isDead='0' WHERE Name ='"..getPlayerName(player).."'"), -1)
return
end
setElementData(player, "logedin", true)
local weapon = getElementData(player, "currentweapon_1")
if weapon then
local ammoData, weapID = getWeaponAmmoType(weapon)
giveWeapon(player, weapID, getElementData(player, ammoData), true)
end
local weapon = getElementData(player, "currentweapon_2")
if weapon then
local ammoData, weapID = getWeaponAmmoType(weapon)
giveWeapon(player, weapID, getElementData(player, ammoData), false)
end
local weapon = getElementData(player, "currentweapon_3")
if weapon then
local ammoData, weapID = getWeaponAmmoType(weapon)
giveWeapon(player, weapID, getElementData(player, ammoData), false)
end
setPedSkin(player,getElementData(player, "skin"))
end
addEvent("onPlayerDayZLogin", true)
addEventHandler("onPlayerDayZLogin", getRootElement(), playerLogibn)
function saveAccounts3()
local account = getPlayerAccount(source)
if account then
local x,y,z = getElementPosition(source)
local _,_,rz = getElementRotation(source)
qh = dbQuery(dbConnection, "UPDATE users SET x="..tostring(x)..", y="..tostring(y)..", z="..tostring(z)..", rz="..tostring(rz).." WHERE Name ='"..getPlayerName(source).."'")
resultb = dbPoll(qh, -1)
for i, datensatzb in ipairs(playerDataTable) do
dataz = getElementData(source,datensatzb[1])
qh = dbQuery(dbConnection, "UPDATE users SET "..datensatzb[2].."="..tostring(dataz).." WHERE Name ='"..getPlayerName(source).."'")
resultb = dbPoll(qh, -1)
end
end
setElementData(source, "logedin", false)
end
addEventHandler("onPlayerQuit", getRootElement(), saveAccounts3)
-- VEHICLES & TENTS !
local vehicleDataTable = {
{"MAX_Slots","MAX_Slots"},
{"Tire_inVehicle","Tire_inVehicle"},
{"Engine_inVehicle","Engine_inVehicle"},
{"fuel","fuel"},
{"Wood","Wood"},
{"Bandage","Bandage"},
{"Water Bottle","WaterBottle"},
{"Pasta Can","PastaCan"},
{"Beans Can","BeansCan"},
{"Burger","Burger"},
{"Lighter","Lighter"},
{"Pistol Ammo","PistolAmmo"},
{"Pistol","Pistol"},
{"Silenced Pistol","SilencedPistol"},
{"Shotgun","Shotgun"},
{"Knife","Knife"},
{"Morphine","Morphine"},
{"Katana","Katana"},
{"Pizza","Pizza"},
{"Soda Bottle","SodaBottle"},
{"Empty Patrol Canister","EmptyPatrolCanister"},
{"Full Patrol Canister","FullPatrolCanister"},
{"Roadflare","Roadflare"},
{"Milk","Milk"},
{"Smg Ammo","SmgAmmo"},
{"Assault Ammo","AssaultAmmo"},
{"Tear Gas","TearGas"},
{"Grenade","Grenade"},
{"Desert Eagle","DesertEagle"},
{"Sawn-Off Shotgun","SawnOffShotgun"},
{"SPAZ-12 Combat Shotgun","SPAZ12CombatShotgun"},
{"MP5","MP5"},
{"Watch","Watch"},
{"Medic Kit","MedicKit"},
{"Heat Pack","HeatPack"},
{"Country Rifle","CountryRifle"},
{"Uzi","Uzi"},
{"TEC-9","TEC9"},
{"AK-47","AK47"},
{"Rocket Launcher","RocketLauncher"},
{"Blood Bag","BloodBag"},
{"GPS","GPS"},
{"Map","Map"},
{"Toolbox","Toolbox"},
{"Wire Fence","WireFence"},
{"Tire","Tire"},
{"Engine","Engine"},
{"Rocket Ammo","RocketAmmo"},
{"Sniper Ammo","SniperAmmo"},
{"M4","M4"},
{"Sniper Rifle","SniperRifle"},
{"Heat-Seeking RPG","HeatSeekingRPG"},
{"Satchel","Satchel"},
{"Infrared Goggles","InfraredGoggles"},
{"Night Vision Goggles","NightVisionGoggles"},
{"Tent","Tent"},
{"Raw Meat","RawMeat"},
{"Cooked Meat","CookedMeat"},
{"Army Skin","ArmySkin"},
{"Sniper Skin","SniperSkin"},
{"Civilian Skin","CivilianSkin"},
{"Standart Skin","StandartSkin"},
{"Painkiller","Painkiller"},
{"Binocular","Binocular"},
{"Empty Water Bottle","EmptyWaterBottle"},
{"Empty Soda Cans","EmptySodaCans"},
{"Scruffy Burgers","ScruffyBurgers"},
{"Shotgun Ammo","ShotgunAmmo"},
{"Small Backpack","SmallBackpack"},
{"Alice Backpack","AliceBackpack"},
{"Radio Device","RadioDevice"},
{"Coyote Backpack","CoyoteBackpack"}
}
tent_id = 3243
function removeTent1(x,y,z,object)
local item, itemString = getItemTablePosition("Tent")
local itemPickup = createItemPickup(item, x, y, z + 1, itemString)
destroyElement(getElementData(object, "parent"))
destroyElement(object)
end
addEvent("removeTent1", true)
removeEventHandler("removeTent", getRootElement(), removeTent)
addEventHandler("removeTent1", getRootElement(), removeTent1)
local vehicleDataTable = {
{"MAX_Slots","MAX_Slots"},
{"Tire_inVehicle","Tire_inVehicle"},
{"Engine_inVehicle","Engine_inVehicle"},
{"fuel","fuel"},
{"Wood","Wood"},
{"Bandage","Bandage"},
{"Water Bottle","WaterBottle"},
{"Pasta Can","PastaCan"},
{"Beans Can","BeansCan"},
{"Burger","Burger"},
{"Lighter","Lighter"},
{"Pistol Ammo","PistolAmmo"},
{"Pistol","Pistol"},
{"Silenced Pistol","SilencedPistol"},
{"Shotgun","Shotgun"},
{"Knife","Knife"},
{"Morphine","Morphine"},
{"Katana","Katana"},
{"Pizza","Pizza"},
{"Soda Bottle","SodaBottle"},
{"Empty Patrol Canister","EmptyPatrolCanister"},
{"Full Patrol Canister","FullPatrolCanister"},
{"Roadflare","Roadflare"},
{"Milk","Milk"},
{"Smg Ammo","SmgAmmo"},
{"Assault Ammo","AssaultAmmo"},
{"Tear Gas","TearGas"},
{"Grenade","Grenade"},
{"Desert Eagle","DesertEagle"},
{"Sawn-Off Shotgun","SawnOffShotgun"},
{"SPAZ-12 Combat Shotgun","SPAZ12CombatShotgun"},
{"MP5","MP5"},
{"Watch","Watch"},
{"Medic Kit","MedicKit"},
{"Heat Pack","HeatPack"},
{"Country Rifle","CountryRifle"},
{"Uzi","Uzi"},
{"TEC-9","TEC9"},
{"AK-47","AK47"},
{"Rocket Launcher","RocketLauncher"},
{"Blood Bag","BloodBag"},
{"GPS","GPS"},
{"Map","Map"},
{"Toolbox","Toolbox"},
{"Wire Fence","WireFence"},
{"Tire","Tire"},
{"Engine","Engine"},
{"Rocket Ammo","RocketAmmo"},
{"Sniper Ammo","SniperAmmo"},
{"M4","M4"},
{"Sniper Rifle","SniperRifle"},
{"Heat-Seeking RPG","HeatSeekingRPG"},
{"Satchel","Satchel"},
{"Infrared Goggles","InfraredGoggles"},
{"Night Vision Goggles","NightVisionGoggles"},
{"Tent","Tent"},
{"Raw Meat","RawMeat"},
{"Cooked Meat","CookedMeat"},
{"Army Skin","ArmySkin"},
{"Sniper Skin","SniperSkin"},
{"Civilian Skin","CivilianSkin"},
{"Standart Skin","StandartSkin"},
{"Painkiller","Painkiller"},
{"Binocular","Binocular"},
{"Empty Water Bottle","EmptyWaterBottle"},
{"Empty Soda Cans","EmptySodaCans"},
{"Scruffy Burgers","ScruffyBurgers"},
{"Shotgun Ammo","ShotgunAmmo"},
{"Radio Device","RadioDevice"},
}
tent_id = 3243
function rebornTents()
if not (source == getResourceRootElement()) then return end
---
qh = dbQuery(dbConnection, "SELECT id FROM tents")
local id = dbPoll(qh, -1)
for k,v in pairs(id) do
qrb = dbQuery(dbConnection, "SELECT * FROM tents WHERE id ="..v['id'].."")
resdasdult = dbPoll(qrb, -1)
local tent = createObject(tent_id,tonumber(resdasdult[1]['x']),tonumber(resdasdult[1]['y']),tonumber(resdasdult[1]['z']),tonumber(resdasdult[1]['rx']),tonumber(resdasdult[1]['ry']),tonumber(resdasdult[1]['rz']))
setElementData(tent,"id",resdasdult[1]['id'])
setElementData(tent,"MySQLTENT",true)
setObjectScale(tent, 1.3)
tentCol = createColSphere(resdasdult[1]['x'],resdasdult[1]['y'],resdasdult[1]['z'], 4)
attachElements(tentCol, tent, 0, 0, 0)
setElementData(tentCol, "parent", tent)
setElementData(tent, "parent", tentCol)
setElementData(tentCol, "tent", true)
setElementData(tentCol, "vehicle", true)
setElementData(tentCol, "MAX_Slots", 100)
for i, datensatzb in ipairs(vehicleDataTable) do
local datensatzx = tonumber(resdasdult[1][datensatzb[2]])
setElementData(tentCol,datensatzb[1],datensatzx)
end
end
local id = table.getn(id)
outputDebugString(id)
end
function saveTentsc()
if not (source == getResourceRootElement()) then return end
for index,tents in ipairs(getElementsByType("object")) do
if (getElementModel(tents) == 3243) then
if (getElementData(tents,"MySQLTENT")) then
outputDebugString("MYSQL TENT")
local x,y,z = getElementPosition(tents)
local _,_,rz = getElementRotation(tents)
local tent = getElementData(tents,"parent")
for i, datensatzz in ipairs(vehicleDataTable) do
qh = dbQuery(dbConnection, "UPDATE tents SET "..datensatzz[2].."='"..tostring(getElementData(tent,datensatzz[1])).."' WHERE id ='"..getElementData(tents,"id").."'")
resultb = dbPoll(qh, -1)
end
else
outputDebugString("NON MYSQL TENT")
qh = dbQuery(dbConnection, "SELECT id FROM tents")
idresult = dbPoll(qh, -1)
local id = table.getn(idresult)+1
outputDebugString(id)
local x,y,z = getElementPosition(tents)
local rx,ry,rz = getElementRotation(tents)
local tents = getElementData(tents,"parent")
local querry = dbQuery(dbConnection, "INSERT INTO tents VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
math.random(99999999),
x,
y,
z,
rx,
ry,
rz,
100,
getElementData(tents,"Tire_inVehicle"),
getElementData(tents,"Engine_inVehicle"),
getElementData(tents,"Fuel"),
getElementData(tents,"Wood"),
getElementData(tents,"Bandage"),
getElementData(tents,"Water Bottle"),
getElementData(tents,"Pasta Can"),
getElementData(tents,"Beans Can"),
getElementData(tents,"Burger"),
getElementData(tents,"Lighter"),
getElementData(tents,"Pistol Ammo"),
getElementData(tents,"Pistol"),
getElementData(tents,"Silenced Pistol"),
getElementData(tents,"Shotgun"),
getElementData(tents,"Knife"),
getElementData(tents,"Morphine"),
getElementData(tents,"Katana"),
getElementData(tents,"Pizza"),
getElementData(tents,"Soda Bottle"),
getElementData(tents,"Empty Patrol Canister"),
getElementData(tents,"Full Patrol Canister"),
getElementData(tents,"Roadflare"),
getElementData(tents,"Milk"),
getElementData(tents,"Smg Ammo"),
getElementData(tents,"Assault Ammo"),
getElementData(tents,"Tear Gas,"),
getElementData(tents,"Grenade"),
getElementData(tents,"Desert Eagle"),
getElementData(tents,"Sawn-Off Shotgun"),
getElementData(tents,"SPAZ-12 Combat Shotgun"),
getElementData(tents,"MP5"),
getElementData(tents,"Watch"),
getElementData(tents,"Medic Kit"),
getElementData(tents,"Heat Pack"),
getElementData(tents,"Country Rifle"),
getElementData(tents,"Uzi"),
getElementData(tents,"TEC-9"),
getElementData(tents,"AK-47"),
getElementData(tents,"Rocket Launcher"),
getElementData(tents,"Blood Bag"),
getElementData(tents,"GPs,"),
getElementData(tents,"Map"),
getElementData(tents,"Toolbox"),
getElementData(tents,"Wire Fence"),
getElementData(tents,"Tire"),
getElementData(tents,"Engine"),
getElementData(tents,"Rocket Ammo"),
getElementData(tents,"Sniper Ammo"),
getElementData(tents,"M4"),
getElementData(tents,"Sniper Rifle"),
getElementData(tents,"Heat-Seeking RPG"),
getElementData(tents,"Satchel"),
getElementData(tents,"Infrared Goggles,"),
getElementData(tents,"Night Vision Goggles,"),
getElementData(tents,"Tent"),
getElementData(tents,"Raw Meat"),
getElementData(tents,"Cooked Meat"),
getElementData(tents,"Army Skin"),
getElementData(tents,"Sniper Skin"),
getElementData(tents,"Civilian Skin"),
getElementData(tents,"Standart Skin"),
getElementData(tents,"Painkiller"),
getElementData(tents,"Binocular"),
getElementData(tents,"Empty Water Bottle"),
getElementData(tents,"Empty Soda Cans,"),
getElementData(tents,"Scruffy Burgers,"),
getElementData(tents,"Shotgun Ammo"),
getElementData(tents,"Radio Device")
)
local result = dbPoll( querry, 10 )
end
destroyElement(tents)
end
end
end
function rebornVehicles()
if not (source == getResourceRootElement()) then return end
---
qh = dbQuery(dbConnection, "SELECT id FROM vehicles")
local id = dbPoll(qh, -1)
local id = table.getn(id)
outputDebugString(id)
for i = 1, id do
qrb = dbQuery(dbConnection, "SELECT * FROM vehicles WHERE id ="..i.."")
resdasdult = dbPoll(qrb, -1)
local vehicle = createVehicle(tonumber(resdasdult[1]['vehicle_ID']),tonumber(resdasdult[1]['x']),tonumber(resdasdult[1]['y']),tonumber(resdasdult[1]['z']),tonumber(resdasdult[1]['rx']),tonumber(resdasdult[1]['ry']),tonumber(resdasdult[1]['rz']))
setElementData(vehicle,"id",resdasdult[1]['id'])
setElementData(vehicle,"MYSQLVEHICLE",true)
vehicleCol = createColSphere(resdasdult[1]['x'],resdasdult[1]['y'],resdasdult[1]['z'], 2)
attachElements(vehicleCol, vehicle, 0, 0, 0)
setElementData(vehicleCol, "parent", vehicle)
setElementData(vehicle, "parent", vehicleCol)
setElementData(vehicleCol, "vehicle", true)
setElementData(vehicleCol, "MAX_Slots", tonumber(resdasdult[1]['MAX_Slots']))
setElementData(vehicleCol, "spawn", {
tonumber(resdasdult[1]['vehicle_ID']),
tonumber(resdasdult[1]['spawn_x']),
tonumber(resdasdult[1]['spawn_y']),
tonumber(resdasdult[1]['spawn_z'])
})
for i, datensatzb in ipairs(vehicleDataTable) do
local datensatzx = tonumber(resdasdult[1][datensatzb[2]])
setElementData(vehicleCol,datensatzb[1],datensatzx)
end
end
end
function saveVehiclesc()
if not (source == getResourceRootElement()) then return end
for index,tent in ipairs(getElementsByType("vehicle")) do
if (getElementData(tent,"MYSQLVEHICLE")) then
local x,y,z = getElementPosition(tent)
local rx,ry,rz = getElementRotation(tent)
dbPoll(dbQuery(dbConnection, "UPDATE vehicles SET x='"..x.."' WHERE id ='"..getElementData(tent,"id").."'"), -1)
dbPoll(dbQuery(dbConnection, "UPDATE vehicles SET y='"..y.."' WHERE id ='"..getElementData(tent,"id").."'"), -1)
dbPoll(dbQuery(dbConnection, "UPDATE vehicles SET z='"..z.."' WHERE id ='"..getElementData(tent,"id").."'"), -1)
dbPoll(dbQuery(dbConnection, "UPDATE vehicles SET rx='"..rx.."' WHERE id ='"..getElementData(tent,"id").."'"), -1)
dbPoll(dbQuery(dbConnection, "UPDATE vehicles SET ry='"..ry.."' WHERE id ='"..getElementData(tent,"id").."'"), -1)
dbPoll(dbQuery(dbConnection, "UPDATE vehicles SET rz='"..rz.."' WHERE id ='"..getElementData(tent,"id").."'"), -1)
local tents = getElementData(tent,"parent")
for i, datensatzz in ipairs(vehicleDataTable) do
qh = dbQuery(dbConnection, "UPDATE vehicles SET "..datensatzz[2].."='"..tostring(getElementData(tents,datensatzz[1])).."' WHERE id ='"..getElementData(tent,"id").."'")
resultb = dbPoll(qh, -1)
end
else
if (getElementData(tent,"spawnedViaPanel") == true) then return end
qh = dbQuery(dbConnection, "SELECT id FROM vehicles")
idresult = dbPoll(qh, -1)
local id = table.getn(idresult)+1
local x,y,z = getElementPosition(tent)
local rx,ry,rz = getElementRotation(tent)
local tents = getElementData(tent,"parent")
if (getElementModel(tent) ~= 548) then
local querry = dbQuery(dbConnection, "INSERT INTO vehicles VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
id,
x,
y,
z,
rx,
ry,
rz,
getElementData(tents, "spawn")[2],
getElementData(tents, "spawn")[3],
getElementData(tents, "spawn")[4],
getElementModel(tent),
getElementData(tents,"MAX_Slots"),
getElementData(tents,"Tire_inVehicle"),
getElementData(tents,"Engine_inVehicle"),
getElementData(tents,"fuel"),
getElementData(tents,"Wood"),
getElementData(tents,"Bandage"),
getElementData(tents,"Water Bottle"),
getElementData(tents,"Pasta Can"),
getElementData(tents,"Beans Can"),
getElementData(tents,"Burger"),
getElementData(tents,"Lighter"),
getElementData(tents,"Pistol Ammo"),
getElementData(tents,"Pistol"),
getElementData(tents,"Silenced Pistol"),
getElementData(tents,"Shotgun"),
getElementData(tents,"Knife"),
getElementData(tents,"Morphine"),
getElementData(tents,"Katana"),
getElementData(tents,"Pizza"),
getElementData(tents,"Soda Bottle"),
getElementData(tents,"Empty Patrol Canister"),
getElementData(tents,"Full Patrol Canister"),
getElementData(tents,"Roadflare"),
getElementData(tents,"Milk"),
getElementData(tents,"Smg Ammo"),
getElementData(tents,"Assault Ammo"),
getElementData(tents,"Tear Gas,"),
getElementData(tents,"Grenade"),
getElementData(tents,"Desert Eagle"),
getElementData(tents,"Sawn-Off Shotgun"),
getElementData(tents,"SPAZ-12 Combat Shotgun"),
getElementData(tents,"MP5"),
getElementData(tents,"Watch"),
getElementData(tents,"Medic Kit"),
getElementData(tents,"Heat Pack"),
getElementData(tents,"Country Rifle"),
getElementData(tents,"Uzi"),
getElementData(tents,"TEC-9"),
getElementData(tents,"AK-47"),
getElementData(tents,"Rocket Launcher"),
getElementData(tents,"Blood Bag"),
getElementData(tents,"GPs,"),
getElementData(tents,"Map"),
getElementData(tents,"Toolbox"),
getElementData(tents,"Wire Fence"),
getElementData(tents,"Tire"),
getElementData(tents,"Engine"),
getElementData(tents,"Rocket Ammo"),
getElementData(tents,"Sniper Ammo"),
getElementData(tents,"M4"),
getElementData(tents,"Sniper Rifle"),
getElementData(tents,"Heat-Seeking RPG"),
getElementData(tents,"Satchel"),
getElementData(tents,"Infrared Goggles,"),
getElementData(tents,"Night Vision Goggles,"),
getElementData(tents,"Tent"),
getElementData(tents,"Raw Meat"),
getElementData(tents,"Cooked Meat"),
getElementData(tents,"Army Skin"),
getElementData(tents,"Sniper Skin"),
getElementData(tents,"Civilian Skin"),
getElementData(tents,"Standart Skin"),
getElementData(tents,"Painkiller"),
getElementData(tents,"Binocular"),
getElementData(tents,"Empty Water Bottle"),
getElementData(tents,"Empty Soda Cans,"),
getElementData(tents,"Scruffy Burgers,"),
getElementData(tents,"Shotgun Ammo"),
getElementData(tents,"Radio Device")
)
local result = dbPoll( querry, 10 )
end
end
end
end
function removeTentMYSQL(object)
local id = dbPoll(dbQuery(dbConnection, "SELECT id FROM tents"),-1)
local id = table.getn(id)+1
dbPoll(dbQuery(dbConnection, "DELETE FROM tents WHERE id = '"..getElementData(object,"id").."'"), -1)
local x, y, z = getElementPosition(getElementData(object, "parent"))
outputDebugString(getElementData(object,"id"))
triggerEvent("removeTent1", getRootElement(), x,y,z,object)
end
addEvent("removeTent", true)
addEventHandler("removeTent", getRootElement(), removeTentMYSQL)
addEventHandler("onResourceStart",getRootElement(),rebornTents)
addEventHandler("onResourceStop",getRootElement(),saveTentsc)
addEventHandler("onResourceStart",getRootElement(),rebornVehicles)
addEventHandler("onResourceStop",getRootElement(),saveVehiclesc)
Alles anzeigen