Hm I don't understand the part where you need to save the kill .
Pvp kills are easy to store cause they are saved in chars table but there is nothing for the pve.
Hmm, Not sure if its a good idea to store the kills in DB.
Sure it will persist through restart then, but I suggest you will look into storing the data in C++ containers and variables instead.
You can then move onto saving to DB afterwards. It should be easy to implement on top of the map with OnSave hook.
In C++ map there are key and value.
For this purpose the key could be uint32 for the key and uint32 for the value. so that is player guid pointing to the kill count.
We will use unordered map instead of map, since it should be faster for lookup, and we wont need looping through the map.
std::unordered_map<uint32, uint32> myMap;
Simple example:
Code:
std::unordered_map<uint32, uint32> myMap;
myMap[10] = 5;
printf("%u\n", myMap[9]); // prints 0
printf("%u\n", myMap[10]); // prints 5
You can access a map element with the [] operator.
So for example if you need the kill count for a player, you can do
printf("%u\n", myMap[player->GetGUIDLow()]);
This will print the amount of kills saved for the player to the console.
If an element doesnt exist for the key used in [], an element is created. For uint32 and other integers the default value is 0.
Check out the site and the links I posted earlier for the map.
The site contains information examples of how to use each function and operator for map.
It is possible that there is a counter for overall creature kills, but that is true only if wow has an achievement for creature kills or some function like the player counter for pvp lifetime kills.