Page MenuHomeRealLifeRPG

Gang HQ Update SQL
GeschlossenPublic

Description

alter table gangs
	add hq tinyint default 0 null after points_total;

alter table gangs drop column short_name;
alter table gangs drop column max_members;

create
    definer = dbadmin@`localhost` procedure evt_resetGangPoints()
BEGIN
    UPDATE gangs SET hq=0 WHERE hq <> 0;
    UPDATE gangs SET hq=1 WHERE disabled=0 ORDER BY points_current DESC LIMIT 1;
    UPDATE gangs SET points_current = ((SELECT Count(gang_member.id) FROM gang_member WHERE gang_id=gangs.id AND gang_member.disabled=0) * 100) WHERE gangs.disabled=0;
    UPDATE gangs SET points_current = 0 WHERE points_disabled=1;
    UPDATE gangs SET points_current = 1000 WHERE points_current > 1000;
    UPDATE gangs SET points_current = ROUND(points_current*0.5) WHERE hq=1;
END;

create definer = dbadmin@localhost event LogMarket on schedule
    every '3' DAY 
        starts '2019-26-06 03:00:00'
    enable
    do
    CALL evt_resetGangPoints();

Event Timeline

vabene1111 created this object in space S4 Public.
vabene1111 updated the task description. (Show Details)
vabene1111 raised the priority of this task from Normal to Kritisch.Jun 25 2019, 9:29 PM
vabene1111 claimed this task.