Wysłany: 2015-07-10, 20:19
piotr172
Wiek: 26 Na forum: 4417 dni Posty: 130
Piwa : 2329
U mnie normalnie dzia?a.
strona clienta:
local sX , sY = guiGetScreenSize ()
function createGUIGielda ()
if not guig then
guig = {}
guig [ 1 ] = guiCreateWindow (( sX - 350 )/ 2 , ( sY - 360 )/ 2 , 350 , 360 , "Sprzeda? pojazdu" , false )
guig [ 2 ] = guiCreateLabel ( 10 , 23 , 330 , 40 , "Wybierz z listy graczy, kt?rzy znajduj? si? w makerze tego, komu chcesz sprzeda? pojazd." , false , guig [ 1 ])
guiLabelSetHorizontalAlign ( guig [ 2 ], "center" , true )
guig [ 3 ] = guiCreateGridList ( 10 , 60 , 330 , 250 , false , guig [ 1 ])
guig [ 4 ] = guiGridListAddColumn ( guig [ 3 ], "Gracze" , 0.9 )
guig [ 5 ] = guiCreateButton ( 10 , 320 , 80 , 30 , "Zamknij" , false , guig [ 1 ])
guig [ 6 ] = guiCreateButton ( 260 , 320 , 80 , 30 , "Dalej" , false , guig [ 1 ])
addEventHandler ( "onClientGUIClick" , guig [ 5 ], onSprzedazClickZamknij , false )
addEventHandler ( "onClientGUIClick" , guig [ 6 ], onSprzedazClickGraczeDalej , false )
-- wybieranie pojazdu
guig [ 7 ] = guiCreateWindow (( sX - 350 )/ 2 , ( sY - 360 )/ 2 , 350 , 360 , "Sprzeda? pojazdu" , false )
guig [ 8 ] = guiCreateLabel ( 10 , 23 , 330 , 40 , "Z listy pojazd?w wybierz pojazd, kt?ry chcesz sprzeda?" , false , guig [ 7 ])
guiLabelSetHorizontalAlign ( guig [ 8 ], "center" , true )
guig [ 9 ] = guiCreateGridList ( 10 , 60 , 330 , 250 , false , guig [ 7 ])
guig [ 10 ] = guiGridListAddColumn ( guig [ 9 ], "Twoje pojazdy" , 0.9 )
guig [ 11 ] = guiCreateButton ( 10 , 320 , 80 , 30 , "Zamknij" , false , guig [ 7 ])
guig [ 12 ] = guiCreateButton ( 260 , 320 , 80 , 30 , "Dalej" , false , guig [ 7 ])
addEventHandler ( "onClientGUIClick" , guig [ 11 ], onSprzedazClickZamknij , false )
addEventHandler ( "onClientGUIClick" , guig [ 12 ], onSprzedazClickPojazdyDalej , false )
-- cena
guig [ 13 ] = guiCreateWindow (( sX - 280 )/ 2 , ( sY - 190 )/ 2 , 280 , 190 , "Sprzeda? pojazdu" , false )
guig [ 14 ] = guiCreateLabel ( 10 , 23 , 260 , 40 , "Wpisz cen? pojazdu, za kt?r? chcesz sprzeda? Tw?j pojazd." , false , guig [ 13 ])
guiLabelSetHorizontalAlign ( guig [ 14 ], "center" , true )
guig [ 15 ] = guiCreateLabel ( 15 , 75 , 30 , 20 , "Cena:" , false , guig [ 13 ])
guig [ 16 ] = guiCreateEdit ( 52 , 71 , 120 , 30 , "" , false , guig [ 13 ])
guig [ 17 ] = guiCreateButton ( 10 , 150 , 80 , 30 , "Zamknij" , false , guig [ 13 ])
guig [ 18 ] = guiCreateButton ( 190 , 150 , 80 , 30 , "Sprzedaj" , false , guig [ 13 ])
addEventHandler ( "onClientGUIClick" , guig [ 17 ], onSprzedazClickZamknij , false )
addEventHandler ( "onClientGUIClick" , guig [ 18 ], onSprzedazClickSprzedaj , false )
end
guiSetVisible ( guig [ 1 ], false )
guiSetVisible ( guig [ 7 ], false )
guiSetVisible ( guig [ 13 ], false )
guiGridListClear ( guig [ 3 ])
guiGridListClear ( guig [ 9 ])
guiSetText ( guig [ 16 ], "" )
showCursor ( true )
end
addEvent ( "pokazGUISprzedazy" , true )
addEventHandler ( "pokazGUISprzedazy" , getRootElement (),
function( players )
createGUIGielda ()
guiSetVisible ( guig [ 1 ], true )
for i , v in pairs ( players ) do
--if v ~= localPlayer then
local row = guiGridListAddRow ( guig [ 3 ])
guiGridListSetItemText ( guig [ 3 ], row , guig [ 4 ], getPlayerName ( v ), false , false )
guiGridListSetItemData ( guig [ 3 ], row , guig [ 4 ], v )
-- end
end
end )
function onSprzedazClickZamknij ()
savePLAYER = nil
saveVEHICLE = nil
guiSetVisible ( guig [ 1 ], false )
guiSetVisible ( guig [ 7 ], false )
guiSetVisible ( guig [ 13 ], false )
showCursor ( false )
end
function onSprzedazClickGraczeDalej ()
local row , column = guiGridListGetSelectedItem ( guig [ 3 ])
if row ~= - 1 then
local player = guiGridListGetItemData ( guig [ 3 ], row , guig [ 4 ])
if player then
savePLAYER = player
triggerServerEvent ( "pobierzListePojazdow" , localPlayer , id )
end
end
end
--<< pojazdy >>--
addEvent ( "pokazListePojazdow" , true )
addEventHandler ( "pokazListePojazdow" , getRootElement (),
function( pojazdy )
guiSetVisible ( guig [ 1 ], false )
guiSetVisible ( guig [ 7 ], true )
for i , v in pairs ( pojazdy ) do
local row = guiGridListAddRow ( guig [ 9 ])
guiGridListSetItemText ( guig [ 9 ], row , guig [ 10 ], getVehicleNameFromModel ( v [ "model" ]), false , false )
guiGridListSetItemData ( guig [ 9 ], row , guig [ 10 ], v [ "id" ])
end
end )
function onSprzedazClickPojazdyDalej ()
local row , column = guiGridListGetSelectedItem ( guig [ 9 ])
if row ~= - 1 then
local id = guiGridListGetItemData ( guig [ 9 ], row , guig [ 10 ])
if id then
saveVEHICLE = id
guiSetVisible ( guig [ 7 ], false )
guiSetVisible ( guig [ 13 ], true )
guiSetText ( guig [ 16 ], "" )
end
end
end
--<< cena
function onSprzedazClickSprzedaj ()
local cena = guiGetText ( guig [ 16 ])
if #cena >= 1 then
local cena = tonumber ( cena )
if type ( cena ) == "number" then
showCursor ( false )
guiSetVisible ( guig [ 13 ], false )
--
triggerServerEvent ( "zaproponujKupnoPojazdu" , localPlayer , savePLAYER , saveVEHICLE , cena )
else
outputChatBox ( "Wpisz cen? za jak? chcesz sprzeda? sw?j pojazd." , 255 , 255 , 255 , true )
end
end
end
-- ######## OFERTA KUPNA #########
function createGUIKupnoUzywanego ()
if not guiku then
guiku = {}
guiku [ 1 ] = guiCreateWindow (( sX - 300 )/ 2 , ( sY - 150 )/ 2 , 300 , 150 , "Oferta kupna pojazdu" , false )
guiku [ 2 ] = guiCreateLabel ( 10 , 25 , 280 , 60 , "Gracz <nick> zaproponowa? Ci kupno pojazdu prywatnego <nazwa> o przebiegu <przebieg> km za <cena>$." , false , guiku [ 1 ])
guiLabelSetHorizontalAlign ( guiku [ 2 ], "center" , true )
guiku [ 3 ] = guiCreateButton ( 10 , 110 , 80 , 30 , "Odrzu?" , false , guiku [ 1 ])
guiku [ 4 ] = guiCreateButton ( 210 , 110 , 80 , 30 , "Kup" , false , guiku [ 1 ])
addEventHandler ( "onClientGUIClick" , guiku [ 3 ], onOfertaKupnaOdrzuc , false )
addEventHandler ( "onClientGUIClick" , guiku [ 4 ], onOfertaKupnaKup , false )
end
guiSetVisible ( guiku [ 1 ], true )
showCursor ( true )
end
addEvent ( "pokazOferteKupnaPojazdu" , true )
addEventHandler ( "pokazOferteKupnaPojazdu" , getRootElement (),
function( gracz , nazwa , cena , przebieg )
createGUIKupnoUzywanego ()
guiSetText ( guiku [ 2 ], "Gracz " .. getPlayerName ( gracz ).. " zaproponowa? Ci kupno pojazdu prywatnego " .. nazwa .. " o przebiegu " .. przebieg .. " km za " .. cena .. "$." )
end )
function onOfertaKupnaZamknij ()
guiSetVisible ( guiku [ 1 ], false )
showCursor ( false )
end
function onOfertaKupnaOdrzuc ()
onOfertaKupnaZamknij ()
triggerServerEvent ( "odrzucOferteKupna" , localPlayer )
end
function onOfertaKupnaKup ()
onOfertaKupnaZamknij ()
triggerServerEvent ( "przyjmijOferteKupna" , localPlayer )
end
strona servera:( zmie? sobie kordy markeru)
local sprzedaz = createMarker ( 117.50697 , 1109.32739 , 13.60938 , "cylinder" , 2 , 255 , 0 , 0 , 100 )
function onSprzedazHit ( hitElement , dim )
if getElementType ( hitElement ) == "player" then
local players = getElementsInMarker ( sprzedaz )
triggerClientEvent ( hitElement , "pokazGUISprzedazy" , root , players )
end
end
addEventHandler ( "onMarkerHit" , sprzedaz , onSprzedazHit )
function getElementsInMarker ( marker )
elements = {}
for i , v in pairs ( getElementsByType ( "player" )) do
if isElementWithinMarker ( v , marker ) then
table . insert ( elements , v )
end
end
return elements
end
addEvent ( "pobierzListePojazdow" , true )
addEventHandler ( "pobierzListePojazdow" , getRootElement (),
function()
local account = getPlayerAccount ( source )
if account then
local wlasciciel = getAccountName ( account )
local query = dbQuery ( handler , "SELECT * FROM pojazdy WHERE wlasciciel='" .. wlasciciel .. "'" )
local result , num_rows , errormsg = dbPoll ( query , - 1 )
triggerClientEvent ( source , "pokazListePojazdow" , root , result )
end
end )
ofertyKupna = {}
addEvent ( "zaproponujKupnoPojazdu" , true )
addEventHandler ( "zaproponujKupnoPojazdu" , getRootElement (),
function( gracz , id , cena )
if not ofertyKupna [ gracz ] then
ofertyKupna [ gracz ] = {}
ofertyKupna [ gracz ] = { gracz , source , id , cena }
local query = dbQuery ( handler , "SELECT model,przebieg FROM pojazdy WHERE id='" .. id .. "'" )
local result , num_rows , errormsg = dbPoll ( query , - 1 )
local pojazd = result [ 1 ]. model
local pojazd = getVehicleNameFromModel ( pojazd )
local przebieg = result [ 1 ]. przebieg
triggerClientEvent ( gracz , "pokazOferteKupnaPojazdu" , root , source , pojazd , cena , przebieg )
else
outputChatBox ( "Ten gracz w tym momencie ma otwart? inn? ofert? kupna pojazdu..." , source , 255 , 255 , 255 , true )
end
end )
addEvent ( "odrzucOferteKupna" , true )
addEventHandler ( "odrzucOferteKupna" , getRootElement (),
function()
if ofertyKupna [ source ] then
local od_kogo_oferta = ofertyKupna [ source ][ 2 ]
if isElement ( od_kogo_oferta ) then
outputChatBox ( "Gracz " .. getPlayerName ( source ).. " odrzuci? Twoj? ofert? kupna pojazdu." , od_kogo_oferta , 255 , 255 , 255 , true )
end
ofertyKupna [ source ] = nil
end
end )
addEvent ( "przyjmijOferteKupna" , true )
addEventHandler ( "przyjmijOferteKupna" , getRootElement (),
function()
if ofertyKupna [ source ] then
local account = getPlayerAccount ( source )
if account then
local login = getAccountName ( account )
if 5 >= getYourVehicleCount ( login ) then
local od_kogo_oferta = ofertyKupna [ source ][ 2 ]
local veh = ofertyKupna [ source ][ 3 ] -- id pojazdu
local cena = ofertyKupna [ source ][ 4 ]
if isElement ( od_kogo_oferta ) then
local cena = tonumber ( cena )
if getPlayerMoney ( source ) >= cena then
takePlayerMoney ( source , cena )
givePlayerMoney ( od_kogo_oferta , cena )
-- nadpisanie danych
local vehicle = getVehicleByID ( veh )
ustawDanePojazdu ( vehicle , veh , login )
dbExec ( handler , "UPDATE pojazdy SET wlasciciel='" .. login .. "' WHERE id=" .. veh .. "" )
-- chat
local pojazd = getVehicleName ( vehicle )
outputChatBox ( "Gracz " .. getPlayerName ( source ).. " przyja? Twoj? ofert? i kupi? Tw?j pojazd " .. pojazd .. " za " .. cena .. "$." , od_kogo_oferta , 255 , 255 , 255 , true )
outputChatBox ( "Kupi?e? pojazd " .. pojazd .. " za " .. cena .. "$ od gracza " .. getPlayerName ( od_kogo_oferta ).. "." , source , 255 , 255 , 255 , true )
else
outputChatBox ( "Gracz " .. getPlayerName ( source ).. " nie ma wystarczaj?co pieni?dzy by kupi? Tw?j pojazd." , od_kogo_oferta , 255 , 255 , 255 , true )
outputChatBox ( "Nie masz wystarczaj?co pieni?dzy by kupi? ten pojazd." , source , 255 , 255 , 255 , true )
end
else
outputChatBox ( "Gracz kt?ry sk?ada? Ci ofert? nie jest ju? online na serwerze." , source , 255 , 255 , 255 , true )
end
else
outputChatBox ( "Mo?esz posiada? maksymalnie 5 pojazd?w." , source , 255 , 255 , 255 , true )
end
else
outputChatBox ( "Nie jeste? zalogowany." , source , 255 , 255 , 255 , true )
end
else
outputChatBox ( "Wyst?pi? b??d, nie mo?esz teraz kupi? pojazdu :|" , source , 255 , 255 , 255 , true )
end
ofertyKupna [ source ] = nil
end )
Wysłany: 2015-07-10, 21:10
sebik2303
Mapper :)
Wiek: 25 Na forum: 4160 dni Posty: 298
Nick w MP: sebik2303
Piwa : 899
piotr172 , jak ju? jeste?my przy gie?dzie, to czemu mi ten skrypt nie dzia?a
m = createMarker ( 149.1142578125 , 1108.9118652344 , 14.695250511169 , "cylinder" , 5 , 255 , 100 , 0 )
function wystawa ( plr , cmd , ...)
if isElementWithinMarker ( plr , m ) then
local pojazd = getPedOccupiedVehicle ( plr )
if pojazd and getVehicleController ( pojazd )== plr then
vname = getVehicleName ( pojazd )
sprzedajacy = getPlayerName ( plr )
przebieg = getElementData ( pojazd , "przebieg" ) or 0
local tresc = tonumber (...)
setElementData ( pojazd , "opis_aut" , vname .. "4nW?a?ciciel: " .. sprzedajacy .. "4nPrzebieg: " .. przebieg .. " km4nCena: " .. tresc .. " Euro" )
end
end
end
addCommandHandler ( "wystaw" , wystawa )
jest 1 DB3
Wysłany: 2015-07-10, 21:27
Jurandovsky
Kurdebele
Wiek: 17 Na forum: 4838 dni Posty: 915
Piwa : 2697
Bo "tresc" ustalasz, a jej nigdzie nie nadajesz.
Zrob to na gui editbox a potem :
tresc = guiGetText(cena)
Podpis
Jedyny kontakt ze mną to PW forum
Kod:
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Wysłany: 2015-07-10, 21:38
sebik2303
Mapper :)
Wiek: 25 Na forum: 4160 dni Posty: 298
Nick w MP: sebik2303
Piwa : 899
Iksdekowski , chodzi Ci o takie co? ?
Wysłany: 2015-07-10, 21:40
Jurandovsky
Kurdebele
Wiek: 17 Na forum: 4838 dni Posty: 915
Piwa : 2697
Tak, chodzi mi o takie co? xd
Podpis
Jedyny kontakt ze mną to PW forum
Kod:
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Wysłany: 2015-07-10, 21:41
sebik2303
Mapper :)
Wiek: 25 Na forum: 4160 dni Posty: 298
Nick w MP: sebik2303
Piwa : 899
ok teraz b?d? musia? to po??czy?, w co jestem najgorszy przy gui xD
[ Dodano : 2015-07-10, 21:45 ]
to jest aktualne SS jak to wygl?da.
Dam jeszcze kod tego
GUIEditor = {
button = {},
window = {},
edit = {}
}
addEventHandler ( "onClientResourceStart" , resourceRoot ,
function()
GUIEditor . window [ 1 ] = guiCreateWindow ( 490 , 323 , 301 , 266 , "Cena Pojazdu" , false )
guiWindowSetSizable ( GUIEditor . window [ 1 ], false )
GUIEditor . button [ 1 ] = guiCreateButton ( 550 , 492 , 173 , 66 , "Zatwierd? cene" , false )
GUIEditor . edit [ 1 ] = guiCreateEdit ( 500 , 383 , 281 , 57 , "" , false )
end
)
Wysłany: 2015-07-11, 11:52
piotr172
Wiek: 26 Na forum: 4417 dni Posty: 130
Piwa : 2329
Tutaj masz m?j kod na gielde:
Ustaw sobie tylko dobr? elemntDate i kordy markeru
local x , y = guiGetScreenSize ()
window = guiCreateWindow ( 220 / 800 * x , 118 / 600 * y , 339 / 800 * x , 321 , "Gie?da pojazd?w." , false )
guiWindowSetSizable ( window , false )
label1 = guiCreateLabel ( 10 / 800 * x , 43 / 600 * y , 56 / 800 * x , 24 / 600 * y , "Cena:" , false , window )
edit1 = guiCreateEdit ( 84 / 800 * x , 42 / 600 * y , 239 / 800 * x , 31 / 600 * y , "" , false , window )
button = guiCreateButton ( 89 / 800 * x , 140 / 600 * y , 177 / 800 * x , 39 / 600 * y , "Zatwierdz" , false , window )
button2 = guiCreateButton ( 89 / 800 * x , 190 / 600 * y , 177 / 800 * x , 39 / 600 * y , "Wyjdz" , false , window )
label3 = guiCreateLabel ( 24 / 800 * x , 217 / 600 * y , 289 / 800 * x , 86 / 600 * y , "Po wpisaniu ceny i zatwierdzeniu\nodstaw auto na jakie? wolne miejsce." , false , window )
guiLabelSetHorizontalAlign ( label3 , "center" , false )
guiLabelSetVerticalAlign ( label3 , "center" )
guiSetVisible ( window , false )
e_marker = createMarker ( 1640.18945 + 2 , - 1139.36218 + 2 , 22.8 , "cylinder" , 7 , 255 , 0 , 0 , 130 )
addEventHandler ( "onClientMarkerHit" , e_marker , function( el )
local veh = getPedOccupiedVehicle ( el )
if ( veh and getVehicleController ( veh )== el ) then
if not el then return end
if not getPedOccupiedVehicle ( el ) then return end
if el ~= getLocalPlayer () then return end
guiSetVisible ( window , true )
showCursor ( true )
end
end )
addEventHandler ( "onClientMarkerLeave" , e_marker , function( el )
if not el then return end
if not getPedOccupiedVehicle ( el ) then return end
if el ~= getLocalPlayer () then return end
guiSetVisible ( window , false )
showCursor ( false )
end )
function setDescription ( btn )
local veh = getPedOccupiedVehicle ( localPlayer )
local model = getElementModel ( veh )
local nazwa = getVehicleNameFromModel ( model )
local id = getElementData ( veh , "car_id" )
local przebieg2 = getElementData ( veh , "pojazd_przebieg" )
local przebieg = string . format ( "%.02f" ,( przebieg2 ))
local nick = getPlayerName ( localPlayer )
if btn == "left" then
local cena = guiGetText ( edit1 )
if not tonumber ( cena ) then return end
if cena > "9999999" then return end
if cena < "0" then return end
if veh then
setElementData ( veh , "pojazd_opis" , "Typ pojazdu:" .. nazwa .. "\n Numer pojazdu(id):" .. id .. "\n Przebieg pojazdu:" .. przebieg .. " \n Sprzedaj?cy:" .. nick .. "\n Cena:" .. cena .. "" )
guiSetVisible ( window , false )
showCursor ( false )
end
end
end
addEventHandler ( "onClientGUIClick" , button , setDescription )
Wysłany: 2015-07-11, 12:12
sebik2303
Mapper :)
Wiek: 25 Na forum: 4160 dni Posty: 298
Nick w MP: sebik2303
Piwa : 899
wszystko by?o by fajnie piotr172 , lecz jest db z linijk? 1 local x , y = guiGetScreenSize ()
Pom??
Wysłany: 2015-07-11, 12:20
Jurandovsky
Kurdebele
Wiek: 17 Na forum: 4838 dni Posty: 915
Piwa : 2697
a moze blad z db3 tez podasz?
Podpis
Jedyny kontakt ze mną to PW forum
Kod:
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Wysłany: 2015-07-11, 12:25
sebik2303
Mapper :)
Wiek: 25 Na forum: 4160 dni Posty: 298
Nick w MP: sebik2303
Piwa : 899
ostatnia linijka to ten.
Wysłany: 2015-07-11, 12:26
piotr172
Wiek: 26 Na forum: 4417 dni Posty: 130
Piwa : 2329
To jest kod po stronie clienta nie servera, u mnie ?adnego b??du nie ma( po stronie clienta).
Wysłany: 2015-07-11, 12:33
sebik2303
Mapper :)
Wiek: 25 Na forum: 4160 dni Posty: 298
Nick w MP: sebik2303
Piwa : 899
piotr172 , Dzia?a lecz teraz mam drugi problem, nie mam napis?w na poje?dzie
Wysłany: 2015-07-11, 12:39
piotr172
Wiek: 26 Na forum: 4417 dni Posty: 130
Piwa : 2329
Ustawi?e? elementdate opisu? Bo to by? tylko przyk?ad. I czy masz skrypt na opisy na aucie? Tutaj ustaw elementdate
setElementData ( veh , "pojazd_opis" , "Typ pojazdu:" .. nazwa .. "\n Numer pojazdu(id):" .. id .. "\n Przebieg pojazdu:" .. przebieg .. " \n Sprzedaj?cy:" .. nick .. "\n Cena:" .. cena .. "" )
I tutaj zamiast 4n powinno by? \n bo forum zmienia na 4n
Wysłany: 2015-07-11, 12:45
sebik2303
Mapper :)
Wiek: 25 Na forum: 4160 dni Posty: 298
Nick w MP: sebik2303
Piwa : 899
Wysłany: 2015-07-11, 12:51
piotr172
Wiek: 26 Na forum: 4417 dni Posty: 130
Piwa : 2329
No chodzi o skrypt kt?ry tworzy ci napisy na aucie za pomoc? dxDrawText.
Tagi: sprzedaż :: pojazdów
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: