ok i think i have managed to write some code.
would be nice if someone could take a quick look over it!
Code: Select all
playerJob = player:getMainJob();
if (playerJob == 1) then
playerVar = player:getVar("warwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 2) then
playerVar = player:getVar("mnkwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 3) then
playerVar = player:getVar("whmwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 4) then
playerVar = player:getVar("blmwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 5) then
playerVar = player:getVar("rdmwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 6) then
playerVar = player:getVar("thfwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 7) then
playerVar = player:getVar("pldwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 8) then
playerVar = player:getVar("drkwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 9) then
playerVar = player:getVar("bstwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 10) then
playerVar = player:getVar("brdwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 11) then
playerVar = player:getVar("rngwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 12) then
playerVar = player:getVar("samwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 13) then
playerVar = player:getVar("ninwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 14) then
playerVar = player:getVar("drgwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 15) then
playerVar = player:getVar("smnwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 16) then
playerVar = player:getVar("bluwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
elsif (playerJob == 17) then
playerVar = player:getVar("corwpnVar");
item_id = 0x????;
if not(player:hasItem(item_id) and playerVar == 0) then
player:addItem(item_id);
player:messageSpecial(ITEM_OBTAINED, ????);
player:setVar("playerVar",1);
end
end
if all goes right the script checks the job of the player then checks if the player has the item allready and if you triggered the event and if both conditions are given the player gets the item.
so what i need to know now is do i need to make all variables in the database myself or does darkstar creates them himself when checking them for status?
i mean if the variable warwpnVar doesnt exists does darkstar creates it and set it to 0 or do i have to add them myself before?
also i dont really know where i should put this script...
i thought i will use "Gulldago" in bastok mines cus he isnt really important at all.
can i just pot the script inside of this method?
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
SCRIPT GOES HERE !!!!
-- printf("RESULT: %u",option);
end;
or would that not work?
also do i need to add some require's?
like im said i have no clue about lua just basic ruby knwoledge...
thx in advance!