Hello,
well i would like to make new thread. To help people make good and readable codes. I can also help you optimize your old codes and explain, if you post them here.
Here is some example of optimizations:
Usually what is see what people do:
How i would do:
or
Some useful codes:
Cheers everyone!
well i would like to make new thread. To help people make good and readable codes. I can also help you optimize your old codes and explain, if you post them here.
Here is some example of optimizations:
Usually what is see what people do:
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 2148 then
print("This is a gold coin.")
elseif item.itemid == 2152 then
print("This is a platium coin.")
elseif item.itemid == 2160 then
print("This is a crystal coin.")
end
return true
end
How i would do:
Code:
local config = {
[2148] = "This is a gold coin.",
[2152] = "This is a platium coin.",
[2160] = "This is a crystal coin."
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
print(config[item.itemid])
end
or
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
print("This is a ".. ItemType(item.itemid):getName() ..".")
end
Some useful codes:
Cheers everyone!
Last edited: