• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Critical System tfs 1.0

secondlife

Active Member
Joined
Aug 1, 2009
Messages
302
Reaction score
25
Hello friends,
how to make a critical script melee/distance in tfs 1.0??
this version no have StatsChange, i try to make a script using onChangeHealth, but doesnt work =(
can anyone help me?
thank u guys!!
 
@Codinablack,
i already have tested Evan's guide bro
my tfs 1.0 dont have the function onHealthChange lol, but onChangeHealth, is it this? is there any difference?
thank u for feedback

Then you don't have tfs 1.0. Because it is most definitely onHealthChange, and always has been in 1.0. Evans guide worked perfectly for me when I he wrote it, he wrote it before 1.1, and I was using 1.0 then. I am using 1.1 and it still works, only one small change, cid isn't passed anymore, userdata is.

If you haven't really done any work to your server yet, I would suggest downloading from the master branch.

If you have a script written out for this and are confident that you are using the correct version of TFS (but the correct event is most definitely onHealthChange), then please post here your script and I will see if I can find any mistakes.

https://github.com/otland/forgottenserver
 
Then you don't have tfs 1.0. Because it is most definitely onHealthChange, and always has been in 1.0.
Actually it was originally called onChangeHealth in TFS 1.0: https://github.com/otland/forgotten...f9ff62b#diff-998806a0c9368f2516d632e390ab82fe

@secondlife seems like your build is quite old. If you want to stay with 1.0 you should use this: https://github.com/otland/forgottenserver/tree/1.0

Or you can move to the latest revision of 1.1: https://github.com/otland/forgottenserver

It's worth mentioning that TFS 1.1 will probably require some minor changes to the script to work. It's not hard and I or someone else would surely be able to help you if needed.
 
Apparently it was onChangeHealth() thanks @forgee

My apologies @secondlife , still, even for your version, if you honestly really truly don't want to update for some damn reason, you can still post your script here, and I will try to help you make it work for your version
 
hiho @Codinablack
my tfs is 1.0 10.76, i need this script for one custom project.
my critical.lua is
Code:
function onChangeHealth(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
  if math.random(100) <= 50 then
  if origin == ORIGIN_MELEE then
  creature:say("SKULLBASH!", TALKTYPE_MONSTER_SAY)
  elseif origin == ORIGIN_RANGED then
  creature:say("HEADSHOT!", TALKTYPE_MONSTER_SAY)
  end
  return primaryDamage * 10, primaryType, secondaryDamage, secondaryType
  end
 
  return primaryDamage, primaryType, secondaryDamage, secondaryType
end

and my tag in creaturescripts.xml is:

<event type="changehealth" name="Critical" script="critical.lua"/>


no have errors in console, but does not work, thank u bro, i'm still waiting your feedback, hugs!
 
hiho @Codinablack
my tfs is 1.0 10.76, i need this script for one custom project.
my critical.lua is
Code:
function onChangeHealth(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
  if math.random(100) <= 50 then
  if origin == ORIGIN_MELEE then
  creature:say("SKULLBASH!", TALKTYPE_MONSTER_SAY)
  elseif origin == ORIGIN_RANGED then
  creature:say("HEADSHOT!", TALKTYPE_MONSTER_SAY)
  end
  return primaryDamage * 10, primaryType, secondaryDamage, secondaryType
  end

  return primaryDamage, primaryType, secondaryDamage, secondaryType
end

and my tag in creaturescripts.xml is:

<event type="changehealth" name="Critical" script="critical.lua"/>


no have errors in console, but does not work, thank u bro, i'm still waiting your feedback, hugs!

A few things. Have you ever had a creature say any of those things? Probably not I am assuming, and will over advice based on that assumption.

You want this to actually change the damage if it's a critical hit correct? But not for it to give the same damage always. So where you have creature:say("HEADSHOT!"~ put your return there with the primary damage calculated. Now you showed me your creaturescripts.xml, and the lua script, one last thing that was missing was registering this creature event. You should have done this in your "login.lua" file. If you have it there as well and make all these changes and it still doesn't work, please post the updated script, and the copy of the line from login lua with the event registered, most of the the time it is from not registering, or a capitalization error or something like that with the event "name".
 
Hello Bro @Codinablack
i already registered in login.lua =(
tested:
Code:
    registerCreatureEvent(cid, "Critical")
and:
Code:
local events = {
   'TaskCustom',
   'PlayerDeath',
   'Critical',  
   'AdvanceSave'
}
I do not know what else to try =(
 
Try to change

registerCreatureEvent(cid, "Critical")
to
player:registerEvent("Critical")

Also if this does not work. Please check your onLogin() function in same file (login.lua). It should say onLogin(player) instead of onLogin(cid). Now please take note of this fact. Since you updated from 1.0 to 1.1 there is a crucial break in backwards compatibility, that can be fixed very easily. That means if you tried to copy any of your old scripts to the new datapack, or just used your old data pack, you will need to make alot of changes. In creaturescripts, spells, actions, talkactions, all of those scripting systems for sure and more. Instead of "cid" IE the creatures ID, being passed during these events, the userdata of that creature or item or w/e if passed instead. This makes it easier to go ahead and start using the methods instead of the functions, also keeps us from having to remake the object. So what that means is, anytime you see an event, onLogin(cid), onCastSpell(cid, var), ect. you replace cid with either creature, or player or w/e honestly, just know that the variable isn't he ID anymore, you can even leave it as cid, but instead of treating it like it's the creatures id, you treat it as if it's the creature already, cid:say() cid:getMaxHealth(), ect.

So if you have for example onLogin(cid) then change cid to player, then make sure player isn't defined anymore in the script, look and find local player = Player(cid) and erase that line.
 
@Codinablack
4tsCUDt.png


now result in this error bro
 
man, for example...
how to allow only players of level 100 or higher execute the critical?
or
how allow only players with weapons attack 45 or higher execute the critical?
is this possible?
 
man, for example...
how to allow only players of level 100 or higher execute the critical?
or
how allow only players with weapons attack 45 or higher execute the critical?
is this possible?

Yes, very easy. You just need to learn your methods. You should have a list saved with all the methods available. You can always reference it to see what you can do with the different metatables in this server. I still need to see your script, I will comment when I fix it, and show you how to add the check for the levels, and comment and show you if you really want to learn but I need to see what you have to help you.
 
has worked for me replacing:
Code:
function onChangeHealth(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
for:
Code:
function onChangeHealth(cid, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType)
but now various problems occur, the script execute critical message (SKULLBASH!) several times, 5-8x per time approx =(
how to define script check for the levels? how the define the damage in critical attack? hugs @Codinablack
 
Back
Top