Jump to content
  • 0

Keep Zombie kills on death


Phone_Guy

Question

So I have seen triggers to keep items on death but still need some help with this concept. I want my players to keep zombie kills on death. This was the total number of zombies killed can be used to gauge users experience level. Just need to know where to start.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

in your SQL character_data table there is a field called "KillZ" you will have to transfer that to the new character via SQL trigger to the newly created character

 

This trigger will update all created objects by the dead character to the new character ID (i just removed some code that would confuse so don't use it as is to update your own build objects), you might be able to use some thing from it. But don't ask me how it works... i'm not a SQL guy :) Like i get why and how it works, but have no clue how to rewrite it to your need

DELIMITER ;
DROP TRIGGER IF EXISTS epoch_srv_2.`update_owner`;
DELIMITER //
CREATE TRIGGER epoch_srv_2.`update_owner`
AFTER INSERT ON epoch_srv_2.character_data
FOR EACH ROW
BEGIN
    UPDATE epoch_srv_2.object_data SET CharacterID = NEW.CharacterID WHERE CharacterID IN (SELECT CharacterID FROM character_data WHERE PlayerUID = NEW.PlayerUID);
END//
DELIMITER ;

http://dev.mysql.com/doc/refman/5.6/en/trigger-syntax.html

https://dev.mysql.com/doc/refman/5.0/en/example-maximum-column.html

 

Had a little idea, and have no clue if it will work at all

DELIMITER ;
DROP TRIGGER IF EXISTS Your_Epoch_Database.`update_zkills`;
DELIMITER //
CREATE TRIGGER Your_Epoch_Database.`update_zkills`
AFTER INSERT ON Your_Epoch_Database.character_data
FOR EACH ROW
BEGIN
    UPDATE Your_Epoch_Database.character_data SET KillZ = (SELECT MAX(KillZ) AS KillZ FROM character_data WHERE PlayerUID = NEW.PlayerUID) WHERE CharacterID = NEW.CharacterID;
END//
DELIMITER ;

Remember to change "Your_Epoch_Database" and do a backup FIRST :D

Link to comment
Share on other sites

  • 0

Thank you for the reply. I discovered when working with this code that my server host doesn't allow stored functions. It throws a fit when I try to create the trigger. My only other thought is something script related. While digging a while back I seen a section that had code related to on player death. If the scripts send the signal to the database to reset the data, would there be a way script wise to stall that function?

Link to comment
Share on other sites

  • 0

it don't even allow triggers?? i would contact them then. try this code as i know there is no errors in that so it hould create a trigger

DELIMITER ;
DROP TRIGGER IF EXISTS CHANGE_ME.`update_owner`;
DELIMITER //
CREATE TRIGGER CHANGE_ME.`update_owner`
AFTER INSERT ON CHANGE_ME.character_data
FOR EACH ROW
BEGIN
    UPDATE CHANGE_ME.object_data SET CharacterID = NEW.CharacterID WHERE CharacterID IN (SELECT CharacterID FROM character_data WHERE PlayerUID = NEW.PlayerUID);
END//
DELIMITER ;

CHANGE_ME need to be your table name

 

Check if character_data in your table is character_data or Character_DATA (same for object_data) and change the script accordingly before running this code as a query (don't change the "NEW.")

 

if that doesn't throw you an error they allow triggers and then you should run

 

DROP TRIGGER IF EXISTS CHANGE_ME.`update_owner`;

 

to delete the trigger again

 

Remember to do this while your server is shut down and you have a SQL backup

 

If it give you an error copy the text and post it here

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...