Wysłany: 2020-01-15, 21:39
Fl!k
Wiek: 26 Na forum: 3592 dni Posty: 162
Piwa : 18
Witam posiadam logowanie i gdy si? loguje , pozniej mam wybieranie spawnu
mam ustawione 3 : Spawn FC, Spawn BB, Urz?d . Gdy klikne na obojetnie kt?ry wywala mnie tylko do FC a nie np. Pod urz?d lub do BB, a b??du w DB3 brak
c_zone.lua
local login = {}
local dist = 100
local angler = 0
rX , rY = 0 , 0
local foncik = dxCreateFont ( "assets/bold.ttf" , 15 )
local foncik2 = dxCreateFont ( "assets/normal.ttf" , 22 )
local foncik1 = dxCreateFont ( "assets/bold.ttf" , 11 )
local sx , sy = guiGetScreenSize () -- pobieramy rozdzielczo ?? gracza kt ? ry widzi gui
local px , py = ( sx / 1366 ),( sy / 768 ) -- dzielimy rozdzielczo ?? gracza kt ? ry widzi gui przez rozdzielczo ?? na kt ? rej by ? o robione
local screenW , screenH = guiGetScreenSize ()
local data ={ showed = nil , button ={}, info = nil , misc = nil , }
function math . round ( number , decimals , method )
decimals = decimals or 0
local factor = 10 ^ decimals
if ( method == "ceil" or method == "floor" ) then return math [ method ]( number * factor ) / factor
else return tonumber (( "%." .. decimals .. "f" ): format ( number )) end
end
function getPointFromDistanceRotation ( x , y , dist , angler )
local a = math . rad ( 90 - angler )
local dx = math . cos ( a ) * dist ;
local dy = math . sin ( a ) * dist ;
return x + dx , y + dy ;
end
function isMouseIn ( 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 dist = 100
local angler = 0
login . required_resources = {
fog = exports [ "dxFog" ]
}
login . positions = {
bg = {
x = 0 ,
y = 0 ,
w = 1366 * px ,
h = 768 * py ,
},
logo = {
x = 515 * px ,
y = 70 * py ,
w = 375 * px ,
h = 195 * py ,
},
lights = {
x = 0 ,
y = 0 ,
w = 1366 * px ,
h = 768 * py ,
},
spawn = {
x = 0 ,
y = 0 ,
w = 1366 * px ,
h = 768 * py ,
}
}
login . textures = {
bg = dxCreateTexture ( "assets/background.png" ),
logo = dxCreateTexture ( "assets/logo.png" ),
lights = dxCreateTexture ( "assets/lights.png" ),
spawn = dxCreateTexture ( "assets/spawn/spawn.png" ),
onebutton = dxCreateTexture ( "assets/spawn/1button.png" ),
twobutton = dxCreateTexture ( "assets/spawn/2button.png" ),
threebutton = dxCreateTexture ( "assets/spawn/3button.png" )
}
function renderZoneBox ()
dxDrawImage ( login . positions . bg . x , login . positions . bg . y , login . positions . bg . w , login . positions . bg . h , login . textures . bg )
login . required_resources . fog : renderFogRectangle ()
dxDrawText ( "Wybierz miejsce spawnu" , 532 * px , 285 * py , 873 * px , 327 * py , tocolor ( 255 , 255 , 255 , 120 ), 1.00 , foncik2 , "center" , "center" , false , false , false , false , false )
dxDrawImage ( login . positions . spawn . x , login . positions . spawn . y , login . positions . spawn . w , login . positions . spawn . h , login . textures . spawn )
if isMouseIn ( 425 * px , 76 * py , 157 * px , 39 * py ) then
dxDrawImage ( 0 , 0 , 1366 * px , 768 * py , login . textures . onebutton )
end
if isMouseIn ( 605 * px , 76 * py , 157 * px , 39 * py ) then
dxDrawImage ( 0 , 0 , 1366 * px , 768 * py , login . textures . twobutton )
end
if isMouseIn ( 784 * px , 76 * py , 157 * px , 39 * py ) then
dxDrawImage ( 0 , 0 , 1366 * px , 768 * py , login . textures . rbutton )
end
dxDrawText ( "Spawn FC" , 429 * px , 85 * py , 582 * px , 115 * py , tocolor ( 255 , 255 , 255 , 120 ), 1.00 , foncik1 , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Spawn BB" , 604 * px , 85 * py , 757 * px , 115 * py , tocolor ( 255 , 255 , 255 , 120 ), 1.00 , foncik1 , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Urzad" , 784 * px , 85 * py , 937 * px , 115 * py , tocolor ( 255 , 255 , 255 , 120 ), 1.00 , foncik1 , "center" , "center" , false , false , false , false , false )
local x , y = getPointFromDistanceRotation (- 296.20 , 1088.70 , dist , angler )
setCameraMatrix ( x , y , 44.25 + 0.9 ,- 296.20 , 1088.70 , 44.25 + 0.9 )
angler =( angler + 0.1 )
end
addEventHandler ( "onClientClick" , root , function( btn , state )
if btn == "left" and state == "down" then
if isMouseIn ( 429 * px , 85 * py , 582 * px , 115 * py ) and data . showed then
setElementData ( localPlayer , "player:spawn" ,{- 205.69 , 1212.20 , 19.89 }) -- 1 button
triggerEvent ( "onClientAddNotification" , localPlayer , "Pomy?lnie si? zrespi?e?/a?." , "info" , true , 6500 )
closeZones ()
end
if isMouseIn ( 604 * px , 85 * py , 757 * px , 115 * py ) and data . showed then
setElementData ( localPlayer , "player:spawn" ,{ 207.63 , - 63.86 , 1.58 }) -- 2button
triggerEvent ( "onClientAddNotification" , localPlayer , "Pomy?lnie si? zrespi?e?/a?." , "info" , true , 6500 )
closeZones ()
end
if isMouseIn ( 784 * px , 85 * py , 937 * px , 115 * py ) and data . showed then
setElementData ( localPlayer , "player:spawn" ,{- 59.14 , 1176.20 , 19.63 }) -- 3button
triggerEvent ( "onClientAddNotification" , localPlayer , "Pomy?lnie si? zrespi?e?/a?." , "info" , true , 6500 )
closeZones ()
end
end
end )
function closeZones ()
showChat ( true )
showCursor ( false )
fadeCamera ( false )
setElementAlpha ( localPlayer , 255 )
stopSound ( data . misc )
showPlayerHudComponent ( "all" , false )
showPlayerHudComponent ( "radar" , true )
data . showed = false
setElementData ( localPlayer , "player:logged" , true )
triggerServerEvent ( "core:spawnPlayer" , localPlayer )
removeEventHandler ( "onClientRender" , root , renderblur )
removeEventHandler ( "onClientRender" , root , renderZoneBox )
end
function showZones ( misc )
data . misc = misc
data . showed = true
showPlayerHudComponent ( "all" , false )
guiSetInputMode ( "no_binds_when_editing" )
showChat ( false )
addEventHandler ( "onClientRender" , root , renderZoneBox )
end
function filedelet ()
if fileExists ( "c_zone.lua" ) then
fileDelete ( "c_zone.lua" )
end
end
addEventHandler ( "onClientResourceStart" , getResourceRootElement ( getThisResource ()), filedelet )
Wysłany: 2020-01-15, 21:53
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
Nic dziwnego, nigdzie tutaj w kodzie nie ustalasz pozycji gracza ani go nie spawnujesz.
Albo nie wys?a?e? ca?ego kodu, albo u?yj jednej z poni?szych funkcji
Więcej informacji znajdziesz w Wikipedii MTA: spawnPlayer
Przeanalizuj dok?adnie sw?j kod.
Wysłany: 2020-01-15, 22:58
Fl!k
Wiek: 26 Na forum: 3592 dni Posty: 162
Piwa : 18
To przypadkiem nie to ?
if btn == "left" and state == "down" then
if isMouseIn ( 429 * px , 85 * py , 582 * px , 115 * py ) and data . showed then
setElementData ( localPlayer , "player:spawn" ,{- 205.69 , 1212.20 , 19.89 }) -- 1 button
triggerEvent ( "onClientAddNotification" , localPlayer , "Pomy?lnie si? zrespi?e?/a?." , "info" , true , 6500 )
closeZones ()
end
if isMouseIn ( 604 * px , 85 * py , 757 * px , 115 * py ) and data . showed then
setElementData ( localPlayer , "player:spawn" ,{ 207.63 , - 63.86 , 1.58 }) -- 2button
triggerEvent ( "onClientAddNotification" , localPlayer , "Pomy?lnie si? zrespi?e?/a?." , "info" , true , 6500 )
closeZones ()
end
if isMouseIn ( 784 * px , 85 * py , 937 * px , 115 * py ) and data . showed then
setElementData ( localPlayer , "player:spawn" ,{- 59.14 , 1176.20 , 19.63 }) -- 3button
triggerEvent ( "onClientAddNotification" , localPlayer , "Pomy?lnie si? zrespi?e?/a?." , "infno" , true , 6500 )
closeZones ()
end
Wysłany: 2020-01-16, 06:36
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
No i gdzie masz te funkcje, kt?re wymieni?em w po?cie wcze?niej?
Dlatego m?wi?, przeanalizuj kod. Zobacz co robisz closeZone, jakie eventy triggeruje itd.
Wysłany: 2020-01-16, 16:06
Fl!k
Wiek: 26 Na forum: 3592 dni Posty: 162
Piwa : 18
No jest w closeZone :
triggerServerEvent ( "core:spawnPlayer" , localPlayer )
Wysłany: 2020-01-16, 18:11
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
No to wklej funkcje z tego eventu. To jest tylko trigger. Radz? poczyta?
Wysłany: 2020-01-16, 20:15
Fl!k
Wiek: 26 Na forum: 3592 dni Posty: 162
Piwa : 18
Wysłany: 2020-01-16, 20:32
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
No co tu du?o m?wi?, musisz wklei? tre?? funkcji, kt?ra jest wykorzystywana w tym evencie ("core:spawnPlayer").
Wysłany: 2020-01-17, 18:25
Fl!k
Wiek: 26 Na forum: 3592 dni Posty: 162
Piwa : 18
Tylko ze mam 2 inne logowanie i tez tego nie ma a jakos mnie tepa w dane miejsca ?
Wysłany: 2020-01-18, 11:00
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
No to szukaj w ca?ym gamemodzie funkcji "spawnPlayer" albo "setElementPosition" bo jako? musi Ci? gdzie? respi?. No chyba, ?e tego w og?le nie masz to dodaj sobie event z klienta do serwera po zalogowaniu i wtedy tam spawnuj gracza.
Wysłany: 2020-01-18, 11:57
Fl!k
Wiek: 26 Na forum: 3592 dni Posty: 162
Piwa : 18
Tylko ze inne logowania dzialaja ?
Wysłany: 2020-01-18, 12:44
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
No i co z tego, to musisz naprawi? ten co nie dzia?a. Albo u?yj tych co dzia?aj? i je przer?b graficznie czy co tam chcesz.
Tagi: ten :: sam :: resp
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: