17.01.2013, 08:01
Hello,
I made a trigger which runs when the third cheatlog get inserted of a player.
So when a player has been detected three times for cheating he will get banned.
this is the trigger:
The only problem is, when I unban this person, he get directly banned after one cheatlog, and i don't want to delete all the cheatlogs when he got unbanned.
So I made a column called 'TRIGGERED' inside log_cheat.
I want this to set on 1 for all rows that belows to the player that is getting banned, so basicly it will be:
So this will looks like:
The only problem is that it gives me an error when it runs, because it cannot update the table log_cheat because it is stored inside the trigger or something, someone knows a way to modify the trigger so this will work?
I made a trigger which runs when the third cheatlog get inserted of a player.
So when a player has been detected three times for cheating he will get banned.
this is the trigger:
PHP код:
CREATE TRIGGER `check_for_ban` BEFORE INSERT ON `log_cheat`
FOR EACH ROW IF ((SELECT COUNT(*) FROM `log_cheat` WHERE PLR_ID = NEW.PLR_ID AND TRIGGERED != 1) > 2)
THEN INSERT INTO `log_banned` (`PLR_ID`,`PLR_NAME`,`PLR_IP`,`ADM_ID`,`ADM_IP`, `DESCRIPTION`, `TIME`, `TYPE`)
VALUES (NEW.PLR_ID, (SELECT PLR_NAME FROM `plr_account` WHERE plr_account.PLR_ID = NEW.PLR_ID), NEW.PLR_IP, -1, 'none', '3 times kicked for using cheats.', NOW(), 0);
END IF
So I made a column called 'TRIGGERED' inside log_cheat.
I want this to set on 1 for all rows that belows to the player that is getting banned, so basicly it will be:
PHP код:
UPDATE `log_cheat` SET TRIGGERED=1 WHERE PLR_ID = NEW.PLR_ID
PHP код:
CREATE TRIGGER `check_for_ban` BEFORE INSERT ON `log_cheat`
FOR EACH ROW IF ((SELECT COUNT(*) FROM `log_cheat` WHERE PLR_ID = NEW.PLR_ID AND TRIGGERED != 1) > 2)
THEN INSERT INTO `log_banned` (`PLR_ID`,`PLR_NAME`,`PLR_IP`,`ADM_ID`,`ADM_IP`, `DESCRIPTION`, `TIME`, `TYPE`)
VALUES (NEW.PLR_ID, (SELECT PLR_NAME FROM `plr_account` WHERE plr_account.PLR_ID = NEW.PLR_ID), NEW.PLR_IP, -1, 'none', '3 times kicked for using cheats.', NOW(), 0);
UPDATE `log_cheat` SET TRIGGERED=1 WHERE PLR_ID = NEW.PLR_ID;
END IF