]> ruin.nu Git - ndwebbie.git/blob - database/raids.sql
Remove points when unclaiming launched target
[ndwebbie.git] / database / raids.sql
1
2 /*Changes when target is unclaimed */
3 CREATE OR REPLACE FUNCTION unclaim_target()
4   RETURNS "trigger" AS
5 $BODY$
6 if ($_TD->{event} eq 'DELETE' && $_TD->{old}{launched} eq 't'){
7         my $uid = $_TD->{old}{uid};
8         my $query = spi_prepare(q{UPDATE users
9                 SET attack_points = attack_points - 1
10                 WHERE uid = $1},'int4');
11         spi_exec_prepared($query,$uid);
12         spi_freeplan($query);
13 }
14 return;
15 $BODY$  LANGUAGE 'plperl' VOLATILE;
16 ALTER FUNCTION updated_target() OWNER TO ndawn;
17
18
19 CREATE TRIGGER unclaim_target AFTER DELETE
20    ON raid_claims FOR EACH ROW
21    EXECUTE PROCEDURE PUBLIC.unclaim_target();
22