Wysłany: 2015-11-25, 20:46
lalko
Spamer
Wiek: 24 Na forum: 3891 dni Posty: 20
Nick w MP: xLalko
Piwa : 2
Siemanko, zrobi?em sw?j w?asny serwer wystartowa? tylko ?e jest ma?y problem ;c
Poniewa? pobra?em skrypt na prywatne pojazdy By PanPrezes i przy sprzedaniu auta jest taki bug ?e bierzesz klikasz na siebie sprzedajesz sobie auto za -99999 i daje ci to 999999k. Jak to naprawi? aby nie mo?na by?o sprzedawa? sobie aut i nie sprzedawa? aut za cen? na minusie.
KOD:
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 )
KOD PODAJEMY W ZNACZNIKU LUA!!!
Ostatnio zmieniony przez #404 2015-11-25, 20:53, w całości zmieniany 2 razy
Wysłany: 2015-11-25, 20:50
BlackTen
LUA Dev.
Wiek: 28 Na forum: 4330 dni Posty: 698
Piwa : 2080
Witaj, byl juz taki temat, jezeli nie chce ci sie szukac dam ci gotowy kod sprzedasz_C
podmien cale _sprzedasz_c na to:
local sprzedaz = createMarker ( x , y , z , "cylinder" , 2 , 255 , 0 , 0 , 100 )
-- setElementInterior ( sprzedaz , 3 )
-- setElementDimension ( sprzedaz , 1 )
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 }
if cena < 1 then
outputChatBox ( "*Wpisa?e? niepoprawn? cen? sprzeda?y!" , source , 255 , 0 , 0 )
else
local query = dbQuery ( handler , "SELECT model 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 )
end
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 25 >= 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 25 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 :c" , source , 255 , 255 , 255 , true )
end
ofertyKupna [ source ] = nil
end )
Wysłany: 2015-11-25, 20:53
lalko
Spamer
Wiek: 24 Na forum: 3891 dni Posty: 20
Nick w MP: xLalko
Piwa : 2
Dzi?ki, szuka?em tego na forum ale nie mog?em znale?? ;c
Wysłany: 2015-11-25, 21:08
Barcioo
Kiedyś to było ST
Wiek: 26 Na forum: 4049 dni Posty: 458
Nick w MP: Bartek.
Piwa : 1887
BlackTen , chyba Sprzedasz_s
Podpis
Kanał Youtube;
A tu zapraszam
[you]
, pomogłem Ci? Wynagrodź mnie
SUPPORT TEAM - 2016-09-03 do 2018-05-25
Test Mod - 2018-05-25
1k dni na Forum - 2018-01-28
GG: 62111935
Wysłany: 2015-11-25, 21:21
BlackTen
LUA Dev.
Wiek: 28 Na forum: 4330 dni Posty: 698
Piwa : 2080
No sory, pomylilo mi sie poprawka
Wysłany: 2015-11-25, 21:21
EMILOS123
Wiek: 28 Na forum: 5449 dni Posty: 219
Nick w MP: Emilos
Piwa : 128
lalko , Problem zosta? rozwi?zany?
Podpis
Support-Team 19.02.2015
Moderator 28.06.2015
Mod-Team 11.11.2015 do 30.01.2016
Wysłany: 2015-11-28, 11:00
lalko
Spamer
Wiek: 24 Na forum: 3891 dni Posty: 20
Nick w MP: xLalko
Piwa : 2
Problem nie jest rozwi?zany poniewa? teraz si? co? zepsu?o ?e w og?le nie mo?na kupi? auta nic nie wyskakuje ;c
Wysłany: 2015-11-28, 11:29
jg2aviva1
Rusek :D
Wiek: 25 Na forum: 4134 dni Posty: 445
Nick w MP: _Wolfenstei[N]^.^
Piwa : 1033
Tagi: bug :: sprzedażą :: aut
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: