Boski1234567
Wiek: 25 Na forum: 3626 dni Posty: 6
Nick w MP: BOSKI
Witam.
Mam taki problem z systemem pana prezesa np: Gracz sobie buguje kas?:
Np sprzedam sobie auto jakies za -999999999 i daje mi kase na 9999999999999
jak to naprawic? prosze o szybk? odpowiedz
daje zimnie piwerko
1.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 )
end
2.Kod
local sprzedaz = createMarker (- 2721.01 , 436.21 , 24.45 - 0.9 , "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 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 )
Ostatnio zmieniony przez Emm 2016-07-05, 14:31, w całości zmieniany 3 razy