czaszka
Wiek: 23 Na forum: 2273 dni Posty: 35
Nick w MP: Gangus*
Piwa : 9
Witam tak jak w temacie a mianowicie mam problem z salonem gdy kupuj? pojazd pisze ?e zawie? pojazd do przechowywalni aby si? zapisa?, lecz gdy go kupi? nie ma go ani w panelu gracza pod F2 ani w przechowywalni r?wnie? nie respi si? nigdzie przy salonie
--[[
StoriesRPG
]]
ustawienia ={}
local sw , sh = guiGetScreenSize ()
local w , h =( sw / 1680 ), ( sh / 1050 )
local font = dxCreateFont ( "f.ttf" , 10 )
local salon = false
function isMouseIn ( x , y , width , height )
if ( not isCursorShowing ( ) ) then
return false
end
local sx , sy = guiGetScreenSize ( )
local cx , cy = getCursorPosition ( )
local cx , cy = ( cx * sx ), ( cy * sy )
if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
return true
else
return false
end
end
function guiKUPNO ()
dxDrawImage ( 631 * w , 367 * h , 400 * w , 250 * h , "img/bg.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
model = getVehicleName ( actual_vehicle )
przebieg = getElementData ( actual_vehicle , "vehicle:mileage" )
pojemnosc = getElementData ( actual_vehicle , "vehicle:pojemnosc" )
naped = getElementData ( actual_vehicle , "vehicle:naped" )
cena = getElementData ( actual_vehicle , "salon:cena" )
dxDrawText ( "Model: " .. getVehicleName ( actual_vehicle ).. "\nPrzebieg: " .. przebieg .. " km\nPojemno?›?‡: " .. pojemnosc .. " dm3\nNap?™d: " .. naped .. "\n\nCena: " .. cena .. " PLN\n\nAby zakupi?‡ ten pojazd kliknij 'zakup'." , 636 * w + 1 , 394 * h + 1 , 1025 * w + 1 , 1007 * h + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.00 * w , font , "center" , "top" , false , false , false , false , false )
dxDrawText ( "Model: " .. getVehicleName ( actual_vehicle ).. "\nPrzebieg: " .. przebieg .. " km\nPojemno?›?‡: " .. pojemnosc .. " dm3\nNap?™d: " .. naped .. "\n\nCena: " .. cena .. " PLN\n\nAby zakupi?‡ ten pojazd kliknij 'zakup'." , 636 * w , 394 * h , 1025 * w , 1007 * h , tocolor ( 255 , 255 , 255 , 255 ), 1.00 * w , font , "center" , "top" , false , false , false , false , false )
if isMouseIn ( 760 * w , 562 * h , 134 * w , 44 * h ) then
dxDrawImage ( 760 * w , 562 * h , 134 * w , 44 * h , "img/btnh.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 200 ), false )
else
dxDrawImage ( 760 * w , 562 * h , 134 * w , 44 * h , "img/btn.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
end
dxDrawText ( "Zakup" , 759 * w , 182 * h , 894 * w , 986 * h , tocolor ( 255 , 255 , 255 , 255 ), 1.00 * w , font , "center" , "center" , false , false , false , false , false )
dxDrawRectangle ( 1011 * w , 367 * h , 20 * w , 18 * h , tocolor ( 155 , 0 , 0 , 255 ), false )
dxDrawText ( "x" , 1010 * w , - 32 * h , 1031 * w , 785 * h , tocolor ( 255 , 255 , 255 , 255 ), 1.00 * w , "default" , "center" , "center" , false , false , false , false , false )
end
addEvent ( "showGUIKupno" , true )
addEventHandler ( "showGUIKupno" , getRootElement (), function( pojazd )
if salon == false then
actual_vehicle = pojazd
salon = true
addEventHandler ( "onClientRender" , getRootElement (), guiKUPNO )
showCursor ( true , false )
end
end )
addEvent ( "hideGUIKupno" , true )
addEventHandler ( "hideGUIKupno" , getRootElement (), function()
if salon == true then
salon = false
removeEventHandler ( "onClientRender" , getRootElement (), guiKUPNO )
showCursor ( false )
setTimer (function()
triggerServerEvent ( "klikankoo:true" , localPlayer )
end , 500 , 1 )
end
end )
addEventHandler ( "onClientClick" , getRootElement (), function( btn , state )
if salon and btn == "left" and state == "down" then
if isMouseIn ( 760 * w , 562 * h , 134 * w , 44 * h ) then
triggerServerEvent ( "kupPojazd" , localPlayer )
elseif isMouseIn ( 1011 * w , 367 * h , 20 * w , 18 * h ) then
triggerEvent ( "hideGUIKupno" , localPlayer )
end
end
end )
a tutaj 2 kod
cygunblip = createBlip ( 1729.35 , - 1143.76 , 24.04 , 55 , 2 , 255 , 0 , 0 , 255 , 0 , 400 )
cygunblip = createBlip ( 542.88 , - 1293.35 , 17.24 , 55 , 2 , 255 , 0 , 0 , 255 , 0 , 400 )
cygunblip = createBlip ( 2352.53 , - 2174.34 , 13.55 , 55 , 2 , 255 , 0 , 0 , 255 , 0 , 400 )
local positionVehicles = {
-- nazwa , model , przebieg , cena , x , y , z , rx , ry , rz , sprzedaĹĽ
-- test
{ 'Cheetah' , 415 , 120 , 6400000 , 562.98 , - 1299.00 , 17.2 , 0.3 , 0.0 , 90.0 , "2.2" , "salon1" },
{ 'Bullet' , 541 , 60 , 6750000 , 535.92 , - 1300.90 , 17.1 , 359.5 , 0.0 , 0 , "2.2" , "salon1" },
{ 'Sultan' , 560 , 25 , 5850000 , 527.32 , - 1301.02 , 17.1 , 359.9 , 360.0 , 0 , "2.4" , "salon1" },
{ 'Elegy' , 562 , 100 , 4350000 , 537.05 , - 1296.10 , 20.8 , 359.5 , 360.0 , 90 , "2.8" , "salon1" },
{ 'Infernus' , 411 , 100 , 7350000 , 524.34 , - 1296.17 , 20.9 , 0.0 , 0.0 , 90 , "5.2" , "salon1" },
{ 'Tursimo' , 451 , 239 , 6800000 , 553.50 , - 1300.81 , 20.9 , 359.5 , 360.0 , 0 , "3.0" , "salon1" },
{ 'Comet' , 480 , 123 , 5900000 , 560.59 , - 1300.78 , 20.9 , 359.7 , 0.0 , 0 , "4.0" , "salon1" },
{ 'Flash' , 565 , 26 , 1850000 , 530.27 , - 1302.37 , 20.8 , 359.6 , 0.0 , 270.0 , "2.4" , "salon1" },
{ 'Admiral' , 445 , 30 , 600000 , 1721.45 , - 1124.11 , 24.1 , 360.0 , 0.0 , 180 , "1.8" , "salon1" },
{ 'Blista Compact' , 496 , 27 , 750000 , 1718.53 , - 1131.50 , 23.9 , 360.0 , 359.9 , 180 , "1.6" , "salon1" },
{ 'Sabre' , 475 , 16 , 1450000 , 1707.94 , - 1132.04 , 24.1 , 359.7 , 0.0 , 180 , "1.8" , "salon1" },
{ 'Premier' , 426 , 54 , 750000 , 1721.48 , - 1113.43 , 24.1 , 0.0 , 0.0 , 180 , "1.8" , "salon1" },
{ 'Savanna' , 567 , 23 , 1200000 , 1708.01 , - 1098.50 , 23.95 , 0.5 , 0.0 , 242.9 , "1.8" , "salon1" },
{ 'Voodoo' , 412 , 24 , 900000 , 1708.38 , - 1104.78 , 23.92 , 0.2 , 0.0 , 297.2 , "1.8" , "salon1" },
{ 'Huntley' , 579 , 56 , 1600000 , 1746.52 , - 1130.38 , 24.2 , 359.4 , 359.9 , 90 , "1.6" , "salon1" },
{ 'Landstalker' , 400 , 54 , 600000 , 1763.25 , - 1130.38 , 24.3 , 360.0 , 0.0 , 90 , "1.6" , "salon1" },
{ 'Stratum' , 561 , 47 , 1100000 , 1803.59 , - 1105.83 , 24.1 , 0.1 , 0.0 , 64.4 , "1.8" , "salon1" },
{ 'ZR-350' , 477 , 63 , 3000000 , 1763.39 , - 1106.79 , 24.1 , 359.7 , 0.0 , 90 , "1.8" , "salon1" },
{ 'Jester' , 559 , 78 , 3000000 , 1803.09 , - 1098.41 , 23.9 , 360.0 , 360.0 , 121.3 , "1.8" , "salon1" },
{ 'Sentinel' , 405 , 65 , 380000 , 1789.17 , - 1113.25 , 24.1 , 0.0 , 360.0 , 0 , "1.8" , "salon1" },
{ 'Greenwood' , 492 , 42 , 400000 , 1804.21 , - 1132.11 , 24 , 0.0 , 360.0 , 180 , "1.6" , "salon1" },
{ 'Cadrona' , 527 , 27 , 500000 , 1792.51 , - 1131.75 , 24 , 359.9 , 0.1 , 180 , "1.6" , "salon1" },
{ 'Buffalo' , 402 , 67 , 2700000 , 1789.12 , - 1124.03 , 24.1 , 360.0 , 0.0 , 0 , "1.8" , "salon1" },
{ 'Emperor' , 585 , 17 , 180000 , 1746.92 , - 1106.94 , 23.9 , 359.6 , 0.0 , 90 , "1.6" , "salon1" },
{ 'Perennial' , 404 , 90495 , 45000 , 2355.38 , - 2166.23 , 13.38 , 359.5 , 360.0 , 108.3 , "1.2" , "salon1" },
{ 'Bobcat' , 422 , 95105 , 85000 , 2337.59 , - 2175.05 , 13.67 , 359.2 , 360.0 , 270.0 , "1.2" , "salon1" },
{ 'Clover' , 542 , 97615 , 125000 , 2372.91 , - 2155.08 , 13.52 , 0.0 , 0.1 , 266.3 , "1.2" , "salon1" },
{ 'Manana' , 410 , 95402 , 65000 , 2379.90 , - 2161.85 , 13.42 , 359.5 , 360.0 , 44.3 , "1.2" , "salon1" },
{ 'Walton' , 478 , 92425 , 70000 , 2372.64 , - 2168.32 , 13.58 , 359.2 , 359.9 , 89.3 , "1.2" , "salon1" },
{ 'Sadler' , 543 , 98100 , 80000 , 2361.62 , - 2155.94 , 13.52 , 359.0 , 0.1 , 202.3 , "1.2" , "salon1" },
{ 'Previon' , 436 , 97568 , 50000 , 2341.23 , - 2183.79 , 13.42 , 359.4 , 0.0 , 317.5 , "1.2" , "salon1" },
{ 'Moonbeam' , 418 , 96751 , 30000 , 2348.92 , - 2165.48 , 13.72 , 359.7 , 0.1 , 132.5 , "1.2" , "salon1" },
{ 'Picador' , 600 , 98750 , 100000 , 2362.87 , - 2176.13 , 13.42 , 359.1 , 0.1 , 302.7 , "1.2" , "salon1" },
}
local klikankoo = true
for i , v in pairs ( positionVehicles ) do
veh = createVehicle ( v [ 2 ], v [ 5 ], v [ 6 ], v [ 7 ]- 0.25 , v [ 8 ], v [ 9 ], v [ 10 ])
local handling = getModelHandling ( tonumber ( v [ 2 ]))
local naped = handling [ "driveType" ]
if naped == "rwd" then naped = "RWD" elseif naped == "fwd" then naped = "FWD" elseif naped == "awd" then naped = "AWD" end
local cena ; if type ( v [ 4 ]) == "table" then cena =( math . random ( v [ 4 ][ 1 ], v [ 4 ][ 2 ])) else cena = v [ 4 ] end
local przebieg ; if type ( v [ 3 ]) == "table" then przebieg =( math . random ( v [ 3 ][ 1 ], v [ 3 ][ 2 ])) else przebieg = v [ 3 ] end
setVehicleOverrideLights ( veh , 1 )
setElementFrozen ( veh , true )
setElementData ( veh , "jaki:salon" , v [ 12 ])
setElementData ( veh , "vehicle:mileage" , przebieg )
setVehicleDamageProof ( veh , true )
setElementData ( veh , "vehicle:naped" , naped )
setElementData ( veh , "vehicle:pojemnosc" , v [ 11 ])
setElementData ( veh , 'vehicle.selling' , true )
setElementData ( veh , "vehicle:desc" , "Model: " .. v [ 1 ].. "\nPrzebieg: " .. przebieg .. "\nPojemno?›?‡: " .. v [ 11 ].. " dm3\nNap?™d: " .. naped .. "\nCena: " .. cena .. " PLN\nW?‚?…cz kursor 'F3', po czym kliknij na pojazd aby uzyska?‡ informacje." )
setElementData ( veh , "salon:cena" , v [ 4 ])
veh : setData ( 'salon' , {
[ 'cost' ]= cena ,
[ 'model' ]= v [ 2 ],
[ 'mileage' ]= przebieg ,
[ 'pojemnosc' ]= v [ 11 ],
[ 'naped' ]= naped ,
[ "jakisalon" ]= v [ 12 ],
[ 'selling' ]= v [ 13 ],
[ 'id' ]= i ,
}, false )
end
function showMenuSalon ( btn , state , player )
if btn == "left" and state == "down" then
if klikankoo == true then
if getElementType ( source ) == "vehicle" then
local x , y , z = getElementPosition ( player )
local x1 , y1 , z1 = getElementPosition ( source )
local distance = getDistanceBetweenPoints3D ( x , y , z , x1 , y1 , z1 )
if distance > 4 then return end
local pojazd = getPedOccupiedVehicle ( player )
if pojazd then return end
local data = source : getData ( 'salon' )
if not data then return end
player : setData ( 'salon' , {
[ 'cost' ]= data . cost ,
[ 'model' ]= data . model ,
[ 'mileage' ]= data . mileage ,
[ 'pojemnosc' ]= data . pojemnosc ,
[ 'naped' ]= data . naped ,
[ 'jakisalon' ]= data . jakisalon ,
}, false )
setElementData ( player , "salon:cena" , data . cost )
triggerClientEvent ( player , "showGUIKupno" , player , source )
klikankoo = false
-- vehicle = source
end
end
end
end
addEventHandler ( "onElementClicked" , getRootElement (), showMenuSalon )
addEventHandler ( "onVehicleStartEnter" , root , function( player , seat )
if getElementData ( source , "salon" ) then
cancelEvent ()
end
end )
addEvent ( "klikankoo:true" , true )
addEventHandler ( "klikankoo:true" , getRootElement () ,function()
klikankoo = true
removeElementData ( source , "salon" )
removeElementData ( source , "salon:cena" )
end )
addEvent ( "kupPojazd" , true )
addEventHandler ( "kupPojazd" , getRootElement (), function()
local data = source : getData ( 'salon' )
if not data then return end
if getPlayerMoney ( source ) < data . cost then
triggerClientEvent ( source , "createAlert" , source , "error" , "Nie posiadasz wystarczaj?…co gotĂłwki!" )
return
end
local cost = data . cost
local model = data . model
local mileage = data . mileage
local pojemnosc = data . pojemnosc
local naped = data . naped
local uid = getElementData ( source , 'player:uid' )
local jakisalon = data . jakisalon
local vr , vg , vb = getVehicleColor ( veh )
local color = vr .. ", " .. vg .. ", " .. vb
if jakisalon == "salon1" then
x , y , z , rx , ry , rz = 1005.82 , - 1352.82 , 13.33 , 0.0 , 0.0 , 178.9
end
local pos = x .. ", " .. y .. ", " .. z .. ", " .. rx .. ", " .. ry .. ", " .. rz
triggerClientEvent ( source , "createAlert" , source , "info" , "Prosimy o oddanie pojazdu do przechowywalni w celu zapisania si?™ go!!" )
takePlayerMoney ( source , cost )
local wyk , _ , id = exports [ "srpg-db" ]: dbSet ( "INSERT INTO srpg_vehicles SET model=?, ownedPlayer=?, pos=?, fuel=?, firstowner=?, parking=?, mileage=?, pojemnosc=?, naped=?, color=?" , model , uid , pos , 100 , uid , 0 , mileage , pojemnosc , naped , color )
local q = exports [ "srpg-db" ]: dbGet ( "SELECT * FROM srpg_vehicles WHERE id=?" , id )
local veh2 = exports [ "srpg-vehicles" ]: stworzPojazdy ( q [ 1 ], x , y , z , rx , ry , rz )
warpPedIntoVehicle ( source , veh2 )
triggerClientEvent ( source , "createAlert" , source , "success" , "Zakupi?‚e?›/a?› swĂłj pojazd " .. getVehicleNameFromModel ( model ))
triggerClientEvent ( source , "hideGUIKupno" , source )
klikankoo = true
removeElementData ( source , "salon" )
removeElementData ( source , "salon:cena" )
end )
Prosz? o pomoc za rozwi?zanie daje zimne browarki oraz Reputacj? ;D
Ostatnio zmieniony przez PatryKK. 2020-08-04, 16:11, w całości zmieniany 1 raz