Shadow Dan
Sh4dowDan
I'm not a scripter, but i need that script, that's why i'm asking for help.
This is my first long(for me) script and it looks like it's a little too much for TFS.
Problem: This script can crash my server(when someone use it 2x fast) so i want someone to optimize that.
I would appreciate if someone can find a little time and improve the script.
This is my first long(for me) script and it looks like it's a little too much for TFS.
Problem: This script can crash my server(when someone use it 2x fast) so i want someone to optimize that.
I would appreciate if someone can find a little time and improve the script.
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local p1 = "Orshabaal"
local p2 = "Morgaroth"
local p3 = "Ghazbaran"
local pos1 = {x=149, y=958, z=8}
local pos2 = {x=153, y=958, z=8}
local pos3 = {x=151, y=958, z=8}
if item.actionid == 9901 and getPlayerStorageValue(cid, 9901) ~= 1 then
local reward = 0
if item.actionid == 9901 then
setPlayerStorageValue(cid, 9901, 1)
reward = doCreateItemEx(7759,1)
doCreateMonster(p1, pos1)
doCreateMonster(p2, pos2)
end
if doPlayerAddItemEx(cid, reward, 0) == RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Obudziles demony.')
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Wykonales juz ten crystal.')
end
elseif item.actionid == 9902 and getPlayerStorageValue(cid, 9902) ~= 1 then
local reward = 0
if item.actionid == 9902 then
setPlayerStorageValue(cid, 9902, 1)
reward = doCreateItemEx(7759,1)
doCreateMonster(p1, pos1)
doCreateMonster(p2, pos2)
end
if doPlayerAddItemEx(cid, reward, 0) == RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Obudziles demony.')
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Wykonales juz ten crystal.')
end
elseif item.actionid == 9903 and getPlayerStorageValue(cid, 9903) ~= 1 then
local reward = 0
if item.actionid == 9903 then
setPlayerStorageValue(cid, 9903, 1)
reward = doCreateItemEx(7761,1)
doCreateMonster(p1, pos1)
doCreateMonster(p2, pos2)
end
if doPlayerAddItemEx(cid, reward, 0) == RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Obudziles demony.')
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Wykonales juz ten crystal.')
end
elseif item.actionid == 9904 and getPlayerStorageValue(cid, 9904) ~= 1 then
local reward = 0
if item.actionid == 9904 then
setPlayerStorageValue(cid, 9904, 1)
reward = doCreateItemEx(7761,1)
doCreateMonster(p1, pos1)
doCreateMonster(p2, pos2)
end
if doPlayerAddItemEx(cid, reward, 0) == RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Obudziles demony.')
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Wykonales juz ten crystal.')
end
elseif item.actionid == 9905 and getPlayerStorageValue(cid, 9905) ~= 1 then
local reward = 0
if item.actionid == 9905 then
setPlayerStorageValue(cid, 9905, 1)
reward = doCreateItemEx(7759,1)
doCreateMonster(p1, pos1)
doCreateMonster(p2, pos2)
doCreateMonster(p3, pos3)
end
if doPlayerAddItemEx(cid, reward, 0) == RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Obudziles demony.')
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Wykonales juz ten crystal.')
end
elseif item.actionid == 9906 and getPlayerStorageValue(cid, 9906) ~= 1 then
local reward = 0
if item.actionid == 9906 then
setPlayerStorageValue(cid, 9906, 1)
reward = doCreateItemEx(7759,1)
doCreateMonster(p1, pos1)
doCreateMonster(p2, pos2)
doCreateMonster(p3, pos3)
end
if doPlayerAddItemEx(cid, reward, 0) == RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Obudziles demony.')
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Wykonales juz ten crystal.')
end
end
return FALSE
end
Last edited: