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: 27
Na forum: 3892 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 = createObject( 1956, 1385.87, -20.98, 999.92 );

obj:setInterior( 1 );
obj:setScale( 10 );
obj:setFrozen( true );

local rt = dxCreateRenderTarget( 500, 500, true );
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 = createVehicle( vehicles[actual_car].model, 1385.87, -20.98, 1000.82 );
    for i,v in ipairs(split(vehicles[actual_car]["tuning"], ",")) do veh:addUpgrade( v ); end
    veh:setHeadLightColor( lights[1], lights[2], lights[3] );
    veh:setInterior( 1 );
    veh:setFrozen( true );
    loaded = true;
end

function changeCar( btn )
    if btn == "arrow_l" then
        if vehicles[actual_car - 1] then
            actual_car = actual_car - 1;
        else
            actual_car = #vehicles;
        end
    elseif btn == "arrow_r" then
        if vehicles[actual_car + 1] then
            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_car] then
        rot = rot + 1;
        veh:setRotation( 0, 0, -rot );
        obj:setRotation( 0, 0, -rot );
        dxSetRenderTarget( rt );
        dxDrawRectangle( 0, 0, 500, 500, tocolor( 0, 0, 0, 150 ) );
        dxDrawLine( 0, 500, 500, 500, tocolor( 0, 130, 210, 255 ), 5 );
        dxDrawText("Nazwa: ".. getVehicleNameFromModel( vehicles[actual_car].model ), 0, 30, 500, 50, white, 1, font, 'center', 'top');
        dxDrawText("ID: ".. vehicles[actual_car].id, 0, 60, 500, 70, white, 1, font, 'center', 'top');
        dxDrawText("MK1: ".. table_bool[vehicles[actual_car].mk1], 0, 90, 500, 70, white, 1, font, 'center', 'top');
        dxDrawText("MK2: ".. table_bool[vehicles[actual_car].mk2], 0, 120, 500, 70, white, 1, font, 'center', 'top');
        dxDrawText("4x4: ".. table_bool[vehicles[actual_car].naped], 0, 150, 500, 70, white, 1, font, 'center', 'top');
        dxDrawText("RH1: ".. table_bool[vehicles[actual_car].rh], 0, 180, 500, 70, white, 1, font, '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(  );
        dxDrawMaterialLine3D( 1385.57, -14.57, 1004.52, 1385.57, -14.57, 1000.52, rt, 5);
    end
end

local categoryA={[463] = true,[462] = true,[461] = true,[581] = true,[448] = true,[468] = true,[471] = true,[521] = true,[522] = true,[523] = true} 
local 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" ) ~= 0 and categoryB[car.model]) or (localPlayer:getData( "player:license:pjA" ) ~= 0 and categoryA[car.model]) or (localPlayer:getData( "player:license:pjC" ) ~= 0 and categoryC[ car.model ]) then
        triggerServerEvent( "parking:respawnCar", localPlayer, car );
        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_car] then
        loadCar(  );
        bindKey( "arrow_l", "down", changeCar);
        bindKey( "arrow_r", "down", changeCar);
        bindKey( "space", "down", respawnCar );
        bindKey( "enter", "down", exitParking );
        setCameraMatrix( 1398.88, -17.49, 1003.39, 1386.06, -18.09, 1000.92 );
        addEventHandler( 'onClientRender', root, _onClientRender );
    end
end);

addEventHandler( "parking:setCollidable", root, function( veh, bool )
    if bool == false then
        veh:setAlpha( 180 );
    elseif bool == true then
        veh:setAlpha( 255 );
    end
    for k,v in ipairs(getElementsByType( "vehicle" )) do
        setElementCollidableWith( veh, v, bool );
    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: 24
Na forum: 3651 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1572

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: 27
Na forum: 3892 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: 24
Na forum: 3651 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1572

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: 27
Na forum: 3892 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 = createVehicle( vehicles[actual_car].model, 1385.87, -20.98, 1000.82 ); 
for i,v in ipairs(split(vehicles[actual_car]["tuning"], ",")) do veh:addUpgrade( v ); end 
veh:setHeadLightColor( lights[1], lights[2], lights[3] ); 
veh:setInterior( 1 ); 
veh:setFrozen( true ); 
loaded = true; 
end 


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: 3351 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

a = fromJSON(vehicles[actual_car]["color"])
r,g,b = 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: 27
Na forum: 3892 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: 3351 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: 27
Na forum: 3892 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: 4254 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,b = unpack(a)
local lights=split(vehicles[actual_car]["headlights"], ","); 
veh = createVehicle( vehicles[actual_car].model, 1385.87, -20.98, 1000.82 ); 
for i,v in ipairs(split(vehicles[actual_car]["tuning"], ",")) do veh:addUpgrade( v ); end 
veh:setHeadLightColor( lights[1], lights[2], lights[3] ); 
setVehicleColor(veh,r,g,b)
veh:setInterior( 1 ); 
veh:setFrozen( true ); 
loaded = true; 
end 


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: 27
Na forum: 3892 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 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