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

Wysłany: 2016-03-26, 17:52


GamerHD11







Wiek: 24
Na forum: 4402 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

Witam mam problem. Ustawi?em sobie przed funkcjami w skrypcie, ?eby mi nadawa?o elementDate na 5, no i gdy u?ywam przedmiotu to mi odejmuije i mam ilo?? przedmiotu r?wn? 4, ale gdy nast?pnym razem u?yje to ju? mi nie odejmuje -1 do ilo?ci.

ileziola = getElementData(localPlayer, "Marihuana")
wynik = ileziola - 1
guiGridListSetItemText(grid, rowmarycha, ilosc, ""..wynik.." g.", false, false)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 17:56


AteX







Wiek: 27
Na forum: 4156 dni
Posty: 925
Nick w MP: #AteX

Piwa: 8366

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

ileziola = getElementData(localPlayer, "Marihuana")
wynik = ileziola - 1
setElementData(localPlayer,"Marihuana",wynik)
guiGridListSetItemText(grid, rowmarycha, ilosc, ""..wynik.." g.", false, false)


Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 18:11


GamerHD11







Wiek: 24
Na forum: 4402 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

O dzi?ki, dzia?a i jeszcze jedno, wywala mi bledy i gdy mam 0 to sie nie usuwa row

function sprMarycha()
if getElementData(localPlayer, "Marihuana") >= 1 then
if guiGridListGetItemText(grid, rowmarycha, przedmiot) then return end
rowmarycha = guiGridListAddRow(grid)
iloscmarycha = getElementData(localPlayer, "Marihuana") or 0
guiGridListSetItemText(grid, rowmarycha, przedmiot, "Marihuana", false, false)
guiGridListSetItemText(grid, rowmarycha, ilosc, ""..iloscmarycha.." g", false, false)
elseif getElementData(localPlayer, "Marihuana") == 0 then
guiGridListRemoveRow(rowmarycha, przedmiot)
guiGridListRemoveRow(rowmarycha, ilosc)
end
end
addEventHandler("onClientRender", getRootElement(), sprMarycha)


B?ad w DB3 jest wlasnie w obu RemoveRow i pisze expected gui-element at argument 1, got number '0'

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 18:17


AteX







Wiek: 27
Na forum: 4156 dni
Posty: 925
Nick w MP: #AteX

Piwa: 8366

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

function sprMarycha()
if getElementData(localPlayer, "Marihuana") >= 1 then
if guiGridListGetItemText(grid, rowmarycha, przedmiot) then return end
rowmarycha = guiGridListAddRow(grid)
iloscmarycha = getElementData(localPlayer, "Marihuana") or 0
guiGridListSetItemText(grid, rowmarycha, przedmiot, "Marihuana", false, false)
guiGridListSetItemText(grid, rowmarycha, ilosc, ""..iloscmarycha.." g", false, false)
elseif getElementData(localPlayer, "Marihuana") == 0 then
guiGridListRemoveRow(grid,rowmarycha)
end
end
addEventHandler("onClientRender", getRootElement(), sprMarycha)


Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 18:25


GamerHD11







Wiek: 24
Na forum: 4402 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

Teraz usuwa wszystkie row'y, a nie jeden. Nie ma DB3

Usuwa wszystkie rowy, kt?re s? pod tym kt?rego jest 0 i go te? usuwa.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 18:32


AteX







Wiek: 27
Na forum: 4156 dni
Posty: 925
Nick w MP: #AteX

Piwa: 8366

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

"GamerHD11" napisał/a:

Teraz usuwa wszystkie row'y, a nie jeden. Nie ma DB3

Usuwa wszystkie rowy, kt?re s? pod tym kt?rego jest 0 i go te? usuwa.


Nwm jak to wygl?da w grze i co chcesz za bardzo osi?gn??, ale skoro usuwa to ju? wiesz co trzeba zrobi?. Pierwszy argument w guiGridListRemoveRow to gridlista, a drugi row. Pokombinuj, a jak dalej nie b?dziesz m?g? sobie da? rady to pisz.

Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 18:45


GamerHD11







Wiek: 24
Na forum: 4402 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

Nie ogarniam wszystko powinno si? zgadza?, gridLista ma zmienn? grid, a row ma zmienn? rowmarycha, poprostu chodzi o to, ?e jak marihuana jest pierwsza na gridli?cie to si? usuwa i inne itemy, kt?re by?y pod ni?.

GUI:
okno = guiCreateWindow(781, 272, 334, 546, "Ekwipunek", false)
        guiWindowSetSizable(okno, false)
        grid = guiCreateGridList(9, 21, 315, 441, false, okno)
        przedmiot = guiGridListAddColumn(grid, "Przedmiot", 0.5)
        ilosc = guiGridListAddColumn(grid, "Ilo??", 0.5)   
        btnuzyj = guiCreateButton(10, 472, 155, 60, "U?yj", false, okno)
        btnwyrzuc = guiCreateButton(169, 472, 155, 60, "Wyrzu?", false, okno)
        guiSetVisible(okno, false)


Sprawdzenie:

function sprMarycha()
if getElementData(localPlayer, "Marihuana") >= 1 then
if guiGridListGetItemText(grid, rowmarycha, przedmiot) then return end
rowmarycha = guiGridListAddRow(grid)
iloscmarycha = getElementData(localPlayer, "Marihuana") or 0
guiGridListSetItemText(grid, rowmarycha, przedmiot, "Marihuana", false, false)
guiGridListSetItemText(grid, rowmarycha, ilosc, ""..iloscmarycha.." g", false, false)
elseif getElementData(localPlayer, "Marihuana") == 0 then
guiGridListRemoveRow(grid,rowmarycha)
end
end
addEventHandler("onClientRender", getRootElement(), sprMarycha)


Dzia?anie:

function uzyjMarycha()
chose = guiGridListGetItemText ( grid, guiGridListGetSelectedItem ( grid ), 1 )
if chose == "Marihuana" then
if getElementData(localPlayer, "Marihuana") >= 1 then
if getElementData(localPlayer, "tripmar") == false then
setElementData(localPlayer, "tripmar", true)
ileziola = getElementData(localPlayer, "Marihuana")
wynik = ileziola - 1
setElementData(localPlayer,"Marihuana",wynik)
guiGridListSetItemText(grid, rowmarycha, ilosc, ""..wynik.." g.", false, false)
pogoda = getWeather()
setGameSpeed(0.6)
muza = playSound("sound/reggae.mp3", true)
setCameraShakeLevel(45)
setWindVelocity(20, 20, 0)
setHeatHaze(255)
setWaveHeight(50)
setWeather(0)
setGravity(0.006)
setSkyGradient(math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255))
setWaterColor(math.random(0,255), math.random(0,255), math.random(0,255), math.random(0, 255))
setSunColor(math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255))
setFogDistance(math.random(0,500))
setTimer(function()
setElementData(localPlayer, "tripmar", false)
resetSkyGradient()
resetWaterColor()
resetFogDistance()
resetWindVelocity()
resetSunColor()
resetHeatHaze()
setGravity(0.008)
setGameSpeed(1)
stopSound(muza)
setWeather(pogoda)
setWaveHeight(0)
setCameraShakeLevel(1)
end, 5000, 1)
end
end
end
end
addEventHandler("onClientGUIClick", btnuzyj, uzyjMarycha)


Wywala b??d w guiGridListGetTextItem

Postaw piwo autorowi tego posta
 

 
Tagi: nie :: odejmuje :: przedmiotu
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Nie odejmuje przedmiotu 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