STOPseba
Emeryt na scenie MTA
Wiek: 25 Na forum: 3771 dni Posty: 448
Nick w MP: STOPseba
Piwa : 5014
Witam
[you]
!
Witam chcia?em zrobi? spawn w panelu logowania do domu ale i? mam taki problem ze nie wiem jak to zrobi? z tym systemem dom?w chodzi tu o co? takiego jak "player:house" na ya ist itp Je?li kto? wie jak to zrobi? lub mnie nakieruje z g?ry Dzi?kuje.
(system dom?w Aspera)
C:
--[[
Autor : Asper
Skrypt : System domow
Dla : . newMode
]]
bindKey ( 'i' , 'both' , function( key , keyState )
if keyState == 'down' then
for k , v in ipairs ( getElementsByType ( 'colshape' , resourceRoot ) ) do
local dom = getElementData ( v , "dom" )
if tonumber ( dom . wlasciciel ) then
createBlipAttachedTo ( v , 32 , 2 , 255 , 0 , 0 , 255 , 100 , 500 );
else
createBlipAttachedTo ( v , 31 , 2 , 255 , 0 , 0 , 255 , 100 , 500 );
end
end
else
for k , v in ipairs ( getElementsByType ( 'blip' , getResourceRootElement () ) ) do
destroyElement ( v )
end
end
end )
local screenW , screenH = guiGetScreenSize ()
local sx , sy = guiGetScreenSize ()
function mysz ( psx , psy , pssx , pssy , abx , aby )
if not isCursorShowing () then return end
cx , cy = getCursorPosition ()
cx , cy = cx * sx , cy * sy
if cx >= psx and cx <= psx + pssx and cy >= psy and cy <= psy + pssy then
return true , cx , cy
else
return false
end
end
local ustawienia = nil
local panel = false
local edit = guiCreateEdit ( 0.786 , 0.48 , 0.159 , 0.057 , "1" , true )
guiSetVisible ( edit , false )
guiEditSetMaxLength ( edit , 2 )
guiSetAlpha ( edit , 0.5 )
local c = guiCreateFont ( ":nm-noti/czcionka.ttf" , 10 )
guiSetFont ( edit , c )
local czcionka = dxCreateFont ( ":nm-geodeta/czcionka.ttf" , 10 )
if not czcionka then czcionka = "default-bold" end
function guiKupno ()
exports [ "nm-blur" ]: dxDrawBluredRectangle ( screenW * 0.7357 , screenH * 0.3112 , screenW * 0.2504 , screenH * 0.3802 , tocolor ( 150 , 150 , 150 , 255 ))
dxDrawRectangle ( screenW * 0.7357 , screenH * 0.3099 , screenW * 0.2504 , screenH * 0.0599 , tocolor ( 25 , 75 , 125 , 155 ), false )
local info = "Panel kupna domu"
if ustawienia . wlasciciel == getElementData ( localPlayer , "dbid" ) then
info = "Panel przed?u?ania domu"
end
local dni = "Ilo?? dni"
if ustawienia . wlasciciel == getElementData ( localPlayer , "dbid" ) then
dni = "Ilo?? dni\n(( Dom jest op?acony do " .. ustawienia . data .. "))"
end
dxDrawText ( info , ( screenW * 0.7357 ) + 1 , ( screenH * 0.3099 ) + 1 , ( screenW * 0.9861 ) + 1 , ( screenH * 0.3698 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
dxDrawText ( info , screenW * 0.7357 , screenH * 0.3099 , screenW * 0.9861 , screenH * 0.3698 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
dxDrawText ( dni , screenW * 0.7650 , screenH * 0.4010 , screenW * 0.9612 , screenH * 0.4674 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
dxDrawRectangle ( screenW * 0.7877 , screenH * 0.4805 , screenW * 0.1552 , screenH * 0.0560 , tocolor ( 255 , 255 , 255 , 255 ), false )
if mysz ( screenW * 0.7804 , screenH * 0.5742 , screenW * 0.1713 , screenH * 0.0677 ) then
dxDrawRectangle ( screenW * 0.7804 , screenH * 0.5742 , screenW * 0.1713 , screenH * 0.0677 , tocolor ( 25 , 75 , 125 , 180 ), false )
else
dxDrawRectangle ( screenW * 0.7804 , screenH * 0.5742 , screenW * 0.1713 , screenH * 0.0677 , tocolor ( 25 , 75 , 125 , 125 ), false )
end
dxDrawText ( "Zakup dom o id " .. ustawienia . id , ( screenW * 0.7796 ) + 1 , ( screenH * 0.5742 ) + 1 , ( screenW * 0.9517 ) + 1 , ( screenH * 0.6419 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Zakup dom o id " .. ustawienia . id , screenW * 0.7796 , screenH * 0.5742 , screenW * 0.9517 , screenH * 0.6419 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
if mysz ( screenW * 0.7423 , screenH * 0.6445 , screenW * 0.0300 , screenH * 0.0417 ) then
dxDrawRectangle ( screenW * 0.7423 , screenH * 0.6445 , screenW * 0.0300 , screenH * 0.0417 , tocolor ( 25 , 75 , 125 , 180 ), false )
else
dxDrawRectangle ( screenW * 0.7423 , screenH * 0.6445 , screenW * 0.0300 , screenH * 0.0417 , tocolor ( 25 , 75 , 125 , 125 ), false )
end
dxDrawText ( "X" , ( screenW * 0.7423 ) + 1 , ( screenH * 0.6445 ) + 1 , ( screenW * 0.7723 ) + 1 , ( screenH * 0.6862 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
dxDrawText ( "X" , screenW * 0.7423 , screenH * 0.6445 , screenW * 0.7723 , screenH * 0.6862 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
end
function gui ()
local nazwa = ustawienia . nazwa
exports [ "nm-blur" ]: dxDrawBluredRectangle ( screenW * 0.3360 , screenH * 0.2552 , screenW * 0.3280 , screenH * 0.4909 , tocolor ( 150 , 150 , 150 , 255 ))
dxDrawRectangle ( screenW * 0.3360 , screenH * 0.2552 , screenW * 0.3280 , screenH * 0.0495 , tocolor ( 25 , 75 , 125 , 155 ), false )
dxDrawText ( nazwa , ( screenW * 0.3360 ) + 1 , ( screenH * 0.2552 ) + 1 , ( screenW * 0.6640 ) + 1 , ( screenH * 0.3047 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
dxDrawText ( nazwa , screenW * 0.3360 , screenH * 0.2552 , screenW * 0.6640 , screenH * 0.3047 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
local wlasciciel = ustawienia . nwlasciciel
local cena = string . format ( "%1.2f" , ustawienia . cena )
local id = ustawienia . id
local status = "OFFLINE"
if getPlayerFromName ( wlasciciel ) then
status = "ONLINE"
end
local info = wlasciciel .. " (" .. status .. ")"
if wlasciciel == "brak" then
info = "brak"
end
dxDrawText ( "ID domku: " .. id .. "\nW?a?ciciel domku: " .. info .. "\nCena domku " .. cena .. " PLN" , ( screenW * 0.3463 ) + 1 , ( screenH * 0.3516 ) + 1 , ( screenW * 0.6486 ) + 1 , ( screenH * 0.5130 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
dxDrawText ( "ID domku: " .. id .. "\nW?a?ciciel domku: " .. info .. "\nCena domku " .. cena .. " PLN" , screenW * 0.3463 , screenH * 0.3516 , screenW * 0.6486 , screenH * 0.5130 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
if mysz ( screenW * 0.3536 , screenH * 0.6003 , screenW * 0.1384 , screenH * 0.0755 ) then
dxDrawRectangle ( screenW * 0.3536 , screenH * 0.6003 , screenW * 0.1384 , screenH * 0.0755 , tocolor ( 25 , 75 , 125 , 180 ), false )
else
dxDrawRectangle ( screenW * 0.3536 , screenH * 0.6003 , screenW * 0.1384 , screenH * 0.0755 , tocolor ( 25 , 75 , 125 , 125 ), false )
end
dxDrawText ( "Zobacz dom" , ( screenW * 0.3536 ) + 1 , ( screenH * 0.5990 ) + 1 , ( screenW * 0.4919 ) + 1 , ( screenH * 0.6758 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Zobacz dom" , screenW * 0.3536 , screenH * 0.5990 , screenW * 0.4919 , screenH * 0.6758 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
if mysz ( screenW * 0.4092 , screenH * 0.5091 , screenW * 0.1786 , screenH * 0.0638 ) then
dxDrawRectangle ( screenW * 0.4092 , screenH * 0.5091 , screenW * 0.1786 , screenH * 0.0638 , tocolor ( 25 , 75 , 125 , 180 ), false )
else
dxDrawRectangle ( screenW * 0.4092 , screenH * 0.5091 , screenW * 0.1786 , screenH * 0.0638 , tocolor ( 25 , 75 , 125 , 125 ), false )
end
local bnapis = ""
if ustawienia . wlasciciel ~= "brak" and ustawienia . wlasciciel ~= getElementData ( localPlayer , "dbid" ) then
bnapis = "Dom zosta? ju? wynaj?ty"
elseif ustawienia . wlasciciel == "brak" then
bnapis = "Kup dom"
elseif ustawienia . wlasciciel ~= "brak" and ustawienia . nwlasciciel == getPlayerName ( localPlayer ) then
bnapis = "Przed?u? dom"
end
dxDrawText ( bnapis , ( screenW * 0.4092 ) + 1 , ( screenH * 0.5078 ) + 1 , ( screenW * 0.5878 ) + 1 , ( screenH * 0.5729 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
dxDrawText ( bnapis , screenW * 0.4092 , screenH * 0.5078 , screenW * 0.5878 , screenH * 0.5729 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
if ustawienia . wlasciciel == getElementData ( localPlayer , "dbid" ) then
if mysz ( screenW * 0.5066 , screenH * 0.6003 , screenW * 0.1384 , screenH * 0.0755 ) then
dxDrawRectangle ( screenW * 0.5066 , screenH * 0.6003 , screenW * 0.1384 , screenH * 0.0755 , tocolor ( 25 , 75 , 125 , 180 ), false )
else
dxDrawRectangle ( screenW * 0.5066 , screenH * 0.6003 , screenW * 0.1384 , screenH * 0.0755 , tocolor ( 25 , 75 , 125 , 125 ), false )
end
dxDrawText ( "Zwolnij dom" , ( screenW * 0.5066 ) + 1 , ( screenH * 0.5990 ) + 1 , ( screenW * 0.6449 ) + 1 , ( screenH * 0.6758 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Zwolnij dom" , screenW * 0.5066 , screenH * 0.5990 , screenW * 0.6449 , screenH * 0.6758 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , czcionka , "center" , "center" , false , false , false , false , false )
end
end
addEventHandler ( "onClientClick" , root , function( b , s )
if b ~= "state" and s ~= "down" then return end
if mysz ( screenW * 0.3536 , screenH * 0.6003 , screenW * 0.1384 , screenH * 0.0755 ) and panel == true then
triggerServerEvent ( "tdDomu" , localPlayer , ustawienia . x , ustawienia . y , ustawienia . z , ustawienia . int , ustawienia . id )
elseif mysz ( screenW * 0.5066 , screenH * 0.6003 , screenW * 0.1384 , screenH * 0.0755 ) and panel == true then
if ustawienia . wlascciel ~= "brak" and ustawienia . wlasciciel ~= getElementData ( localPlayer , "dbid" ) then return end
triggerServerEvent ( "zDom" , localPlayer , ustawienia . id )
exports [ "nm-noti" ]: noti ( "Pomy?lnie zwolni?e? dom o id " .. ustawienia . id )
elseif mysz ( screenW * 0.4092 , screenH * 0.5091 , screenW * 0.1786 , screenH * 0.0638 ) and panel == true then
if ustawienia . wlasciciel ~= "brak" and ustawienia . wlasciciel ~= getElementData ( localPlayer , "dbid" ) then return end
addEventHandler ( "onClientRender" , root , guiKupno )
guiSetVisible ( edit , true )
elseif mysz ( screenW * 0.7423 , screenH * 0.6445 , screenW * 0.0300 , screenH * 0.0417 ) and guiGetVisible ( edit ) == true then
guiSetVisible ( edit , false )
removeEventHandler ( "onClientRender" , root , guiKupno )
elseif mysz ( screenW * 0.7804 , screenH * 0.5742 , screenW * 0.1713 , screenH * 0.0677 ) and guiGetVisible ( edit ) == true then
local text = guiGetText ( edit )
if not tonumber ( text ) then return end
if tonumber ( text ) < 1 then
exports [ "nm-noti" ]: noti ( "Ilo?? dni musi przekraca? minimum zero." )
return
end
triggerServerEvent ( "kDom" , localPlayer , ustawienia . id , tonumber ( text ), ustawienia . cena )
end
end )
addEventHandler ( "onClientColShapeHit" , resourceRoot , function( hit )
if hit ~= localPlayer then return end
local dom = getElementData ( source , "dom" )
if not dom then return end
if panel == true then return end
ustawienia = dom
showCursor ( true , false )
panel = true
addEventHandler ( "onClientRender" , root , gui )
end )
addEventHandler ( "onClientMarkerHit" , resourceRoot , function( hit )
if hit ~= localPlayer then return end
if getElementDimension ( source ) ~= getElementDimension ( hit ) then return end
local wdom = getElementData ( source , "wdom" )
if not wdom then return end
triggerServerEvent ( "tdDomu" , hit , wdom . x , wdom . y , wdom . z )
end )
addEventHandler ( "onClientColShapeLeave" , resourceRoot , function( hit )
if hit ~= localPlayer then return end
local dom = getElementData ( source , "dom" )
if not dom then return end
ustawienia = false
showCursor ( false )
panel = false
removeEventHandler ( "onClientRender" , root , gui )
if guiGetVisible ( edit ) == true then
removeEventHandler ( "onClientRender" , root , guiKupno )
guiSetVisible ( edit , false )
end
end )
S:
--[[
Autor : Asper
Skrypt : System domow
Dla : . newMode
]]
addEventHandler ( "onResourceStart" , resourceRoot , function()
local q = exports . mysql : wykonaj ( "SELECT * FROM domy" )
for i , v in ipairs ( q ) do
v . wejscie = split ( 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 = split ( v . wyjscie , "," )
v . tpw = split ( 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 ,
})
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 )
function refreshDomy ()
local q = exports . mysql : wykonaj ( "SELECT * FROM domy" )
for i , v in ipairs ( q ) do
local qq = exports . mysql : wykonaj ( "SELECT * FROM domy WHERE id=?" , v . id )
local t = getRealTime ()
local r = t . year
local m = t . month
local t = t . monthday
r = r + 1900
m = m + 1
if t < 10 then
t = "0" .. t
end
local data = r .. "-" .. m .. "-" .. t
if qq [ 1 ]. data == data then
exports . mysql : wykonaj ( "UPDATE domy SET wlasciciel=0, nwlasciciel=?, data=? WHERE id=?" , "" , "0000-00-00" , q [ 1 ]. id )
restartResource ( getThisResource ())
end
end
end
setTimer ( refreshDomy , 3600000 , 0 )
addCommandHandler ( "dom" , function( g , _ , c , ...)
if ... and c and getElementData ( g , "duty" ) 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 . mysql : wykonaj ( "INSERT INTO domy SET wlasciciel=0, nwlasciciel=?, nazwa=?, data=?, wejscie=?, wyjscie=?, tpw=?, cena=?" , "" , n , "0000-00-00" , wejscie , "318.61, 1114.48, 1083.88" , "318.39, 1116.68, 1083.88" , c )
restartResource ( getThisResource ())
end
end )
addEvent ( "zDom" , true )
addEventHandler ( "zDom" , root , function( id )
exports . mysql : wykonaj ( "UPDATE domy SET wlasciciel=0, nwlasciciel=?, data=? WHERE id=?" , "" , "0000-00-00" , id )
restartResource ( getThisResource ())
end )
local function getPlayerDBID ( plr )
local c = getElementData ( plr , "dbid" )
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 = getElementData ( client , "pieniadze" )
koszt = dni * koszt
koszt = string . format ( "%1.2f" , koszt )
if tonumber ( koszt ) > hajs then
exports [ "nm-noti" ]: noti ( "Nie sta? ci? na zakup tego domu, potrzebujesz " .. koszt .. " PLN." , client )
return
end
local r = exports . mysql : wykonaj ( "UPDATE domy SET wlasciciel=?,nwlasciciel=?,data=IF(data>NOW(),data,NOW())+INTERVAL ? DAY WHERE id=?" , dbid , getPlayerName ( client ), dni , id )
setElementData ( client , "pieniadze" , hajs - koszt )
exports [ "nm-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 )