Wysłany: 2015-11-20, 21:40
ironmaiden666
Voight...
Wiek: 30 Na forum: 4020 dni Posty: 125
Nick w MP: Irons
Piwa : 2941
Witam, mam problem ze skryptem prezesa (system pojazd?w)
Problem polega na tym, ?e gdy kupuje auto to pojawia si? Gracz <nick> .... (te <nick> jest napisane) Pr?bowa?em zrobi? aby pokazywa?o Przebieg id i gracza ale si? nie uda?o. Pomo?e kto?? Daje piwko + respekt
Kod: --######## OFERTA KUPNA #########
function createGUIKupnoUzywanego()
if not guiku then
guiku = {}
guiku[1] = guiCreateWindow((sX - 300)/2, (sY - 150)/2, 300, 150, "Oferta kupna pojazdu", false)
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()
guiku[2] = guiCreateLabel(10, 25, 280, 60, "Gracz "..getPlayerName(gracz).." zaproponowa? Ci kupno pojazdu prywatnego "..nazwa.." o przebiegu "..przebieg.." km za "..cena.."$.", false, guiku[1])
guiSetText(guiku[2], "Gracz "..getPlayerName(gracz).." zaproponowa? Ci kupno pojazdu prywatnego "..nazwa.." o przebiegu "..przebieg.." km za "..cena.."$.")
outputChatBox("Gracz "..getPlayerName(gracz).." zaproponowa? Ci kupno pojazdu prywatnego "..nazwa.." o przebiegu "..przebieg.." km za "..cena.."$.", 255, 255, 255, true)
end)
function onOfertaKupnaZamknij()
guiSetVisible(guiku[1], false)
showCursor(false)
end
function onOfertaKupnaOdrzuc()
onOfertaKupnaZamknij()
triggerServerEvent("odrzucOferteKupna", localPlayer)
end
function onOfertaKupnaKup()
onOfertaKupnaZamknij()
triggerServerEvent("przyjmijOferteKupna", localPlayer)
end
Podpis
Intelligence gonna get you..
Wysłany: 2015-11-20, 21:47
jg2aviva1
Rusek :D
Wiek: 25 Na forum: 4134 dni Posty: 445
Nick w MP: _Wolfenstei[N]^.^
Piwa : 1033
W?a?ciwie to mo?esz da? i za to, ?e ci teraz powiem tak? magi?. W postach tego tematu z pojazdami by?o podane jak to naprawi?, a nawet gotowy kod czyli ten:
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 )
Tyle . Dodam, ?e jest to plik sprzedaz_s.lua
Podpis
GTAO Member: 2015-08-23, 14:26
Wysłany: 2015-11-20, 21:56
ironmaiden666
Voight...
Wiek: 30 Na forum: 4020 dni Posty: 125
Nick w MP: Irons
Piwa : 2941
Dzi?ki! Do zamkni?cia
Podpis
Intelligence gonna get you..
Tagi: pojazdy :: prezesa
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: