DJglizdek
Uczeń LUA
Wiek: 24 Na forum: 4168 dni Posty: 75
Nick w MP: DJglizdek
Piwa : 5
Problem dalej nie znika
Umieszam odpowiednie za zapis broni fragmenty kodu
Zapis broni:
function playerQuitServer ()
if getElementData ( source , "player_logged" ) == true then
local qh = dbQuery ( conn , "SELECT * FROM userdata" )
local result = dbPoll ( qh , - 1 )
if result then
local x , y , z = getElementPosition ( source )
local rx , ry , rz = getElementRotation ( source )
local hp = getElementHealth ( source )
local armor = getPedArmor ( source )
local money = getPlayerMoney ( source )
local weapons = {}
for i = 0 , 12 do
table . insert ( weapons , getPedWeapon ( source , i ))
end
local ammo = {}
for i = 0 , 12 do
table . insert ( ammo , getPedTotalAmmo ( source , i ))
end
dbExec ( conn , "UPDATE userdata SET position=?, rotation=?, stats=?, weapon=?, ammo=? WHERE uid=?" , toJSON ({ x , y , z }), toJSON ({ rx , ry , rz }), toJSON ({ hp , armor , money }), toJSON ( weapons ), toJSON ( ammo ), getElementData ( source , "player_uid" ))
end
dbFree ( qh )
end
end
addEventHandler ( "onPlayerQuit" , getRootElement (), playerQuitServer )
wczytywanie broni:
if getElementData ( plr , "player_uid" ) == row [ "uid" ] then
local position = fromJSON ( row [ "position" ])
local rotation = fromJSON ( row [ "rotation" ])
local stats = fromJSON ( row [ "stats" ])
weapon = fromJSON ( row [ "weapon" ])
ammo = fromJSON ( row [ "ammo" ])
setElementPosition ( plr , position [ 1 ], position [ 2 ], position [ 3 ])
setElementRotation ( plr , rotation [ 1 ], rotation [ 2 ], rotation [ 3 ])
setElementHealth ( plr , stats [ 1 ])
setPedArmor ( plr , stats [ 2 ])
setPlayerMoney ( plr , stats [ 3 ])
takeAllWeapons ( plr )
for i = 1 , 13 do
giveWeapon ( plr , weapon [ i ], ammo [ i ])
outputChatBox ( weapon [ i ])
end
outputChatBox ( "#00cc00INFO: pomy?lnie zalogowano na konto" , plr , 255 , 255 , 255 , true )
triggerClientEvent ( plr , "playerLogged" , plr )
break
else
outputChatBox ( "#cc0000B??D: nieznana awaria, skontaktuj si? z administratorem [numer]" , plr , 255 , 255 , 255 , true )
end