Fix changing to the same class being treated as a change to a different class (#829)

* Fix running cooldown when changing...

...to the same class.

* Implement savilli's suggestion

Co-authored-by: savilli <savilli@users.noreply.github.com>

* Move return and remove unneeded check

* Completely remove an if check as now unneeded

* Remove whitespace from empty line

Co-authored-by: savilli <savilli@users.noreply.github.com>
Co-authored-by: LoneWolfHT <lonewolf04361@gmail.com>
This commit is contained in:
David Leal 2021-03-15 21:08:01 -06:00 committed by GitHub
parent 844436ca3d
commit 1ef6ddadfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -73,16 +73,18 @@ function ctf_classes.set(player, new_name)
local meta = player:get_meta()
local old_name = meta:get("ctf_classes:class")
if old_name == new_name then
return
end
meta:set_string("ctf_classes:class", new_name)
ctf_classes.update(player)
ctf_classes.set_cooldown(player:get_player_name())
if old_name == nil or old_name ~= new_name then
local old = old_name and ctf_classes.__classes[old_name]
for i=1, #registered_on_changed do
registered_on_changed[i](player, old, new)
end
local old = old_name and ctf_classes.__classes[old_name]
for i=1, #registered_on_changed do
registered_on_changed[i](player, old, new)
end
end