Hallo, habe mal eine Frage und zwar hab ich ein Script geschrieben was den Spieler ermöglicht Ganja anzupflanzen. Das ganze funktioniert auch soweit. Hier das Script:
function onPlayerSeed ()
setElementData(source,"Ganja Seed",getElementData(source,"Ganja Seed")-1)
setPedAnimation (source,"BOMBER","BOM_Plant",false,false,false,false)
local source = source
setTimer( function ()
local x,y,z = getElementPosition(source)
ganja = createObject(823, x,y,z-0.3)
setObjectScale(ganja,0.3)
colGanja = createColSphere(x,y,z,2)
attachElements ( colGanja, ganja, 0, 0, 0 )
setElementData(colGanja,"parent",ganja)
setElementData(ganja,"parent",colGanja)
setElementData(colGanja,"ganjaseed",true)
setElementData(colGanja,"ganjastate",0)
attachElements(ganja,source,0,4,-1,0,0,180)
mark = createMarker ( x, y, z-3, "cylinder", 3.5, 255, 0, 0, 105, source )
setElementData(mark,"ganjaMark",true)
setElementData(mark,"ganja",ganja)
setElementData(mark,"colGanja",colGanja)
outputChatBox("Press Enter to place the Ganja.",source,255,255,255)
bindKey(source,"enter","down",setGanja,ganja,vrot,mark)
end,1000,1)
setTimer(function()
setElementData(colGanja,"ganjastate",getElementData(colGanja,"ganjastate") +1 )
end,10000,0) --11400000
setTimer(function()
if isElement(colGanja) then
if getElementData(colGanja,"ganjastate") >= 10 then
setElementData(colGanja,"ganjastate",10)
setObjectScale(ganja,0.5)
end
end
end,500,0)
end
addEvent("onPlayerSeed",true)
addEventHandler("onPlayerSeed",getRootElement(),onPlayerSeed)
Alles anzeigen
Problem: Ich sage im Script das "ganjastate" meine Ganja "Knospen" sind diese werden dann in der ColSphere gespeichert. Jedoch hat ein User die Möglichkeit mehrmals Ganja anzupflanzen und sobald man mehr als eine Ganja Pflanze gepflanzt hat wird das ganze "ganjastate" nur in die erst platzierte Pflanze gesetzt die andere zuletzt gepflanzte Pflanze wird vollkommen ignoriert und bekommt kein "ganjastate" dazu. Wie kann ich das beheben?