• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua AM I using this right?

Santi

Theres no way im stopping
Joined
Aug 29, 2010
Messages
1,975
Reaction score
152
Location
00
It doesn't matter fow what the script is, I just want to know if im using the 'i' alright, or im doing it wrong.
The thing im trying to make, its that each time you press the item, a globalstoragevalue will be displayed, the first time you press it you'll get 1+i , 'i' will be 1 at that moment, but after that, I added a i = i +1, so if you press it again it will be i + 1 but 'i' will be 2 at that moment. I just want to be sure that this is correct! (And if its wrong then fix it :P)
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
i = 1 
local v = t[item.uid]
      if v then
         if p(cid,v[1]) == -1 then
            setGlobalStorageValue(cid,v[2],1+i)
            setPlayerStorageValue(cid,v[1],2)
            doRemoveItem(getThingfromPos(v[3]).uid,1)
         i = i+1
           return true
           end

EDIT: I'd like to know if I can call a table this way too.
LUA:
local m = mix[getGlobalStorageValue(cid,globalstorageG) and getGlobalStorageValue(cid,globalstorageR)]

2 terms for [ ]
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
i = getGlobalStorageValue(cid,v[2])
if i <= 0 then
 j = 1 
else
j = i
end
local v = t[item.uid]
      if v then
         if p(cid,v[1]) == -1 then
            setGlobalStorageValue(cid,v[2],1+j)
            setPlayerStorageValue(cid,v[1],2)
            doRemoveItem(getThingfromPos(v[3]).uid,1)
           return true
           end
 
Back
Top