Querex
Wiek: 32 Na forum: 4149 dni Posty: 79
Nick w MP: Querex
Piwa : 41
Witam posiadam problem, ot?? po wej?ciu w marker i nacisni?ciu przycisku zamontuj kompletnie nic sie nie dzieje. Czego jest to wina? Za pomoc zimne
S side:
local strefyMontazu ={
ls1_1 ={
colsphere ={ 2039.7182617188 , 1543.8753662109 , 10 , 5 , 5 , 5 },
mpos ={ 2034.0075683594 , 1542.7623291016 , 10 },
},
-- pc ={
-- colsphere ={ 2576.15 , 5.61 , 28.20 , 5 },
-- mpos ={ 2575.69 ,- 4.11 , 27.59 },
-- },
}
createBlipAttachedTo ( mpos , 52 )
for i , v in pairs ( strefyMontazu ) do
if v . cuboid then
v . cs = createColCuboid ( unpack ( v . cuboid ))
elseif v . colsphere then
v . cs = createColSphere ( unpack ( v . colsphere ))
end
v . marker = createMarker ( v . mpos [ 1 ], v . mpos [ 2 ], v . mpos [ 3 ], "cylinder" , 1 , 0 , 0 , 0 , 100 )
setElementData ( v . marker , "cs" , v . cs )
setElementData ( v . marker , "praca" , v . praca )
end
local function czyElementWStrefieMontazu ( e )
for i , v in pairs ( strefyMontazu ) do
if isElementWithinColShape ( e , v . cs ) then return true end
end
return false
end
local function pracownik ( id )
local query = string . format ( "SELECT rank FROM lss_character_factions WHERE faction_id=3 AND character_id=%d" , id )
local wynik = exports . DB : pobierzWyniki ( query )
if ( wynik and wynik . rank ) then return true else return false end
end
-- triggerServerEvent ( "montazSwiatel" , resourceRoot , naprawiany_pojazd , kolor , koszt )
addEvent ( "montazSwiatel" , true )
addEventHandler ( "montazSwiatel" , resourceRoot , function ( pojazd , kolor , koszt )
if not pojazd or not kolor or not koszt then return end
if koszt > getPlayerMoney ( client ) or koszt < 1 or koszt ~= koszt then
-- outputChatBox ( "Nie sta? Ci? na monta? tych ?wiate?." , client )
str = "Nie sta? Ci? na monta? tych ?wiate?"
triggerClientEvent ( client , "CreateBox" , getRootElement (), str )
return
end
-- outputDebugString ( "ev" )
if not isElement ( pojazd ) then return end
local vdbid = getPlayerName ( client )
local dbid = getElementData ( client , "dbid" )
local pdbid = getElementData ( pojazd , "dbid" )
local c = getElementData ( client , "character" )
if ( not c or not c . id ) then return end
if ( not pracownik ( tonumber ( c . id ))) then
-- outputChatBox ( "(( nie masz klucza do tej bramy ))" , gracz )
str = "Nie pracujesz w warsztacie"
triggerClientEvent ( client , "CreateBox" , getRootElement (), str )
return
end
-- if not pdbid or not vdbid or not dbid or vdbid ~= dbid then return end
-- local przebieg = getElementData ( pojazd , "przebieg" ) or 0
takePlayerMoney ( client , koszt )
setVehicleHeadLightColor ( pojazd , kolor [ 1 ], kolor [ 2 ], kolor [ 3 ])
setTimer ( setVehicleHeadLightColor , 500 , 1 , pojazd , kolor [ 1 ], kolor [ 2 ], kolor [ 3 ])
-- setElementData ( pojazd , "hl_przebieg" , przebieg , false )
outputDebugString ( "Kolory: " .. tostring ( kolor [ 1 ]))
outputDebugString ( "pdbid: " .. tostring ( pdbid ))
local query = string . format ( "UPDATE lss_vehicles SET headlightcolor='%d,%d,%d' WHERE id=%d LIMIT 1" , kolor [ 1 ] or 255 , kolor [ 2 ] or 255 , kolor [ 3 ] or 255 , pdbid )
exports . DB2 : zapytanie ( query )
outputDebugString ( "Montaz swiatel " .. kolor [ 1 ])
triggerClientEvent ( client , "montazComplete" , resourceRoot )
exports [ "lss-admin" ]: gameView_add ( string . format ( "TUNING montaz ZAROWEK kolor %d,%d,%d pojazd %d gracz %s " , kolor [ 1 ] or 255 , kolor [ 2 ] or 255 , kolor [ 3 ] or 255 , pdbid , vdbid ))
end )
--[[
-- przepalanie zarowek !
addEvent ( "setVehicleOverrideLights" , true )
addEventHandler ( "setVehicleOverrideLights" , root , function( state )
if state ~= 2 then return end
local dbid = getElementData ( source , "dbid" )
if not dbid then return end
-- local przebieg = getElementData ( source , "przebieg" )
-- if not przebieg then return end
-- local hl_przebieg = getElementData ( source , "hl_przebieg" )
-- if not hl_przebieg then return end
local kierowca = getVehicleController ( source )
if not kierowca then return end
-- tylko wlascicielowi moze przepalic sie zarowka - masc na bol dupy
local player_dbid = getElementData ( kierowca , "dbid" )
-- local vehicle_owner = getElementData ( source , "owning_player" )
-- if not player_dbid or not vehicle_owner or vehicle_owner ~= player_dbid then return end
if not player_dbid then return end
-- outputDebugString ( "pojazd " .. dbid .. " przebieg " .. przebieg .. " hl_przebieg ." .. hl_przebieg )
-- hl_przebieg = hl_przebieg + 2500 -- przepalamy po 2.5kkm
-- if hl_przebieg > przebieg then
return
end
-- przepalamy
setVehicleLightState ( source , 1 , 1 )
setVehicleLightState ( source , 0 , 1 )
setVehicleHeadLightColor ( source , 255 , 255 , 255 )
exports [ "pl-logs" ]: gameView_add ( string . format ( "TUNING przepalenie ZAROWEK pojazd %d gracz %d" , dbid , player_dbid ))
-- setElementData ( source , "hl_przebieg" , przebieg , false )
exports . DB2 : szybkieZapytanie ( "UPDATE pl_vehicles SET headlightcolor=NULL WHERE id=? LIMIT 1" , dbid )
outputChatBox ( "* W poje?dzie przepalaj? si? ?ar?wki." , kierowca )
end )
-- triggerServerEvent ( "montazElementu" , resourceRoot , naprawiany_pojazd , czesc , koszt )
addEvent ( "montazElementu" , true )
addEventHandler ( "montazElementu" , resourceRoot , function( pojazd , czesc , koszt )
-- outputDebugString ( "Naprawa elementu " .. czesc .. " za " .. koszt )
local kierowca = getVehicleController ( pojazd )
if not kierowca then
outputChatBox ( "W poje?dzie nie ma w?a?ciciela." , client )
return
end
local kdbid = getElementData ( kierowca , "dbid" ) or 0
local vdbid = getElementData ( pojazd , "owning_player" )
if not vdbid or kdbid ~= vdbid then
outputChatBox ( "W poje?dzie na miejscu kierowcy musi siedzie? w?a?ciciel pojazdu." , client )
return
end
if not czyElementWStrefieMontazu ( pojazd ) then
outputChatBox ( "Pojazd nie znajduje si? w strefie monta?u." , client )
return
end
if koszt > getPlayerMoney ( client ) then
return
end
if czesc < 0 then
-- czesci specjalne : tuning mechaniczny , taksometr
if czesc ==- 1 then
if koszt < 0 then
if not getElementData ( pojazd , "k_tm1" ) then
outputChatBox ( "* Ten pojazd nie posiada tego komponentu." , client )
return
end
removeElementData ( pojazd , "k_tm1" )
givePlayerMoney ( kierowca , - koszt )
exports [ "pl-logs" ]: gameView_add ( string . format ( "TUNING demontaz k_tm1 pojazd %d gracz %d" , getElementData ( pojazd , "dbid" ) or 0 , getElementData ( client , "dbid" ) or 0 ))
outputChatBox ( "Z pojazdu zdemontowano uk?ad tuninguj?cy." , kierowca )
else
if getElementData ( pojazd , "k_tm1" ) then
outputChatBox ( "* Ten pojazd ju? posiada ten komponent." , client )
return
end
setElementData ( pojazd , "k_tm1" , true )
takePlayerMoney ( client , koszt )
exports [ "pl-logs" ]: gameView_add ( string . format ( "TUNING montaz k_tm1 pojazd %d gracz %d" , getElementData ( pojazd , "dbid" ) or 0 , getElementData ( client , "dbid" ) or 0 ))
outputChatBox ( "* W poje?dzie zamontowano uk?ad tuninguj?cy." , kierowca )
end
elseif czesc ==- 2 then
local lvl = getElementData ( client , "level" ) or 0
if true or lvl < 3 then
outputChatBox ( "* Uk?ad nie jest jeszcze dost?pny na rynku." , client )
triggerClientEvent ( client , "refreshVehicleData" , resourceRoot , pojazd )
return
end
elseif czesc ==- 10 then
local lvl = getElementData ( client , "level" ) or 0
if lvl < 3 then
outputChatBox ( "* Montaz taksometru w trakcie przygotowywania." , client )
triggerClientEvent ( client , "refreshVehicleData" , resourceRoot , pojazd )
return
end
if koszt < 0 then
if not getElementData ( pojazd , "k_tax" ) then
outputChatBox ( "* Ten pojazd nie posiada tego komponentu." , client )
return
end
removeElementData ( pojazd , "k_tax" )
givePlayerMoney ( kierowca , - koszt )
exports [ "pl-logs" ]: gameView_add ( string . format ( "TUNING demontaz k_tax pojazd %d gracz %d" , getElementData ( pojazd , "dbid" ) or 0 , getElementData ( client , "dbid" ) or 0 ))
outputChatBox ( "* Z pojazdu zdemontowano taksometr." , kierowca )
else
if getElementData ( pojazd , "k_tax" ) then
outputChatBox ( "* Ten pojazd ju? posiada ten komponent." , client )
return
end
setElementData ( pojazd , "k_tax" , true )
takePlayerMoney ( client , koszt )
exports [ "pl-logs" ]: gameView_add ( string . format ( "TUNING montaz k_tax pojazd %d gracz %d" , getElementData ( pojazd , "dbid" ) or 0 , getElementData ( client , "dbid" ) or 0 ))
outputChatBox ( "* W poje?dzie zamontowano taksometr." , kierowca )
end
elseif czesc ==- 11 then
if getElementModel ( pojazd )~= 586 then
outputChatBox ( "* Nie mo?na zamontowa? tej cz??ci w tym poje?dzie." , client )
triggerClientEvent ( client , "refreshVehicleData" , resourceRoot , pojazd )
return
end
if koszt < 0 then
if not getElementData ( pojazd , "k_nj" ) then
outputChatBox ( "* Ten pojazd nie posiada tego komponentu." , client )
return
end
removeElementData ( pojazd , "k_nj" )
givePlayerMoney ( kierowca , - koszt )
exports [ "pl-logs" ]: gameView_add ( string . format ( "TUNING demontaz k_nj pojazd %d gracz %d" , getElementData ( pojazd , "dbid" ) or 0 , getElementData ( client , "dbid" ) or 0 ))
outputChatBox ( "* z pojazdu zdemontowano modyfikacj? do nauki jazdy." , kierowca )
else
if getElementData ( pojazd , "k_nj" ) then
outputChatBox ( "* Ten pojazd ju? posiada ten komponent." , client )
return
end
setElementData ( pojazd , "k_nj" , true )
takePlayerMoney ( client , koszt )
exports [ "pl-logs" ]: gameView_add ( string . format ( "TUNING montaz k_nj pojazd %d gracz %d" , getElementData ( pojazd , "dbid" ) or 0 , getElementData ( client , "dbid" ) or 0 ))
outputChatBox ( "* W poje?dzie zamontowano modyfikacj? do nauki jazdy." , kierowca )
end
end
exports [ "pl-vehicle" ]: veh_save ( pojazd )
triggerClientEvent ( client , "refreshVehicleData" , resourceRoot , pojazd )
return
end
-- outputChatBox ( "Koszt " .. koszt )
if koszt < 0 then
-- demontaz tuningu
if not removeVehicleUpgrade ( pojazd , czesc ) then return end
givePlayerMoney ( kierowca , - koszt )
outputChatBox ( "* Z pojazdu zdemontowano cz??? " .. czesc , client )
outputChatBox ( "* Z pojazdu zdemontowano cz??? " .. czesc , kierowca )
triggerClientEvent ( client , "refreshVehicleData" , resourceRoot , pojazd )
exports [ "pl-vehicles" ]: veh_save ( pojazd )
exports [ "pl-logs" ]: gameView_add ( string . format ( "TUNING demontaz element %d pojazd %d gracz %d" , czesc , getElementData ( pojazd , "dbid" ) or 0 , getElementData ( client , "dbid" ) or 0 ))
return
end
if not addVehicleUpgrade ( pojazd , czesc ) then
outputChatBox ( "* Ta cz??? nie pasuje do tego pojazdu." , client )
outputChatBox ( "* Mechanik przymierzy? cz??? " .. czesc .. " ale nie pasuje ona do tego pojazdu." , kierowca )
exports [ "pl-logs" ]: gameView_add ( "incompatible upgrade, vmodel: " .. getElementModel ( pojazd ) .. ", upgrade id: " .. czesc )
return
end
takePlayerMoney ( client , koszt )
outputChatBox ( "* W poje?dzie zamontowano cz??? " .. czesc , client )
outputChatBox ( "* w poje?dzie zamontowano cz??? " .. czesc , kierowca )
triggerClientEvent ( client , "refreshVehicleData" , resourceRoot , pojazd )
exports [ "pl-logs" ]: gameView_add ( string . format ( "TUNING montaz element %d pojazd %d gracz %d" , czesc , getElementData ( pojazd , "dbid" ) or 0 , getElementData ( client , "dbid" ) or 0 ))
exports [ "pl-vehicles" ]: veh_save ( pojazd )
end )
]]--
C side:
local w_m ={}
w_m . wnd = guiCreateWindow ( 0.49 , 0.1667 , 0.4344 , 0.675 , "" , true )
w_m . btn_napraw = guiCreateButton ( 0.0277 , 0.8395 , 0.3064 , 0.1327 , "Zamontuj" , true , w_m . wnd )
w_m . btn_zamknij = guiCreateButton ( 0.3427 , 0.8395 , 0.3064 , 0.1327 , "Zamknij" , true , w_m . wnd )
w_m . lbl_info = guiCreateLabel ( 0.6 , 0.8395 , 0.35 , 0.1327 , "" , true , w_m . wnd )
guiLabelSetHorizontalAlign ( w_m . lbl_info , "center" , true )
guiLabelSetVerticalAlign ( w_m . lbl_info , "center" )
w_m . grid = guiCreateGridList ( 0.0298 , 0.0895 , 0.9383 , 0.7191 , true , w_m . wnd )
guiGridListSetSelectionMode ( w_m . grid , 1 )
guiGridListSetSortingEnabled ( w_m . grid , false )
w_m . grid_nazwa = guiGridListAddColumn ( w_m . grid , "Rodzaj" , 0.6 )
w_m . grid_koszt = guiGridListAddColumn ( w_m . grid , "Koszt" , 0.30 )
guiSetVisible ( w_m . wnd , false )
local naprawiany_pojazd = nil
local npr , npg , npb = 255 , 255 , 255
local function isVehicleUpgradeSlotAllowed ( i )
if i == 8 then return false end
return true
end
local kolorki ={
{ "Stanardowe" , { 255 , 255 , 255 }, 500 },
{ "Xenon ULTRA" , { 104 , 133 , 205 }, 3500 },
{ "Xenon Plasma" , { 196 , 197 , 255 }, 3600 },
{ "SMD LED" , { 251 , 243 , 160 }, 4500 },
{ "LED Yellow" , { 255 , 255 , 16 }, 8800 },
{ "Philips Blue Vision Xenon" , { 93 , 223 , 255 }, 5000 },
{ "Street Panther" , { 252 , 67 , 0 }, 8800 },
{ "Philips Ocean Blue" , { 92 , 70 , 221 }, 5000 },
{ "Philips Ocean Green" , { 92 , 221 , 70 }, 5000 },
{ "Orange Panoramix" , { 255 , 120 , 0 }, 6300 },
{ "Asterix LED Pulsar" , { 255 , 0 , 255 }, 8200 },
{ "Obelix Creme" , { 255 , 222 , 173 }, 4200 },
{ "Drastic Lime" , { 0 , 255 , 0 }, 8800 },
{ "Drastic Blue" , { 0 , 0 , 255 }, 8800 },
{ "Drastic Red" , { 255 , 0 , 0 }, 8800 },
{ "George Pink" , { 255 , 0 , 122 }, 7800 },
}
local function fillVehicleData ( v )
guiGridListClear ( w_m . grid )
guiSetText ( w_m . btn_napraw , "Zamontuj" )
for i , v in ipairs ( kolorki ) do
local row = guiGridListAddRow ( w_m . grid )
guiGridListSetItemText ( w_m . grid , row , 1 , " " .. v [ 1 ], false , false )
guiGridListSetItemColor ( w_m . grid , row , 1 , v [ 2 ][ 1 ], v [ 2 ][ 2 ], v [ 2 ][ 3 ])
guiGridListSetItemData ( w_m . grid , row , 1 , v [ 2 ])
guiGridListSetItemText ( w_m . grid , row , 2 , v [ 3 ], false , false )
guiGridListSetItemData ( w_m . grid , row , 2 , v [ 3 ])
end
if true then return end
end
addEventHandler ( "onClientMarkerHit" , resourceRoot , function( el , md )
if not md or el ~= localPlayer then return end
--[[
local lvl = getElementData ( el , "level" ) or 0
if lvl < 1 then
outputChatBox ( "* Kod od montazu swiatel w trakcie przygotowywania." )
return
end
]]--
local cs = getElementData ( source , "cs" )
local praca = getElementData ( source , "praca" )
local lpraca = getElementData ( localPlayer , "praca:kod" )
if praca and lpraca ~= praca then return end -- gracz nie jest pracownikiem
local pojazdy = getElementsWithinColShape ( cs , "vehicle" )
if #pojazdy<1 then
outputChatBox ( "Na stanowisku montazu nie ma zadnego pojazdu." )
return
end
if #pojazdy>1 then
outputChatBox ( "Na stanowisku montazu jest zbyt duzo pojazd?w." )
return
end
if getElementHealth ( pojazdy [ 1 ])< 950 or getVehicleLightState ( pojazdy [ 1 ], 0 )~= 0 or getVehicleLightState ( pojazdy [ 1 ], 1 )~= 0 then
outputChatBox ( "Pojazd na stanowisku jest za bardzo uszkodzony." )
return
end
setVehicleOverrideLights ( pojazdy [ 1 ], 2 )
fillVehicleData ( pojazdy [ 1 ])
guiSetEnabled ( w_m . btn_napraw , false )
guiSetText ( w_m . lbl_info , "" )
guiSetVisible ( w_m . wnd , true )
showCursor ( true )
naprawiany_pojazd = pojazdy [ 1 ]
npr , npg , npb = getVehicleHeadLightColor ( pojazdy [ 1 ])
end )
addEventHandler ( "onClientMarkerLeave" , resourceRoot , function( el , md )
if el ~= localPlayer then return end
guiSetVisible ( w_m . wnd , false )
showCursor ( false )
if naprawiany_pojazd and isElement ( naprawiany_pojazd ) then
setVehicleOverrideLights ( naprawiany_pojazd , 1 )
setVehicleOverrideLights ( naprawiany_pojazd , 1 )
setVehicleHeadLightColor ( naprawiany_pojazd , npr , npg , npb )
end
naprawiany_pojazd = nil
npr , npg , npb = 255 , 255 , 255
end )
addEventHandler ( "onClientGUIClick" , w_m . btn_zamknij , function()
guiSetVisible ( w_m . wnd , false )
showCursor ( false )
if naprawiany_pojazd and isElement ( naprawiany_pojazd ) then
setVehicleOverrideLights ( naprawiany_pojazd , 1 )
setVehicleOverrideLights ( naprawiany_pojazd , 1 )
setVehicleHeadLightColor ( naprawiany_pojazd , npr , npg , npb )
end
npr , npg , npb = 255 , 255 , 255
naprawiany_pojazd = nil
end , false )
addEventHandler ( "onClientGUIClick" , w_m . grid , function()
guiSetText ( w_m . lbl_info , "" )
selectedRow = guiGridListGetSelectedItem ( w_m . grid ) or - 1
if ( selectedRow < 0 ) then
guiSetEnabled ( w_m . btn_napraw , false )
return
end
local kolor = guiGridListGetItemData ( w_m . grid , selectedRow , 1 )
setVehicleHeadLightColor ( naprawiany_pojazd , kolor [ 1 ], kolor [ 2 ], kolor [ 3 ])
guiSetEnabled ( w_m . btn_napraw , true )
end )
local napraw_lu = getTickCount ()
addEventHandler ( "onClientGUIClick" , w_m . btn_napraw , function()
if getPedOccupiedVehicle ( localPlayer ) then
return
end
if getTickCount ()- napraw_lu < 1000 then return end
if not naprawiany_pojazd or not isElement ( naprawiany_pojazd ) then return end
selectedRow = guiGridListGetSelectedItem ( w_m . grid ) or - 1
if selectedRow < 0 then return end
local koszt = math . floor ( guiGridListGetItemData ( w_m . grid , selectedRow , 2 ))
if koszt > getPlayerMoney ( localPlayer ) then
guiSetText ( w_m . lbl_info , "Nie masz tyle got?wki!" )
return
end
local kolor = guiGridListGetItemData ( w_m . grid , selectedRow , 1 )
napraw_lu = getTickCount ()
triggerServerEvent ( "montazSwiatel" , resourceRoot , naprawiany_pojazd , kolor , koszt )
end , false )
-- triggerClientEvent ( client , "refreshVehicleData" , resourceRoot , pojazd )
addEvent ( "montazComplete" , true )
addEventHandler ( "montazComplete" , resourceRoot , function( pojazd )
guiSetVisible ( w_m . wnd , false )
showCursor ( false )
if naprawiany_pojazd and isElement ( naprawiany_pojazd ) then
setVehicleOverrideLights ( naprawiany_pojazd , 1 )
triggerServerEvent ( "setVehicleOverrideLights" , naprawiany_pojazd , 1 )
-- setVehicleHeadLightColor ( naprawiany_pojazd , npr , npg , npb )
end
naprawiany_pojazd = nil
npr , npg , npb = 255 , 255 , 255
end )