Help in finding players in certain zone

Okay i have a script and a function that is called something like “EndBattle”

In that function i would like to search for players in a certain zone and give them a certain item.

I’ve been trying to find the function in other’s sources of trinitycore but with no luck. Any Suggestions?

/who zonename


not in game … -.-

something like this?

select * from characters where zone='ZONE_ID'

You could do, for example:

#include “Map.h”

if (Map* map = sMapMgr->FindMap(MAP_ID, 0))
PlayerList players = map->GetPlayers();
for (PlayerList::iterator itr = players.begin(); itr != players.end(); itr++)
if (itr->getSource()->GetZoneId() == ZONE_ID)
// itr->getSource() (player) is in yout zone

MAP_ID is the continent where ZONE_ID is.
Not sure about PlayerList, if not compiling, change for MapRefManager and include MapRefManager.h
This can cause huge diff if not used wisely and correctly.

A better solution would be to do a ZoneScript and each time OnPlayerEnterZone gets called you push the GUID to a std::list/std::map (GuidSet) and when OnPlayerLeaveZone you just remove it, so you would have them all saved and could get the players by calling ObjectAccessor::FindPlayer(guid)

if you want to do this in php, then you will have to write like small query in mysql to get zones of online players, then you will be able to give them presents.

First of all, you can use query like Zze said:

select * from characters where zone='ZONE_ID’Then, you will have to write script to handle your needs:

if ($playerzone == zone_number) { //piece of code to give presents } else { //brackets without data will just do nothing, but they still needed }

could also make use of a switch/case statment if theres more then one zone you want to trigger, and specific triggers. However I dont think OP was talking about php. /emoticons/default_wacko.png

no i’m looking for the function in c++

exactly what i was looking for! many thanks