Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Where do I save functions?

Newbie Spellweaver
Joined
Feb 16, 2010
Messages
7
Reaction score
0
hello, i've written some functions but i don't know where i need to save them in order to make them work in game (supposing they are scripted correctly)

for example, i use the function name in a npc script and the function itself is written in another script. where do i need to save it to?

hope someone can help me out, ty in advance
 
Newbie Spellweaver
Joined
Feb 16, 2010
Messages
7
Reaction score
0
made a function that resets more than 1 stat point (again i havent got the chance to check it, so it might have mistakes.. im learning scripting by myself by looking at existing scripts). ill write the str reset and a part of npc script that i think is how to write it.

npc:
Talk(2,"How many Strength points do you want to reset?")
Text(2,"5", Reset_Str, 1, 5)
Text(2,"10", Reset_Str, 1, 10)
Text(2,"30", Reset_Str, 1, 30)
Text(2,"50", Reset_Str, 1, 50)

function:

function Reset_Str ( role , Amount ) --idk what role stands for.. but i think u give it the value 1?
local str = GetChaAttr( role , ATTR_BSTR )
local ap = GetChaAttr( role , ATTR_AP )

local str_dif = Amount
local ap_dif = Amount

--test to see if it's entring the function
SystemNotice( role, "stat chosen: str")
SystemNotice( role, "amount chosen: "..Amount)

if str < (5 + str_dif) then
SystemNotice ( role , "You do not have enough points to reset. Reset failed" )
UseItemFailed ( role ) --i suppose this one is not needed since i dont use an item, so i simply leave it out?
return
end

str = str - str_dif
ap = ap + ap_dif

SystemNotice ( role , "Reset "..str_dif.." Strength points to increase "..ap_dif.." Stat points" )
SetCharaAttr ( str , role , ATTR_BSTR )
SetCharaAttr ( ap , role , ATTR_AP )
end
 
Last edited:
Skilled Illusionist
Joined
Jun 5, 2009
Messages
311
Reaction score
28
NpcScripts
PHP:
npc:
Talk(2,"How many Strength points do you want to reset?")
Text(2,"5", Reset_Str, 1, 5)
Text(2,"10", Reset_Str, 1, 10)
Text(2,"30", Reset_Str, 1, 30)
Text(2,"50", Reset_Str, 1, 50)
Function.lua
PHP:
function Reset_Str ( role , Amount ) --idk what role stands for.. but i think u give it the value 1?
local str = GetChaAttr( role , ATTR_BSTR )
local ap = GetChaAttr( role , ATTR_AP )

local str_dif = Amount
local ap_dif = Amount

--test to see if it's entring the function
SystemNotice( role, "stat chosen: str")
SystemNotice( role, "amount chosen: "..Amount)

if str < (5 + str_dif) then
SystemNotice ( role , "You do not have enough points to reset. Reset failed" )
UseItemFailed ( role ) --i suppose this one is not needed since i dont use an item, so i simply leave it out?
return
end

str = str - str_dif
ap = ap + ap_dif

SystemNotice ( role , "Reset "..str_dif.." Strength points to increase "..ap_dif.." Stat points" )
SetCharaAttr ( str , role , ATTR_BSTR )
SetCharaAttr ( ap , role , ATTR_AP )
end
 
Newbie Spellweaver
Joined
Feb 16, 2010
Messages
7
Reaction score
0
eh thats what i have tried doing before coming here but in game it tells me 'MsgProc: function option unknown function!'
is there anything else i need to do? or does that mean ive got a mistake in my function?

also, could u tell me if its right to give the 'role' the value 1? and if i can leave out the UseItemFailed? i copy pasted it from the function for the reset potions and edited it..
 
Junior Spellweaver
Joined
Jan 23, 2010
Messages
187
Reaction score
12
ok look do this
Put in anyone of your npcscripts.lua

function random_name ()
Talk(2,"How many Strength points do you want to reset?")
Text(2,"5", Reset_Str, 1, 5)
Text(2,"10", Reset_Str, 1, 10)
Text(2,"30", Reset_Str, 1, 30)
Text(2,"50", Reset_Str, 1, 50)
end

Then in garnernpc.txt
or magicseanpc.txt
or darkbluenpc.txt

which ever map you want it be on copy any npc
when u paste make new id change name if u want and the cords the second set...cords must be same as first set.then scroll almost to end you should see a function name like r_talk or w/e npc u copied
change it to

random_name

go would look like this
This is garner npc


200 WhatName 1 20(change how the npc looks..characterinfo choose a number) 1 219312,270612(this first set of cords i was talking about) 219312,270612(this is second. they must be the same for whatever new cords you put the guy at) 114(this is angle he faces) Argent City(map npc is on) 1 0 random_name(function for the function in npcscripts) 0

200 WhatName 1 20 1 219312,270612 219312,270612 114 Argent City 1 0 random_name 0
 
Last edited:
Back
Top