Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2018-11-26, 12:45


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

Witam chc? aby przechowalnia wyczytywa?a kolor 1 i kolor 2 auta z bazy danych i pokazywa?a to na aucie , nie umiem sobie z tym poradzi?.

local obj createObject19561385.87, -20.98999.92 );

obj:setInterior);
obj:setScale10 );
obj:setFrozentrue );

local rt dxCreateRenderTarget500500true );
local actual_car 0;
local font dxCreateFont':czcionka/bbold.ttf'18 ) or 'default';
local table_bool = {
    [0] = "nie",
    [1] = "tak",
    ['0'] = "nie",
    ['1'] = "tak",
}

local loaded false;

addEvent'parking:showCars'true );
addEvent'parking:setCollidable'true );

function loadCar(  )
    if veh then veh:destroy(  ) end
    local color=split(vehicles[actual_car]["color"], ",")
    local lights=split(vehicles[actual_car]["headlights"], ",");
    veh createVehiclevehicles[actual_car].model1385.87, -20.981000.82 );
    for i,v in ipairs(split(vehicles[actual_car]["tuning"], ",")) do veh:addUpgrade); end
    veh:setHeadLightColorlights[1], lights[2], lights[3] );
    veh:setInterior);
    veh:setFrozentrue );
    loaded true;
end

function changeCarbtn )
    if btn == "arrow_l" then
        if vehicles[actual_car 1then
            actual_car actual_car 1;
        else
            actual_car #vehicles;
        end
    elseif btn == "arrow_r" then
        if vehicles[actual_car 1then
            actual_car actual_car 1;
        else
            actual_car 1;
        end
    end
    loadCar(  );
end

function exitParking(  )
    unbindKey"space""down"respawnCar );
    unbindKey"arrow_l""down"changeCar);
    unbindKey"arrow_r""down"changeCar);
    unbindKey"enter""down"exitParking );
    removeEventHandler'onClientRender'root_onClientRender );
    triggerServerEvent"parking:exit"localPlayer );
    loaded false;
end


local rot 0;
function _onClientRender(  )
    if vehicles[actual_carthen
        rot rot 1;
        veh:setRotation00, -rot );
        obj:setRotation00, -rot );
        dxSetRenderTargetrt );
        dxDrawRectangle00500500tocolor000150 ) );
        dxDrawLine0500500500tocolor0130210255 ), );
        dxDrawText("Nazwa: ".. getVehicleNameFromModelvehicles[actual_car].model ), 03050050white1font'center''top');
        dxDrawText("ID: ".. vehicles[actual_car].id06050070white1font'center''top');
        dxDrawText("MK1: ".. table_bool[vehicles[actual_car].mk1], 09050070white1font'center''top');
        dxDrawText("MK2: ".. table_bool[vehicles[actual_car].mk2], 012050070white1font'center''top');
        dxDrawText("4x4: ".. table_bool[vehicles[actual_car].naped], 015050070white1font'center''top');
        dxDrawText("RH1: ".. table_bool[vehicles[actual_car].rh], 018050070white1font'center''top');
        dxDrawText("Aby zmienia? pojazdy klikaj strza?ki ( lewo - prawo )       \nPojazd "..actual_car.."/"..#vehicles..'\nAby wyci?gn?? auto kliknij "SPACJA"\nAby wyj?? z przechowywalni kliknij "ENTER"', 0, 0, 500, 500, white, 1, font, 'center', 'bottom', false, true);    
        dxSetRenderTarget(  );
        dxDrawMaterialLine3D1385.57, -14.571004.521385.57, -14.571000.52rt5);
    end
end

local categoryA={[463] = true,[462] = true,[461] = true,[581] = true,[448] = true,[468] = true,[471] = true,[521] = true,[522] = true,[523] = truelocal categoryB={[602] = true,[545] = true,[496] = true,[517] = true,[401] = true,[410] = true,[518] = true,[600] = true,[527] = true,[436] = true,[589] = true,[580] = true,[419] = true,[439] = true,[533] = true,[549] = true,[526] = true,[491] = true,[474] = true,[445] = true,[467] = true,[604] = true,[426] = true,[507] = true,[547] = true,[585] = true,[405] = true,[587] = true,[409] = true,[466] = true,[550] = true,[492] = true,[566] = true,[546] = true,[540] = true,[551] = true,[421] = true,[516] = true,[529] = true,[488] = true,[460] = true,
[469] = true,[487] = true,[510] = true,[509] = true,[481] = true,[586] = true,[472] = true,[473] = true,[493] = true,[595] = true,[484] = true,[430] = true,[453] = true,[452] = true,[446] = true,[454] = true,[485] = true,[552] = true,
[438] = true,[574] = true,[420] = true,[525] = true,[408] = true,[596] = true,[597] = true,[427] = true,[599] = true,[490] = true,[432] = true,[528] = true,[601] = true,[407] = true,[544] = true,[470] = true,[598] = true,[588] = true,
[532] = true,[443] = true,[486] = true,[531] = true,[543] = true,[422] = true,[583] = true,[478] = true,[605] = true,[554] = true,[530] = true,[418] = true,[572] = true,[582] = true,[536] = true,[575] = true,[534] = true,
[567] = true,[535] = true,[576] = true,[412] = true,[402] = true,[542] = true,[603] = true,[475] = true,[449] = true,[537] = true,[570] = true,[441] = true,[464] = true,[501] = true,[465] = true,[564] = true,[568] = true,[557] = true,[424] = true,[504] = true,[495] = true,[457] = true,[539] = true,[483] = true,[571] = true,[500] = true, 
[444] = true,[556] = true,[429] = true,[411] = true,[541] = true,[559] = true,[415] = true,[561] = true,[480] = true,[560] = true,[562] = true,[506] = true,[565] = true,[451] = true,[434] = true,[558] = true,[494] = true,[555] = true,[502] = true,[477] = true,[503] = true,[579] = true,[400] = true,[404] = true,[489] = true,[505] = true,[479] = true,[442] = true,[458] = true,
[606] = true,[607] = true,[610] = true,[590] = true,[569] = true,[611] = true,[584] = true,[608] = true,[435] = true,[450] = true,[591] = true,[594] = true}
local categoryC={[403] = true,[406] = true,[413] = true,[414] = true,[416] = true,[423] = true,[428] = true,[431] = true,[433] = true,[437] = true,[440] = true,[455] = true,[456] = true,[459] = true,[482] = true,[498] = true,[499] = true,[508] = true,[514] = true,[515] = true,[524] = true,[538] = true,[573] = true}



function respawnCar(  )
    local car vehicles[actual_car];
    if (localPlayer:getData"player:license:pjB" ) ~= and categoryB[car.model]) or (localPlayer:getData"player:license:pjA" ) ~= and categoryA[car.model]) or (localPlayer:getData"player:license:pjC" ) ~= and categoryCcar.model ]) then
        triggerServerEvent"parking:respawnCar"localPlayercar );
        loaded false;
        unbindKey"space""down"respawnCar );
        unbindKey"arrow_l""down"changeCar);
        unbindKey"arrow_r""down"changeCar);
        unbindKey"enter""down"exitParking );
        removeEventHandler'onClientRender'root_onClientRender );
    else
        triggerEvent"onClientAddNotification"localPlayer"Nie posiadasz prawa jazdy.""error" );
    end
end

addEventHandler'parking:showCars'root, function( cars )
    if loaded then return triggerServerEvent"parking:exit"localPlayer ); end
    vehicles cars;
    actual_car 1;
    if cars[actual_carthen
        loadCar(  );
        bindKey"arrow_l""down"changeCar);
        bindKey"arrow_r""down"changeCar);
        bindKey"space""down"respawnCar );
        bindKey"enter""down"exitParking );
        setCameraMatrix1398.88, -17.491003.391386.06, -18.091000.92 );
        addEventHandler'onClientRender'root_onClientRender );
    end
end);

addEventHandler"parking:setCollidable"root, function( vehbool )
    if bool == false then
        veh:setAlpha180 );
    elseif bool == true then
        veh:setAlpha255 );
    end
    for k,v in ipairs(getElementsByType"vehicle" )) do
        setElementCollidableWithvehvbool );
    end
end)


Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Ostatnio zmieniony przez Nexisten 2018-11-26, 19:43, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-26, 12:46


Avenged

Młodszy Szkrypter






Wiek: 23
Na forum: 3510 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1570

Respekt: 326,3
Respekt: 326,3Respekt: 326,3Respekt: 326,3


Więcej informacji znajdziesz w Wikipedii MTA:

split


Więcej informacji znajdziesz w Wikipedii MTA:

setVehicleColor


Podpis
LUA, JS, PHP



Zapraszam do skorzystania z moich usług: Klik

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-26, 13:28


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

ja zielony i tak nic z tego nie rozumiem mo?esz jako? inaczej wyt?umaczy? albo da? przyk?ad ?

Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-26, 14:04


Avenged

Młodszy Szkrypter






Wiek: 23
Na forum: 3510 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1570

Respekt: 326,3
Respekt: 326,3Respekt: 326,3Respekt: 326,3

Krzemo1234, to poczytaj przyk?ady podane i ucz si? na b??dach nie b?d? robi? czego? za Ciebie ;)

Podpis
LUA, JS, PHP



Zapraszam do skorzystania z moich usług: Klik

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-26, 19:38


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

Niby co? takiego ale i tak nie wczytuje kolor?w


function loadCar( ) 
if veh then veh:destroy( ) end 
local color=split(vehicles[actual_car]["color"], ","local lights=split(vehicles[actual_car]["headlights"], ","); 
veh createVehiclevehicles[actual_car].model1385.87, -20.981000.82 ); 
for i,v in ipairs(split(vehicles[actual_car]["tuning"], ",")) do veh:addUpgrade); end 
veh:setHeadLightColorlights[1], lights[2], lights[3] ); 
veh:setInterior); 
veh:setFrozentrue ); 
loaded trueend 


Komentarz Gregory. dodany 2018-11-26, 19:43Następnym razem do kodu LUA użyj znaczników [lua][/lua]
Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Ostatnio zmieniony przez Nexisten 2018-11-26, 19:42, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-27, 23:23


TeeNekk

Cienzaruwka :v






Wiek: 23
Na forum: 3210 dni
Posty: 264
Nick w MP: TeeNekk.

Piwa: 919

Respekt: 110,5
Respekt: 110,5

po prostu zapisuj je w
Więcej informacji znajdziesz w Wikipedii MTA:

toJSON

a potem odczytuj je tak
fromJSON(vehicles[actual_car]["color"])
r,g,unpack(a)
setVehicleColor(veh,r,g,b)


Podpis
Pomogłem Ci
? Może zostawiłbyś za to piwko, lub respekt? Dzięki!
Mój projekt:
?
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-28, 08:18


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

Czyli co mam zrobic ?

Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-28, 09:56


TeeNekk

Cienzaruwka :v






Wiek: 23
Na forum: 3210 dni
Posty: 264
Nick w MP: TeeNekk.

Piwa: 919

Respekt: 110,5
Respekt: 110,5

przecie? ju? ci napisa?em dok?adnie co masz zrobi? -,-

Podpis
Pomogłem Ci
? Może zostawiłbyś za to piwko, lub respekt? Dzięki!
Mój projekt:
?
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-28, 19:36


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

a jak zrobi? to ?eby odpisywa?a j? normalnie ?eby to by?o wida? to w przecho

Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-28, 23:18


mixLoLmix2

Programista






Wiek: 35
Na forum: 4113 dni
Posty: 454
Nick w MP: TomeQmix

Piwa: 1915

Respekt: 47,3


function loadCar( ) 
if veh then veh:destroy( ) end 
a fromJSON(vehicles[actual_car]["color"])
r,g,unpack(a)
local lights=split(vehicles[actual_car]["headlights"], ","); 
veh createVehiclevehicles[actual_car].model1385.87, -20.981000.82 ); 
for i,v in ipairs(split(vehicles[actual_car]["tuning"], ",")) do veh:addUpgrade); end 
veh:setHeadLightColorlights[1], lights[2], lights[3] ); 
setVehicleColor(veh,r,g,b)
veh:setInterior); 
veh:setFrozentrue ); 
loaded trueend 


Podpis
Zajmuję się pisaniem zaawansowanych skryptów lua na zamówienie za bardzo niską cene.
Oraz pomoc przy serwerze mta/forum i tym podobnych.
Discord: TomeQmix#7106
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-30, 23:15


Krzemo1234







Wiek: 26
Na forum: 3751 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

ERROR: tenskrypt\park.lua:32: bad argument #1 to 'unpack' (table expected, got nil)

Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Postaw piwo autorowi tego posta
 

 
Tagi: wczytywanie :: kolor :: kolor
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Wczytywanie kolor 1 i kolor 2 Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku