Wysłany: 2017-12-14, 22:24
mis14
Wiek: 25 Na forum: 3924 dni Posty: 185
Piwa : 73
je?li si? data przedawni powinno zwolni? dom a nie zwalnia db3 b??d ?aden : addEventHandler ( "onResourceStart" , resourceRoot , function()
local q = exports [ "db" ]: dbGet ( "SELECT * FROM Domy" )
for i , v in ipairs ( q ) do
v . wejscie = 1 ( v . wejscie , "," )
if v . nwlasciciel : len () < 3 then id = 1273 else id = 1272 end
local wejscie = createPickup ( v . wejscie [ 1 ], v . wejscie [ 2 ], v . wejscie [ 3 ], 3 , id , 0 , 0 )
local cwejscie = createColSphere ( v . wejscie [ 1 ], v . wejscie [ 2 ], v . wejscie [ 3 ], 1 )
local wlasciciel = false
local nwlascciiel = false
if id == 1273 then
wlasciciel = "brak"
nwlasciciel = "brak"
else
wlasciciel = v . wlasciciel
nwlasciciel = v . nwlasciciel
end
v . wyjscie = 1 ( v . wyjscie , "," )
v . tpw = 1 ( v . tpw , "," )
setElementData ( cwejscie , "dom" , {
[ "id" ]= v . id ,
[ "wlasciciel" ]= wlasciciel ,
[ "nwlasciciel" ]= nwlasciciel ,
[ "cena" ]= v . cena ,
[ "nazwa" ]= v . nazwa ,
[ "x" ]= v . tpw [ 1 ],
[ "y" ]= v . tpw [ 2 ],
[ "z" ]= v . tpw [ 3 ],
[ "data" ]= v . data ,
[ "int" ]= v . int ,
[ "organizacja" ]= v . organizacja
})
local wyjscie = createMarker ( v . wyjscie [ 1 ], v . wyjscie [ 2 ], v . wyjscie [ 3 ], "arrow" , 1 , 0 , 0 , 255 )
setElementData ( wyjscie , "wdom" , {
[ "x" ]= v . wejscie [ 1 ],
[ "y" ]= v . wejscie [ 2 ],
[ "z" ]= v . wejscie [ 3 ],
})
setElementInterior ( wyjscie , v . int )
setElementDimension ( wyjscie , v . id )
end
end )
setTimer ( function()
local time = getRealTime ()
local hours = time . hour
local minute = time . minute
if tonumber ( hours ) == 23 and tonumber ( minute ) == 59 then
outputDebugString ( "* Zresetowano domki *" )
restartResource ( getThisResource ())
end
end , 999 * 60 , 0 )
function refreshDomy ()
local q = exports [ 'db' ]: dbGet ( "SELECT * FROM Domy" )
for i , v in ipairs ( q ) do
local qq = exports [ 'db' ]: dbGet ( "SELECT * FROM Domy WHERE id=?" , v . id )
local qq2 = exports [ 'db' ]: dbGet ( "SELECT * FROM Domy WHERE id=? AND data<NOW()" , v . id )
if #qq2 > 0 then
exports [ 'db' ]: dbGet ( "UPDATE Domy SET wlasciciel=0, nwlasciciel=?, data=?, organizacja=? WHERE id=?" , "" , "0000-00-00" , "brak" , id )
local query1 = exports [ "db" ]: dbSet ( "UPDATE organization_list set spawn=? where id=?" , "0,0,0" , code )
restartResource ( getThisResource ())
end
end
end
setTimer ( refreshDomy , 10 * 1000 * 5 , 0 )
addCommandHandler ( "refreshdomy" , function( player )
if getElementData ( player , "player:admin" ) then
local ranga = getElementData ( player , "player:level" )
if ranga == 4 or ranga == 3 then
refreshDomy ()
end
end
end )
addCommandHandler ( "dom" , function( g , _ , c , ...)
if ... and c and getElementData ( g , "player:admin" ) then
local ranga = getElementData ( g , "player:level" )
if ranga == 3 or ranga == 4 or ranga == 2 then
local x , y , z = getElementPosition ( g )
local n = table . concat ({...}, " " )
outputChatBox ( "Dom na " .. x .. ":" .. y .. ":" .. z .. " nazwa " .. n .. " za cene " .. string . format ( "%1.2f" , c ).. " PLN" , g )
local wejscie = x .. "," .. y .. "," .. z
exports [ 'db' ]: dbGet ( "INSERT INTO Domy SET wlasciciel=0, nwlasciciel=?, nazwa=?, data=?, wejscie=?, wyjscie=?, tpw=?, cena=?, organizacja=?" , "" , n , "0000-00-00" , wejscie , "318.61, 1114.48, 1083.88" , "318.39, 1116.68, 1083.88" , c , "brak" )
restartResource ( getThisResource ())
end
end
end )
addEvent ( "zDom" , true )
addEventHandler ( "zDom" , root , function( id )
exports [ 'db' ]: dbGet ( "UPDATE Domy SET wlasciciel=0, nwlasciciel=?, data=?, organizacja=? WHERE id=?" , "" , "0000-00-00" , "brak" , id )
restartResource ( getThisResource ())
local uid = getElementData ( source , "player:uid" )
local code = getElementData ( source , "player:organization:id" )
local result = exports [ "db" ]: dbGet ( "SELECT * FROM organizations WHERE uid=? and code=?" , uid , code )
if result and #result > 0 then
if result [ 1 ]. rank == 4 then
local x , y , z = getElementPosition ( source )
local query1 = exports [ "db" ]: dbSet ( "UPDATE organization_list set spawn=? where id=?" , "0,0,0" , code )
end
end
end )
local function getPlayerDBID ( plr )
local c = getElementData ( plr , "player:uid" )
if not c then return nil end
return tonumber ( c )
end
addEvent ( "kDom" , true )
addEventHandler ( "kDom" , root , function( id , dni , koszt )
if not id and not dni and not koszt then return end
local dbid = getPlayerDBID ( client )
local hajs = getPlayerMoney ( client )
koszt = dni * koszt
CD = id
CD2 = dni
CD3 = koszt
if tonumber ( koszt ) > hajs then
exports [ "noti" ]: noti ( "Nie sta? ci? na zakup tego domu, potrzebujesz " .. koszt .. " PLN." , client )
return
end
local r = exports [ 'db' ]: dbSet ( "UPDATE Domy SET wlasciciel=?,nwlasciciel=?,data=IF(data>NOW(),data,NOW())+INTERVAL ? DAY WHERE id=?" , dbid , getPlayerName ( client ), dni , id )
exports [ "db" ]: dbSet ( "insert into Logi_domy SET id_dom=?, gracz=?,serial=?,ile_dni=?,kwota=?,data=NOW()" , CD , getPlayerName ( client ), getPlayerSerial ( client ), CD2 , CD3 , data )
setPlayerMoney ( client , hajs - koszt )
exports [ "noti" ]: noti ( "Zakupi?e?/przed?u?y?e? mieszkanie o id " .. id .. " na ilo?? dni " .. dni .. " za cene " .. koszt .. " PLN." , client )
restartResource ( getThisResource ())
end )
addEvent ( "tdDomu" , true )
addEventHandler ( "tdDomu" , root , function( x , y , z , int , dim )
if int and dim then
setElementInterior ( client , int )
setElementDimension ( client , dim )
else
setElementDimension ( client , 0 )
setElementInterior ( client , 0 )
end
setElementPosition ( client , x , y , z )
end )
addEvent ( "przepiszDom" , true )
addEventHandler ( "przepiszDom" , root , function( id )
local przepisywanie = exports [ 'db' ]: dbGet ( "UPDATE Domy SET organizacja=? WHERE id=?" , getElementData ( source , "player:organization" ), id )
restartResource ( getThisResource ())
local uid = getElementData ( source , "player:uid" )
local code = getElementData ( source , "player:organization:id" )
local result = exports [ "db" ]: dbGet ( "SELECT * FROM organizations WHERE uid=? and code=?" , uid , code )
if result and #result > 0 then
if result [ 1 ]. rank == 4 then
local x , y , z = getElementPosition ( source )
local query1 = exports [ "db" ]: dbSet ( "UPDATE organization_list set spawn=? where id=?" , ( "%s,%s,%s" ): format ( x , y , z ), code )
end
end
end )
addEvent ( "odpiszDom" , true )
addEventHandler ( "odpiszDom" , root , function( id )
local przepisywanie = exports [ 'db' ]: dbGet ( "UPDATE Domy SET organizacja=? WHERE id=?" , "brak" , id )
restartResource ( getThisResource ())
local uid = getElementData ( source , "player:uid" )
local code = getElementData ( source , "player:organization:id" )
local result = exports [ "db" ]: dbGet ( "SELECT * FROM organizations WHERE uid=? and code=?" , uid , code )
if result and #result > 0 then
if result [ 1 ]. rank == 4 then
local x , y , z = getElementPosition ( source )
local query1 = exports [ "db" ]: dbSet ( "UPDATE organization_list set spawn=? where id=?" , "0,0,0" , code )
end
end
end )
Wysłany: 2017-12-14, 22:45
koxpl2x22
MAPPER-ALLEREK
Wiek: 23 Na forum: 4556 dni Posty: 375
Nick w MP: ALLEREK
Piwa : 1726
Bo z tego co widze tu nie ma nic takiego.
Daj do tabeli mysql czas w kt?rym dom ma sie usunac i przy refreshowaniu domk?w sprawdzaj czy czas domku jest mniejszy od czasu obecnego, je?li tak, zwolnij go.
Wysłany: 2017-12-14, 22:48
mis14
Wiek: 25 Na forum: 3924 dni Posty: 185
Piwa : 73
"koxpl2x22" napisał/a :Bo z tego co widze tu nie ma nic takiego.
Daj do tabeli mysql czas w kt?rym dom ma sie usunac i przy refreshowaniu domk?w sprawdzaj czy czas domku jest mniejszy od czasu obecnego, je?li tak, zwolnij go.
mo?esz powiedzie? jak bo a? tak dobrze mysql nie znam jest tam
Wysłany: 2017-12-14, 23:32
.RiV
Wiek: 25 Na forum: 3588 dni Posty: 554
Nick w MP: Split
Piwa : 2596
Wyt?umaczenie: Je?eli data b?dzie mniejsza od aktualnego czasu
Podpis
Autor OGRPG, na scenie MTA od 2012 roku.
Użytkownik: 08.08.2016
GTAO Member: 06.02.2017
Support-Team: 17.06.2017 & 01.06.2019 - 18.11.2019
Moderator: 14.01.2018 - 09.08.2018
Wysłany: 2017-12-15, 09:59
mis14
Wiek: 25 Na forum: 3924 dni Posty: 185
Piwa : 73
".WhiteBlue" napisał/a :Wyt?umaczenie: Je?eli data b?dzie mniejsza od aktualnego czasu
no tak jest ale czemu nie chce zadzia?a? jest u?yte w skrypcie to
Wysłany: 2017-12-15, 13:26
koxpl2x22
MAPPER-ALLEREK
Wiek: 23 Na forum: 4556 dni Posty: 375
Nick w MP: ALLEREK
Piwa : 1726
zdefiniuj now() jako
local now = getRealTime ()
Wysłany: 2017-12-15, 17:51
mis14
Wiek: 25 Na forum: 3924 dni Posty: 185
Piwa : 73
"koxpl2x22" napisał/a :zdefiniuj now() jako
local now = getRealTime ()
nie pomog?o
Wysłany: 2017-12-15, 19:43
marcin778
Krytyk serwerów MTA
Wiek: 24 Na forum: 4149 dni Posty: 2268
Nick w MP: Marcineg
Piwa : 4662
koxpl2x22 , Bzdura z tym getRealTime.
mis14 ,
exports [ 'db' ]: dbGet ( "UPDATE Domy SET wlasciciel=0, nwlasciciel=?, data=?, organizacja=? WHERE id=?" , "" , "0000-00-00" , "brak" , id ) nie korzystam i nie korzysta?em z og ale czy tutaj aby nie powinno by? dbSet zamiast dbGet? I te puste "" nale?y usun??, skoro ustawiasz sta?? warto?? 0.
Czyli
exports [ 'db' ]: dbSet ( "UPDATE Domy SET wlasciciel=0, nwlasciciel=?, data=?, organizacja=? WHERE id=?" , "0000-00-00" , "brak" , id )
Wysłany: 2017-12-15, 21:18
mis14
Wiek: 25 Na forum: 3924 dni Posty: 185
Piwa : 73
poradzi?em sobie sam dzi?kuje
Tagi: zwalnianie :: domu
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: