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

Wysłany: 2014-06-22, 18:11


ThomasIPG







Wiek: 30
Na forum: 4389 dni
Posty: 12
Nick w MP: Thomas

Piwa: 17

Respekt: 50

Witam chodzi o to ?e mam taki system aut na kupno ale jakie linjiki musz? dodac ?eby zakupione auto dostawa?o id i jaka linjika potem do zapisu id po wy??czeniu skryptu tutaj skrypt

function give(playerSource,pcar,car,cost,km)
    car getVehicleModelFromName(car)
    if isPlayerInACL(playerSource,"Admin")
    then xygetElementPosition(playerSource)
    if ( car then 
        local theCar createVehicle(car,x,y,z+0.15)
        setElementPosition(playerSource,x,y,z+1.5)
        local xr,yr,zr getElementRotation(playerSource)
        setElementRotation(theCar,xr,yr,zr)
        setElementData(theCar,"vehicle:cost",tonumber(cost))
        setElementData(theCar,"vehicle:owner",0)
        setElementFrozen(theCar,true)
        outputChatBox("#63DBFF*Stworzy?e? pojazd #B9F46C"..getVehicleNameFromModel(car).." #63DBFFkt?ry kosztuje #B9F46C"..cost.."$#63DBFF.",playerSource,0,0,0,true)
        if km then
        setElementData(theCar,"vehicle:travel",tonumber(km))
        end
        else
        outputChatBox("#63DBFF*Wpisa?e? z?? nazw? auta.",playerSource,0,0,0,true)
        end else outputChatBox("#63DBFF*Nie masz prawa do u?ywania tej komendy.",playerSource,0,0,0,true)
end
end

addCommandHandler("stworz.pojazd",give)
Tutaj musi dawac aucie losowe id jest tez w skrypcie mozliwosc sprzedawania i kupowania pojazdu ale to chyba niepotrzbne

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-06-22, 18:18


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4394 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

liczba math.random 11000 )
liczba tonumber liczba )
setElementData zakupione_auta"id"liczba )


Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-06-22, 18:39


ThomasIPG







Wiek: 30
Na forum: 4389 dni
Posty: 12
Nick w MP: Thomas

Piwa: 17

Respekt: 50

liczba math.random 11000 )
liczba tonumber liczba )

function isPlayerInACL playeracl )
    local account getPlayerAccount player )
    if ( isGuestAccount account ) ) then
        return false
    end
        return isObjectInACLGroup "user."..getAccountName account ), aclGetGroup acl ) )
end


function give(playerSource,pcar,car,cost,km)
    car getVehicleModelFromName(car)
    if isPlayerInACL(playerSource,"Admin")
    then xygetElementPosition(playerSource)
    if ( car then 
        local theCar createVehicle(car,x,y,z+0.15)
        setElementPosition(playerSource,x,y,z+1.5)
        local xr,yr,zr getElementRotation(playerSource)
        setElementRotation(theCar,xr,yr,zr)
        setElementData(theCar,"vehicle:cost",tonumber(cost))
        setElementData(theCar,"vehicle:owner",0)
        setElementData zakupione_auta"id"liczba )
        setElementFrozen(theCar,true)
        outputChatBox("#63DBFF*Stworzy?e? pojazd #B9F46C"..getVehicleNameFromModel(car).." #63DBFFkt?ry kosztuje #B9F46C"..cost.."$#63DBFF.",playerSource,0,0,0,true)
        if km then
        setElementData(theCar,"vehicle:travel",tonumber(km))
        end
        else
        outputChatBox("#63DBFF*Wpisa?e? z?? nazw? auta.",playerSource,0,0,0,true)
        end else outputChatBox("#63DBFF*Nie masz prawa do u?ywania tej komendy.",playerSource,0,0,0,true)
end
end

addCommandHandler("stworz.pojazd",give)

function onBuyCar(sPlayer)
  if getPlayerAccount(sPlayerthen
    if isPedInVehicle(sPlayerthen
        if getElementData(getPedOccupiedVehicle(sPlayer),"vehicle:owner")==0 then
        if getPlayerMoney(sPlayer)>=tonumber(getElementData(getPedOccupiedVehicle(sPlayer),"vehicle:cost")) then
            setElementData(getPedOccupiedVehicle(sPlayer),"vehicle:owner",getPlayerAccount(sPlayer))
                setElementData(getPedOccupiedVehicle(sPlayer),"ownername",getPlayerName(sPlayer))
                takePlayerMoney(sPlayer,getElementData(getPedOccupiedVehicle(sPlayer),"vehicle:cost"))
                setVehicleEngineState(getPedOccupiedVehicle(sPlayer),true)
                setElementFrozen(getPedOccupiedVehicle(sPlayer),false)
                setElementData(getPedOccupiedVehicle(sPlayer),"ownername",getPlayerName(sPlayer))
                outputChatBox("#63DBFF*Kupi?e? pojazd #B9F46C"..getVehicleName(getPedOccupiedVehicle(sPlayer)).."#63DBFF za #B9F46C"..getElementData(getPedOccupiedVehicle(sPlayer),"vehicle:cost").."$#63DBFF.",sPlayer,0,0,0,true)
                outputChatBox("#63DBFF*Aby sprzeda? pojazd wpisz komende #FF0000/sprzedaj.pojazd <cena> a ?eby zaparkowa? auto /zaparkuj.",playerSource,0,0,0,true)
                local xygetElementPosition(getPedOccupiedVehicle(sPlayer))
                local blip createBlip(x,y,z,0,1,0,0,255,255,0,65535,sPlayersetElementData(blip,"blip:vehicle",getPedOccupiedVehicle(sPlayer))
                else outputChatBox("#63DBFF*Niemasz wystarczaj?co du?o pieni?dzy ?eby kupi? ten #B9F46C"..getVehicleName(getPedOccupiedVehicle(sPlayer)).."#63DBFF.",sPlayer,0,0,0,true)
            end
        end
        else outputChatBox("#63DBFF*Musisz by? zalogowany.",sPlayer,0,0,0,true)
end
  end
end

addCommandHandler("kuppojazd",onBuyCar)
                

function onEnterCar(thePlayer,seat,jacked)
if seat == 0 then
    if getElementData(source,"vehicle:owner")==0
    then setVehicleEngineState(source,false)
    outputChatBox("#63DBFF*Ten #B9F46C"..getVehicleName(source).." #63DBFFkosztuje#B9F46C "..getElementData(source,"vehicle:cost").."$#63DBFF.",thePlayer,0,0,0,true)
    outputChatBox("#63DBFF*Je?eli chcesz kupi? ten pojazd wpisz#B9F46C /kuppojazd".."#63DBFF.",thePlayer,0,0,0,true)
        else if seat == 0 then if getElementData(source,"vehicle:owner"then if getElementData(source,"vehicle:owner")~=getPlayerAccount(thePlayer)then
        removePedFromVehicle(thePlayeroutputChatBox("#63DBFF*Ten #B9F46C"..getVehicleName(source).." #63DBFFnie nale?y do ciebie.",thePlayer,0,0,0,true)
    end
end
end
end
end
end

addEventHandler("onVehicleStartEnter",getRootElement(),function (thePlayer,seat,jacked)
if seat == 0 then
if jacked == true or false then
if getElementData(source,"vehicle:owner")== not getPlayerAccount(source) or 0 then
outputChatBox("#63DBFF*Ten #B9F46C"..getVehicleName(source).." #63DBFFnie nale?y do ciebie.",thePlayer,0,0,0,true)
end
end
end
end)

addEventHandler("onVehicleEnter",getRootElement(),onEnterCar)

function blipsit()
for keyvalue in ipairs(getElementsByType("player")) do
if getPlayerAccount(valuethen
for kv in ipairs(getElementsByType("vehicle")) do
for k1v1 in ipairs(getElementsByType("blip")) do
if getElementData(v1,"blip:vehicle"then
if getElementType(getElementData(v1,"blip:vehicle"))=="vehicle" then
if getElementData(v,"vehicle:owner")==getPlayerAccount(valuethen
setElementVisibleTo(v1,value,true)
else setElementVisibleTo(v1,value,false)
end
else if getElementData(v1,"blip:vehicle"then destroyElement(v1)
end
end
else if getElementData(v1,"blip:vehicle"then destroyElement(v1)
end
end
end
end
end
end
end

function timerek()
setTimerblipsit1000)
end

timerek()


function sellCar(pps,command,koszt)
if isPedInVehicle(ppsthen
if getElementData(getPedOccupiedVehicle(pps),"vehicle:owner")==getPlayerAccount(ppsthen
if koszt then
if getElementData(getPedOccupiedVehicle(pps),"vehicle:cost")>=tonumber(kosztthen
setElementData(getPedOccupiedVehicle(pps),"vehicle:cost",tonumber(koszt))
carx getPedOccupiedVehicle(pps)
setElementFrozen(carx,true)
setVehicleEngineState(carx,false)
setVehicleDamageProof(carx,true)
setElementData(carx,"vehicle:owner",0)
setElementData(carx,"vehicle:used",true)
setElementData(carx,"vehicle:cost",tonumber(koszt))
givePlayerMoney(pps,tonumber(koszt))
outputChatBox("#63DBFF*Wystawi?e? pojazd #B9F46C"..getVehicleName(carx).." #63DBFFza #B9F46C"..tostring(koszt).."$#63DBFF.",pps,0,0,0,true)
removePedFromVehicle(pps)
else carx getPedOccupiedVehicle(ppsoutputChatBox("#63DBFF*Nie mo?esz wystawi? pojazdu za #B9F46C"..tostring(koszt).."$ #63DBFFponiewa? jest to wi?cej ni? jego poprzednia cena #B9F46C"..tostring(getElementData(carx,"vehicle:cost")).."$#63DBFF.",pps,0,0,0,true)
end
else outputChatBox("#63DBFF*?le wpisana komenda powinno by? #B9F46C/sprzedaj.pojazd <cena>#63DBFF.",pps,0,0,0,true)
end
else outputChatBox("#63DBFF*Ten pojazd nie nale?y do ciebie.",pps,0,0,0,true)
end
else outputChatBox("#63DBFF*Musisz by? w poje?dzie.",pps,0,0,0,true)
end
end

addCommandHandler("sprzedaj.pojazd",sellCar)

addEventHandler("onElementDestroy",getRootElement(),function ()
if getElementType(source)=="vehicle" then
setElementData(source,"vehicle:owner",nil)
setElementData(source,"vehicle:cost",nil)
setElementData(source,"vehicle:used",nil)
setElementData(source,"vehicle:travel",nil)
if getElementData(source,"vehicle:blip")~=nil or getElementData(source,"vehicle:blip")~=false then
destroyElement(getElementData(source,"vehicle:blip"))
end
end
end)



setTimer(function () 
for kv in ipairs(getElementsByType("player")) do
for keyvalue in ipairs(getElementsByType("blip")) do
if getElementData(value,"blip:vehicle"then
if isElement(getElementData(value,"blip:vehicle")) then
if getElementType(getElementData(value,"blip:vehicle"))=="vehicle" then
local vehicle getElementData(value,"blip:vehicle")
if getElementData(vehicle,"vehicle:owner")~=0 then
if getElementData(vehicle,"vehicle:owner")==getPlayerAccount(vthen
setElementVisibleTo(value,v,true)
else
setElementVisibleTo(value,v,false)
end
end
end
end
end
end
end
end,1000,0)



function saveallvehicles()
    executeSQLDropTable "vehiclesaver" )
    executeSQLCreateTable "vehiclesaver""VehicleID INTEGER, px REAL, py REAL, pz REAL, rx REAL, ry REAL, rz REAL, Color1 INTEGER, Color2 INTEGER, Health REAL, upgrades TEXT, paintjob INTEGER, idd, wlasciciel, xx, yy, zz, rr1, rr2, rr3, paliwo,r,g,b" )
    for ivehicle in pairs (getElementsByType("vehicle")) do
    if not getElementData(vehicle"private"then
    destroyElement vehicle )

end


        local pxpypz getElementPosition(vehicle)
        local rxryrz getElementRotation(vehicle)
        local color1color2color3color4 getVehicleColor(vehicle)
        local model getElementModel(vehicle)
        local health getElementHealth (vehicle)
        local tableUpgrades getVehicleUpgrades(vehicle)
        local upgrades table.concat(tableUpgrades",")
        local paintjob getVehiclePaintjob(vehicle)
        local idd getElementData vehicle"liczba" )
        local wlasciciel getElementData(vehicle"owner")
         local paliwo getElementData vehicle"fuel" )       
        local xx getElementData vehicle"x" )
        local yy getElementData vehicle"y" )
        local zz getElementData vehicle"z" )
        local rr1 getElementData vehicle"r1" )
        local rr2 getElementData vehicle"r2" )
        local rr3 getElementData vehicle"r3" )
    local r,g,getVehicleColor(vehicletrue )
        executeSQLInsert "vehiclesaver""'"..model.."','"..px.."','"..py.."','"..pz.."','"..rx.."','"..ry.."','"..rz.."','"..color1.."','"..color2.."','"..health.."','"..upgrades.."','"..paintjob.."','"..idd.."','"..wlasciciel.."','"..xx.."','"..yy.."','"..zz.."','"..rr1.."','"..rr2.."','"..rr3.."','"..paliwo.."','"..r.."','"..g.."','"..b.."'" )
    end
end

addEventHandler("onResourceStop"getResourceRootElement(getThisResource()), saveallvehicles)

function createDatabase()
    executeSQLCreateTable "vehiclesaver""VehicleID INTEGER, px REAL, py REAL, pz REAL, rx REAL, ry REAL, rz REAL, Color1 INTEGER, Color2 INTEGER, Color3 INTEGER, Color4 INTEGER, Health REAL, upgrades TEXT, paintjob INTEGER, idd, wlasciciel, xx, yy, zz, rr1, rr2, rr3, paliwo,r,g,b" )
   
    local vehicles executeSQLQuery("SELECT * FROM vehiclesaver")
    

    for iv in pairs (vehicles) do
        local vehicle createVehiclev.VehicleIDv.pxv.pyv.pzv.rxv.ryv.rz )
        setElementHealth vehiclev.Health )
        setVehicleColor vehiclev.Color1v.Color20)
        setVehicleColor(vehiclev.r,v.g,v.)
        if ( v.paintjob then
            setVehiclePaintjobvehiclev.paintjob )
            setElementData vehicle"liczba"v.idd )
            
            setElementData vehicle"r1"v.rr1setElementData vehicle"r2"v.rr2)
setElementData vehicle"r3"v.rr3setElementData vehicle"zapisany"true )
setElementData vehicle"x"v.xxsetElementData vehicle"y"v.yysetElementData vehicle"z"v.zz)


            


            
            
                        setElementData(vehicle"private"true)
            setElementData(vehicle"owner"v.wlasciciel )
            setElementData vehicle"fuel"v.paliwo)
        end
        local upgrades splitv.upgrades44 )
        for indexupgrade in pairs (upgrades) do
            addVehicleUpgradevehicleupgrade )
     

            
        end
    end
    outputChatBox#vehicles.." - wczytane pojazdy", getRootElement(), 0, 255, 0 )
    outputDebugString #vehicles.." - wczytane pojazdy" )
end
addEventHandler("onResourceStart"getResourceRootElement(getThisResource()), createDatabase)
I teraz b?dzie dzia?a? jak i b?dzie si? zapisywa??

Ostatnio zmieniony przez ThomasIPG 2014-06-22, 20:42, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-06-22, 20:37


Zgredek666

LUA






Wiek: 27
Na forum: 4722 dni
Posty: 251
Nick w MP: Zgredek

Piwa: 442

Respekt: 70,1

To
setElementData zakupione_auta"id"liczba )
musi by? w funkcji tamte stringi mog? tak pozosta?

Podpis
Piszę skrypty lua na serwery Truck/RPG/Race/DayZ. Kontakt pw!

Pomogłem? Wystarczy jak postawisz :piwo:



Zapraszam na mój kanał na yt:
https://www.youtube.com/c...vgsF65M-Xw5hEDQ
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-06-22, 20:43


ThomasIPG







Wiek: 30
Na forum: 4389 dni
Posty: 12
Nick w MP: Thomas

Piwa: 17

Respekt: 50

zedytowa?em zobacz

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-06-22, 20:45


Zgredek666

LUA






Wiek: 27
Na forum: 4722 dni
Posty: 251
Nick w MP: Zgredek

Piwa: 442

Respekt: 70,1

"ThomasIPG" napisał/a:

I teraz b?dzie dzia?a? jak i b?dzie si? zapisywa??


Wr??bit? nie jestem nie wiem sprawd?, jak nie b?dzie dzia?a? to zobacz do db3 i wtedy dalej pisz b?d? si? stara? pom?c

Podpis
Piszę skrypty lua na serwery Truck/RPG/Race/DayZ. Kontakt pw!

Pomogłem? Wystarczy jak postawisz :piwo:



Zapraszam na mój kanał na yt:
https://www.youtube.com/c...vgsF65M-Xw5hEDQ
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-06-22, 20:52


ThomasIPG







Wiek: 30
Na forum: 4389 dni
Posty: 12
Nick w MP: Thomas

Piwa: 17

Respekt: 50

spk tylko niemam gta niemoge znale?? jakie? strony z gta

Postaw piwo autorowi tego posta
 

 
Tagi: jak :: dodac :: aucie :: zakupie
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