• 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!

TFS 0.X how can I check if the player causing damage with a weapon

Lurk

Active Member
Joined
Dec 4, 2017
Messages
336
Reaction score
48
I'm trying to mess around with onStatsChange and I need to check if the damage that the player is causing is being caused by a weapon (since the player can deal damage with runes, spells, fire field and what not)
I know I can getPlayerSlotItem but that will only tell me that he has a weapon equiped
 
Solution
cause I have a project is 0.x, converting everything to 1.3 rn when it is running could cause a lot of trouble

Shadow_ that would lead me to the exact problem I listed, I would be able to check if the player is using x weapon but I wouldn't be able to verify if the damage he's dealing right now is being dealt by that weapon
I'd suggest against it, since constantly spamming storage value changes just bogs down the database..

But inside of the weapon script.. if the weapon will damage the enemy, then give storage +1. If storage is 1, then return to 0 in onStats change, and do whatever you want at that point.

Doing it strictly inside of onStatsChange isn't possible do to the limitations of not knowing the...
0.4 have limited functions to be honest in terms of knowing hits values/types.
I was trying to make lifesteal system but I dont know if its possible without adding new functions
 
I can actually think of some ways to make life steal work, you just need some creativity and inspiration (by that I mean there's x script that makes y and based on that you can create z)
 
in weapons/scripts/theweapon file
you can use storage so lets say player:getStorageValue(9412,4) and check in onStatsChange like this if player:getStorageValue(9412,4) also don't forget to use on deequip script to player:setStorageValue(9412, -1)
-- used 1.3 functions because dunno much about 0.x
used nearly the same way but with function onKill you can understand more from this script.
 
cause I have a project is 0.x, converting everything to 1.3 rn when it is running could cause a lot of trouble

Shadow_ that would lead me to the exact problem I listed, I would be able to check if the player is using x weapon but I wouldn't be able to verify if the damage he's dealing right now is being dealt by that weapon
 
cause I have a project is 0.x, converting everything to 1.3 rn when it is running could cause a lot of trouble

Shadow_ that would lead me to the exact problem I listed, I would be able to check if the player is using x weapon but I wouldn't be able to verify if the damage he's dealing right now is being dealt by that weapon
I'd suggest against it, since constantly spamming storage value changes just bogs down the database..

But inside of the weapon script.. if the weapon will damage the enemy, then give storage +1. If storage is 1, then return to 0 in onStats change, and do whatever you want at that point.

Doing it strictly inside of onStatsChange isn't possible do to the limitations of not knowing the source of the damage, which the storage value would solve.
 
Solution
no it doesnt
So you're telling me that having 100 players online with no storage value changes is faster then 100 players online changing and checking storage values constantly every 2 seconds?
 
So you're telling me that having 100 players online with no storage value changes is faster then 100 players online changing and checking storage values constantly every 2 seconds?
Storage isn't saved every time it is applied (that would be soo bad). You can spam setStorageValue every 0.1s with 1000 players online and not care. The thing with storages is that unnecessary amount just makes database grow in size and SELECT becoming slower and slower.
tl;dr; Don't use storages for every god damn thing. If you want to preserve some data (or use in different scripts) for players that don't have to be saved between sessions, use global variables instead.
 
nvm you're right.
I forgot that storages values are stored in memory and only go into storage during save states. (player logoff / server save)

So yeah, won't bog down the database.
Post automatically merged:

Storage isn't saved every time it is applied (that would be soo bad). You can spam setStorageValue every 0.1s with 1000 players online and not care. The thing with storages is that unnecessary amount just makes database grow in size and SELECT becoming slower and slower.
tl;dr; Don't use storages for every god damn thing.
ah yep. I basically went and researched this.
Thanks for clarifying.
 
xikini's answer help me in what I want to do and the whole talk here also teached me some stuff :p thank yall
 
Back
Top