Wysłany: 2020-07-21, 15:48
TheSebaPL
Mod-team
Wiek: 21 Na forum: 3098 dni Posty: 964
Piwa : 3102
Witam, mam pro?b? pom?g? by kto? doda? do Panelu Logowania spawn na domku tak?e bazie organizacji?
Kod:
if getElementData ( localPlayer , "player:logged" ) then return end
local spawns = {
{ name = "Los Santos" , pos = Vector3 ( 1214.97 , - 1812.75 , 16.59 ),},
{ name = "Prawo Jazdy" , pos = Vector3 ( 1568.04 , - 1893.97 , 13.56 ),},
{ name = "Przechowywalnia LS" , pos = Vector3 ( 1296.48 , - 1868.84 , 13.55 ),},
}
local map = {
size = 1980 ,
zoom = {
actual = 3.0 ,
limit = { 1.3 , 3.0 },
plus = 0 ,
},
moving = nil ,
unit = 1980 / 6000
}
local worldW , worldH = 0 , 0
local mapOffsetX , mapOffsetY = 0 , 0
playerMapOffsetX , playerMapOffsetY = 0 , 0
map . positions = {}
map . positions . w , map . positions . h = 733 * px , 462 * py
map . positions . x , map . positions . y = 650 * px , 309 * py
local newPlayerX , newPlayerY = nil , nil
local function clickMap ( button , state , cx , cy )
if chooseSpawn then
if button == "left" then
if state == "down" then
local x , y , w , h = map . positions . x , map . positions . y , map . positions . w , map . positions . h
if cx >= x and cx <= x + w and cy >= y and cy <= y + h then
mapOffsetX = cx * map . zoom . actual + playerMapOffsetX
mapOffsetY = cy * map . zoom . actual - playerMapOffsetY
mouseCurrentPositionX , mouseCurrentPositionY = getCursorPosition ( )
end
elseif state == "up" then
map . moving = nil
end
end
if button == "left" and state == "down" then
for i , v in ipairs ( spawns ) do
local offsetY = ( 49 * px ) * ( i - 1 )
if mouseIn ( 408 * px , 349 * py + offsetY , 232 * px , 39 * py ) then
triggerServerEvent ( "logging:spawn" , resourceRoot , { pos = { x = v . pos . x , y = v . pos . y , z = v . pos . z }})
spawnGui ( nil )
end
end
end
end
end
local function keyMap ( key )
if chooseSpawn then
if key == "mouse_wheel_down" then
map . zoom . actual = map . zoom . actual + 0.1
if ( map . zoom . actual > map . zoom . limit [ 2 ]) then
map . zoom . actual = map . zoom . limit [ 2 ]
end
elseif key == "mouse_wheel_up" then
map . zoom . actual = map . zoom . actual - 0.1
if ( map . zoom . actual < map . zoom . limit [ 1 ]) then
map . zoom . actual = map . zoom . limit [ 1 ]
end
end
end
end
local function renderMap ()
if chooseSpawn then
alphaSpawn = interpolateBetween ( 0 , 0 , 0 , 255 , 0 , 0 , ( getTickCount () - tickSpawn ) / 500 , "Linear" )
alphaSpawn2 = interpolateBetween ( 0 , 0 , 0 , 200 , 0 , 0 , ( getTickCount () - tickSpawn ) / 500 , "Linear" )
end
local x , y , w , h = map . positions . x , map . positions . y , map . positions . w , map . positions . h ;
local absx , absy = 0 , 0
if isCursorShowing () then
local cursorX , cursorY = getCursorPosition ()
absx = cursorX * sx
absy = cursorY * sy
end
worldW , worldH = map . size * map . zoom . actual , map . size * map . zoom . actual
local mapPX , mapPY = 0 , 0
mapPX , mapPY = getPosInMap ( absx , absy )
mapX , mapY = map . positions . w / 2 - mapPX , map . positions . h / 2 + mapPY
if getKeyState ( "mouse1" ) and not movvv then
if( mouseCurrentPositionX ~= absx and mouseCurrentPositionX ~= absy ) then
map . moving = true
end
if( map . moving ) then
playerMapOffsetX = -( absx * map . zoom . actual - mapOffsetX )
playerMapOffsetY = ( absy * map . zoom . actual - mapOffsetY )
playerMapOffsetX = math . max ( - 3000 , math . min ( 3000 , playerMapOffsetX ) )
playerMapOffsetY = math . max ( - 3000 , math . min ( 3000 , playerMapOffsetY ) )
end
else
map . moving = nil
end
local mapX = ( ( ( 3000 + playerMapOffsetX ) * map . unit ) - ( w / 2 ) * map . zoom . actual )
local mapY = ( ( ( 3000 - playerMapOffsetY ) * map . unit ) - ( h / 2 ) * map . zoom . actual )
local mapWidth , mapHeight = w * map . zoom . actual , h * map . zoom . actual
dxDrawImageSection ( x , y , w , h , mapX , mapY , mapWidth , mapHeight , tex [ "map" ], 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , alphaSpawn ))
if newPlayerX and newPlayerY then
playerMapOffsetX , playerMapOffsetY = interpolateBetween ( playerMapOffsetX , playerMapOffsetY , 0 , newPlayerX , newPlayerY , 0 , ( getTickCount () - tick ) / 750 , "OutQuad" )
if getTickCount () - tick > 750 then
newPlayerX , newPlayerY = nil , nil
movePoint = nil
movvv = nil
end
end
roundedRectangle ( 408 * px , 309 * py , 232 * px , 462 * py , tocolor ( 0 , 0 , 0 , alphaSpawn2 ), false )
dxDrawText ( "Spawny" , 408 * px , 309 * py , 640 * px , 349 * py , tocolor ( 255 , 255 , 255 , alphaSpawn ), 1.00 , font1 , "center" , "center" , false , false , false , false , false )
for i , v in ipairs ( spawns ) do
local offsetY = ( 49 * px ) * ( i - 1 )
local data = { name = v . name }
if mouseIn ( 408 * px , 349 * py + offsetY , 232 * px , 39 * py ) and chooseSpawn then dxDrawRectangle ( 408 * px , 349 * py + offsetY , 232 * px , 39 * py , tocolor ( 40 , 40 , 40 , alphaSpawn2 ), false ) end
dxDrawText ( data . name , 408 * px , 348 * py + offsetY * 2 , 640 * px , 388 * py , tocolor ( 255 , 255 , 255 , alphaSpawn ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
local spawnX , spawnY = v . pos . x , v . pos . y
local centerX , centerY = ( map . positions . x + ( map . positions . w / 2 )), ( map . positions . y + ( map . positions . h / 2 ))
local leftFrame = ( centerX - map . positions . w / 2 ) + ( 28 * px / 2 )
local rightFrame = ( centerX + map . positions . w / 2 ) - ( 28 * px / 2 )
local topFrame = ( centerY - map . positions . h / 2 ) + ( 28 * py / 2 )
local bottomFrame = ( centerY + map . positions . h / 2 ) - ( 28 * py / 2 )
spawnX , spawnY = getMapFromWorldPosition ( spawnX , spawnY )
centerX = math . max ( leftFrame , math . min ( rightFrame , spawnX ))
centerY = math . max ( topFrame , math . min ( bottomFrame , spawnY ))
if mouseIn ( 408 * px , 349 * py + offsetY , 232 * px , 39 * py ) and chooseSpawn then
dxDrawImage ( centerX - 15 * px , centerY - 25 * py , 28 * px , 28 * py , tex [ "point" ], 0 , 0 , 0 , tocolor ( 255 , 0 , 0 , alphaSpawn ))
else
dxDrawImage ( centerX - 15 * px , centerY - 25 * py , 28 * px , 28 * py , tex [ "point" ])
end
if mouseIn ( 408 * px , 349 * py + offsetY , 232 * px , 39 * py ) then
newPlayerX , newPlayerY = v . pos . x , v . pos . y
tick = getTickCount ()
movePoint = true
movvv = true
end
end
end
function spawnGui (bool)
if bool then
createTextures ()
dxSetTextureEdge ( tex [ "map" ], "border" , tocolor ( 0 , 0 , 0 , 0 ))
chooseSpawn = true
tickSpawn = getTickCount ()
font1 = dxCreateFont ( "files/fonts/font.ttf" , 12 )
font2 = dxCreateFont ( "files/fonts/font.ttf" , 10 )
addEventHandler ( "onClientRender" , root , renderMap )
addEventHandler ( "onClientClick" , root , clickMap )
addEventHandler ( "onClientKey" , root , keyMap )
else
showCursor ( false )
showChat ( true )
fadeCamera ( true )
removeEventHandler ( "onClientRender" , root , renderMap )
removeEventHandler ( "onClientClick" , root , clickMap )
removeEventHandler ( "onClientKey" , root , keyMap )
if font1 and font2 then destroyElement ( font1 ) destroyElement ( font2 ) end
chooseSpawn = nil
tickBg = getTickCount ()
panel = nil
if intro then stopSound ( intro ) intro = nil end
destroyTextures ()
end
end
--[[]]--
function getPositionFromElementOffset ( element , offX , offY , offZ )
local m = getElementMatrix ( element )
local x = offX * m [ 1 ][ 1 ] + offY * m [ 2 ][ 1 ] + offZ * m [ 3 ][ 1 ] + m [ 4 ][ 1 ]
local y = offX * m [ 1 ][ 2 ] + offY * m [ 2 ][ 2 ] + offZ * m [ 3 ][ 2 ] + m [ 4 ][ 2 ]
local z = offX * m [ 1 ][ 3 ] + offY * m [ 2 ][ 3 ] + offZ * m [ 3 ][ 3 ] + m [ 4 ][ 3 ]
return x , y , z
end
function getPosInMap ( mapX , mapY )
local x , y , w , h = map . positions . x , map . positions . y , map . positions . w , map . positions . h
local worldX = playerMapOffsetX +( ( mapX -( x + w / 2 ) ) / map . zoom . actual ) / map . unit
local worldY = playerMapOffsetY -( ( mapY -( y + h / 2 ) ) / map . zoom . actual ) / map . unit
return worldX , worldY
end
function getMapFromWorldPosition ( worldX , worldY )
local centerX , centerY = ( map . positions . x + ( map . positions . w / 2 )), ( map . positions . y + ( map . positions . h / 2 ))
local mapLeftFrame = centerX - (( playerMapOffsetX - worldX ) / map . zoom . actual * map . unit )
local mapRightFrame = centerX + (( worldX - playerMapOffsetX ) / map . zoom . actual * map . unit )
local mapTopFrame = centerY - (( worldY - playerMapOffsetY ) / map . zoom . actual * map . unit )
local mapBottomFrame = centerY + (( playerMapOffsetY - worldY ) / map . zoom . actual * map . unit )
centerX = math . max ( mapLeftFrame , math . min ( mapRightFrame , centerX ))
centerY = math . max ( mapTopFrame , math . min ( mapBottomFrame , centerY ))
return centerX , centerY
end
function getWorldFromMapPosition ( mapX , mapY )
local worldX = playerMapOffsetX + (( mapX * (( map . positions . w * map . zoom . actual ) * 2 )) - ( map . positions . w * map . zoom . actual ))
local worldY = playerMapOffsetY + (( mapY * (( map . positions . h * map . zoom . actual ) * 2 )) - ( map . positions . h * map . zoom . actual )) * - 1
return worldX , worldY
end
Wysłany: 2020-07-21, 16:09
VVirmex
Sgrypter luja
Wiek: 21 Na forum: 3365 dni Posty: 281
Nick w MP: AxyZ
Piwa : 234
Ja wzi??em kawa?ek kodu z paczki PYSa i jedynie bawi?em si? z domkami, nie mia?em pomys?u jakby tu ugry?? spawn organizacji, jak co? mnie najdzie to dodam
(Zamie? tylko pocz?tek kodu)
EDIT: Dodaj? zmian? w kodzie, wraz z pomys?em na spawn organizacji
function spawnorg ()
local q = exports [ "pystories-db" ]: dbGet ( "SLEECT * FROM ogrpg_organizations WHERE xyz=? AND sid=?" , xyz , code )
if q and #q > 0 then
pos = Vector3 ( q [ 1 ]. xyz ),
outputChatBox ( "* Wybrano spawn Organizacyjny." , 255 , 255 , 255 )
else
outputChatBox ( "* Nie posiadasz Organizacji lub nie ma ona ustawionego spawnu." , 255 , 255 , 255 )
pos = Vector3 ( 1214.97 , - 1812.75 , 16.59 ),
return
end
end
function spawndom ()
local domek = getElementData ( localPlayer , "player:house" )
if not domek then
pos = Vector3 ( 1214.97 , - 1812.75 , 16.59 ),
outputChatBox ( "* Nie posiadasz domku lub straci? wa?no??." , 255 , 255 , 255 )
end
end
local spawns = {
{ name = "Los Santos" , pos = Vector3 ( 1214.97 , - 1812.75 , 16.59 ),},
{ name = "Prawo Jazdy" , pos = Vector3 ( 1568.04 , - 1893.97 , 13.56 ),},
{ name = "Przechowywalnia LS" , pos = Vector3 ( 1296.48 , - 1868.84 , 13.55 ),},
{ name = "Domek" , pos = Vector3 ( spawndom ()),},
{ name = "Spawn Organizacji" , pos = Vector3 ( spawnorg ()),},
}
(Je?li ci wyskoczy b??d usu? przecinek przy Vector3, po spawndom, bo nie jestem pewien co do tego.)
Mam nadzieje ?e co? tam zadzia?a
Wysłany: 2020-07-21, 16:34
MeeShuffle
Programista/Grafik
Wiek: 32 Na forum: 4394 dni Posty: 2758
Nick w MP: Shuffle
Piwa : 8575
To nie ten dzia?, od tego masz dzia? o pro?by o przerobienie skryptu, tu si? podpowiada jak to zrobi?.
Wysłany: 2020-07-21, 16:50
TheSebaPL
Mod-team
Wiek: 21 Na forum: 3098 dni Posty: 964
Piwa : 3102
VVirmex , tw?j kod po cz??ci dzia?a poniewa? respi aczkolwiek na podanych kordach.
Wysłany: 2020-07-21, 18:34
VVirmex
Sgrypter luja
Wiek: 21 Na forum: 3365 dni Posty: 281
Nick w MP: AxyZ
Piwa : 234
"TheSebaPL" napisał/a :VVirmex , tw?j kod po cz??ci dzia?a poniewa? respi aczkolwiek na podanych kordach.
Bo nie jestem pewien po pierwsze jaki masz system domk?w a po drugie nie zmieni?e? sobie export?w z bazy danych najprawdopodobniej, chyba ?e zmieni?e?.
Podpis
Kontakt:
Discord: fluffy.rbx
Wiadomość PW Forum [Odpiszę wtedy, kiedy będę mógł]
Support Team: 26.08.2020 do 04.05.2021 [*]
Wysłany: 2020-07-21, 18:49
TheSebaPL
Mod-team
Wiek: 21 Na forum: 3098 dni Posty: 964
Piwa : 3102
VVirmex , system domk?w mam z psrpg czyli pystories.
Tagi: resp :: domku
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: