Anyone can do me a favor?
- buddysievers
- Posts: 97
- Joined: Thu Dec 06, 2012 12:10 pm
- Location: Germany
Anyone can do me a favor?
This whole lua scripting is very complicated to me and i dont know all of the functions so i hope someone is so nice and helps me out!
i want a script which runs when talking to an unused npc in bastok.
it doesnt matter which npc as long hes in bastok and isnt used atm.
the script should give the player an item based on the job he have equiped.
if its possible without much hassle to add a function to let each player get only once each item for each job.
as example: im a warrior and talk to the npc, he gives me a great axe.
when i talk to him again as a warrior he dont do anything, maybe says something that you allready got the item but it doesnt matter because its just cosmetic.
when i change my job and talk to him i get another item based on the job equiped but again only once.
if that would be too much it would be ok if he just gives the item based on the job.
thx in advance!
i want a script which runs when talking to an unused npc in bastok.
it doesnt matter which npc as long hes in bastok and isnt used atm.
the script should give the player an item based on the job he have equiped.
if its possible without much hassle to add a function to let each player get only once each item for each job.
as example: im a warrior and talk to the npc, he gives me a great axe.
when i talk to him again as a warrior he dont do anything, maybe says something that you allready got the item but it doesnt matter because its just cosmetic.
when i change my job and talk to him i get another item based on the job equiped but again only once.
if that would be too much it would be ok if he just gives the item based on the job.
thx in advance!
Re: Anyone can do me a favor?
just look at how an existing npc does it, look up [entity:function()] in src/map/lua/lua_baseentity.cpp and any lua specific stuff in lua documentation
Click here for a guide on scripting missions.<Giblet[NewBrain]> kj with this first step would be fine on my shit
- buddysievers
- Posts: 97
- Joined: Thu Dec 06, 2012 12:10 pm
- Location: Germany
Re: Anyone can do me a favor?
ok i think i have managed to write some code.
would be nice if someone could take a quick look over it!
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!
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
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!
- buddysievers
- Posts: 97
- Joined: Thu Dec 06, 2012 12:10 pm
- Location: Germany
Re: Anyone can do me a favor?
well i tried a bit arround and now it works like i wanted.
only thing what i still need is a custom message if that is possible.
is there a function like player:messageSpecial but where i just can write a string inside the luascript?
Edit: there is no lag or such because of all the elseif's so for now its ok.
only thing what i still need is a custom message if that is possible.
is there a function like player:messageSpecial but where i just can write a string inside the luascript?
Edit: there is no lag or such because of all the elseif's so for now its ok.
Re: Anyone can do me a favor?
Like:
This?
This was from the rescue drill, so, I guess just replace with your items in your statements.
Code: Select all
player:messageSpecial(ITEM_OBTAINED, 16535); -- Bronze Sword
This was from the rescue drill, so, I guess just replace with your items in your statements.
- buddysievers
- Posts: 97
- Joined: Thu Dec 06, 2012 12:10 pm
- Location: Germany
Re: Anyone can do me a favor?
Hmm for some reason it didnt work with all item ids and when it doesnt like the id the whole script isnt executed at all.
- buddysievers
- Posts: 97
- Joined: Thu Dec 06, 2012 12:10 pm
- Location: Germany
Re: Anyone can do me a favor?
no i didnt, wil try that out!