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

CreatureEvent [TFS 1.2] autoattack

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,323
Solutions
26
Reaction score
2,694
Location
Poland
I had a concept of some different kind of fast attack, but I found the code to be very inefficient and useless so I'll just share that.
Merry Christmas!


features:
PvE only - autoattack can't be used in pvp
safe burst arrows - no skull for using them in autoattack
multiple shots count as one for ammo breakchance and skilltries
quick switching targets

talkaction
Code:
local togglestorage = 2557
local delaystorage = 2558

function onSay(player, words, param)
	-- this is to avoid duplicated auto attack
	local stor = player:getStorageValue(delaystorage)
	if stor > os.time() then
		player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Please wait " .. stor - os.time() .. " seconds before trying again.")
		return false
	end

	player:setStorageValue(delaystorage, os.time() + 5)
	if player:getStorageValue(togglestorage) == 1 then
		player:setStorageValue(togglestorage, 0)
		player:sendTextMessage(MESSAGE_INFO_DESCR, "Auto attack disabled.")
		return false
	end

	player:setStorageValue(togglestorage, 1)
	player:sendTextMessage(MESSAGE_INFO_DESCR, "Auto attack enabled.")
	return false
end

creaturescripts.xml
Code:
<event type="login" name="autoAttack" script="autoattack.lua"/>

autoattack.lua
http://pastebin.com/aeKDsZSA

known bugs:
this event is onLogin so /reload creaturescripts will turn it off for all players until they log in again

No installation support. If you don't know how to install it, you just shouldn't.
 
Last edited:
@elli
any console errors?
is your level and vocation correct?
do you use it as a player?
 
You're probably right.
That script work only with regular weapons.
Burst arrows, viper stars and poison arrows are coded here as workaround only.
 
Back
Top