-
Posts
76 -
Joined
-
Last visited
-
Days Won
3 -
Feedback
0%
Content Type
Forums
Store
Third Party - Providers Directory
Feature Plan
Release Notes
Docs
Events
Posts posted by serex
-
-
I want the skill to be on self.
Yep I know that I should change it on clientside but where exactly?
-
The bug is only visual because the damage is done correctly in the right area not in the target, anyone knows how can I fix this?
-
En 29/3/2019 a las 22:46, VegaS™ dijo:
The idea isn't bad (even if we're in 2019 and can be bypassed very easy and have no effects this), but there's some things which can be written in C++11 and a better structure, since your map have empty list initialization (since C++11).
Here's some advices which can help you in future, maybe.
- Your map have as value type a another std::map, for what? Since you store in key and value the same thing (player id), you should use std::list / std::vector or anything you want, but not a another std::map for no-reason if your key is same as value and no possible changes.
- You insert all time for each login in a x map the player id, you don't check if already exist and then insert it (you could use std::find/std::map::find), you use make_pair for map and that means the key can't be duplicated, but this isn't a good practice to trying to insert 1000 times and nothing happen.
- You check if map size is smaller or equal than 0, how can be a map size < 0?
-
You declared a another map for iterating in a for-loop, you don't need to do that.
std::map<DWORD, DWORD> map_players = [....]; - You use map.at(...), if you use this you should use the std::out_of_range too, otherwise have no sense, because you already did a check before if exist mapIndex by map.count(index), so you can use directly operator std::map::operator[] instead of std::map::at.
- You declared a std::string with no-reason for GetHostName() -> return a const char *, which you can use strcmp(str1, str2) instead of string.compare(str2).
- Your key of map should be as constant, because you don't want to change it.
- You should use also #pragma once for your header file (including: less code, avoidance of name clashes, and sometimes improvement in compilation speed.)
- You should remove the pid of player after disconnect of the map, have no sense to remain.
PS: If i were in your place, i didn't do the structure like this, it's a bit messed up.
Here's some of things what i said. (didn't tested)
- map_manager.h
#pragma once class MapManager: public singleton<MapManager> { private: std::map<const DWORD, std::list<const DWORD>> m_map_manager = { { 181, {} }, { 182, {} }, { 183, {} } }; public: const bool Initialize(); void Clear(); void Destroy(); void Enter(const LPCHARACTER ch); void Disconnect(const LPCHARACTER ch); const size_t GetIPMapCount(const DWORD dwMapIndex); const bool IsPlayerIPInMap(const LPCHARACTER ch); const bool IsUniqueIPMap(const DWORD dwMapIndex); };
- map_manager.cpp
#include "stdafx.h" #include "buffer_manager.h" #include "char.h" #include "char_manager.h" #include "map_manager.h" #include "desc.h" void MapManager::Initialize() { Clear(); } void MapManager::Destroy() { Clear(); } // Removes all elements from the map container (which are destroyed), leaving the container with a size of 0. void MapManager::Clear() { for (auto iter = m_map_manager.begin(); iter != m_map_manager.end(); ++iter) iter->second.clear(); } // Count elements with a specific key, return 1 (if the element is found) or zero (otherwise). const bool MapManager::IsUniqueIPMap(const DWORD dwMapIndex) { return m_map_manager.count(dwMapIndex) != 0; } // Returns the number of elements in the map container. const size_t MapManager::GetIPMapCount(const DWORD dwMapIndex) { return (m_map_manager[dwMapIndex]).size(); } /* char.cpp : #include "map_manager.h" marriage::CManager::instance().Logout(this); + MapManager::instance().Disconnect(this); */ void MapManager::Disconnect(const LPCHARACTER ch) { if (!ch) return; const DWORD dwMapIndex = ch->GetMapIndex(); if (!IsUniqueIPMap(dwMapIndex)) return; // Remove the player id from map list if exist. const auto it = std::find(m_map_manager[dwMapIndex].begin(), m_map_manager[dwMapIndex].end(), ch->GetPlayerID()); if (it != m_map_manager[dwMapIndex].end()) m_map_manager[dwMapIndex].erase(it); } void MapManager::Enter(const LPCHARACTER ch) { if (!ch) return; const DWORD dwPID = ch->GetPlayerID(); const DWORD dwMapIndex = ch->GetMapIndex(); if (!IsUniqueIPMap(dwMapIndex)) return; // Return iterator to the first element satisfying the condition or last if no such element is found. const auto it = std::find(m_map_manager[dwMapIndex].begin(), m_map_manager[dwMapIndex].end(), dwPID); // If no element is found in the map, find() returns map.end(). if (it != m_map_manager[dwMapIndex].end()) return; // Add the player id into map list. m_map_manager[dwMapIndex].emplace_back(dwPID); } const bool MapManager::IsPlayerIPInMap(const LPCHARACTER ch) { if (!ch) return false; if (!IsUniqueIPMap(ch->GetMapIndex())) return false; if (GetIPMapCount() == 0) return false; LPCHARACTER pkChar = NULL; // Range-based for loop, iterating the std::list with player pids. for (const auto dwPID : m_map_manager[ch->GetMapIndex()]) { if (!(pkChar = CHARACTER_MANAGER::instance().FindByPID(dwPID))) continue; if (!strcmp(ch->GetDesc()->GetHostName(), pkChar->GetDesc()->GetHostName()) && ch->GetPlayerID() != pkChar->GetPlayerID()) return true; } return false; }
BTW: Sorry for my english skills.
Thanks for your tips, I will keep improving
- 1
-
M2 Download Center
( Internal )
( GitHub )
If you want to allow only one player per IP in certain maps you can use this
Example of usage:
when login with pc.is_pc_ip_in_map() begin chat("En este mapa solo puede entrar 1 personaje por IP, serás transportado en 5 segundos.") warp_to_village() end
For add/remove maps, just edit:
std::map<DWORD, std::map<DWORD, DWORD>> maps = { { 181, {} }, { 182, {} }, { 183, {} } };
In map_manager.h
Implementation:
Enjoy
- 43
- 1
- 1
- 13
- 1
- 16
-
-
Hello devs,
If you are in a party doing a dungeon and you get disconnected or your game crash, there is any possible way of come back to that dungeon with your party after reconnect?
-
Dead img.
Can you reupload pls?
-
-
hace 5 horas, Tunga dijo:
Please check the PORT_SECURITY working properly.
where can I check that?
-
Update:
At the beginning everything is working, but when the players start to enter and play it suddenly stop working:
PM and shout.
-
Hello I don't know why the players from my server can't communicate between channels:
Example:
Im in channel 1: so I don't see people shouting on other CHs, and if I try to send PM to people in ch2 or ch3 it says that they are offline.
Any idea of why can it happens?
-
Working! Thanks!
- 1
-
upload bt full
-
Hi I dont know why this is happening with some quests:
This is normal.
But when I close it, I still have this:
Any idea?
No sysser errors.
-
En 19/1/2019 a las 17:47, Zeph dijo:
Hello bro, i don't have "ComputeSkillParty" function in my source so.. can you give me this?
I changed this to "ComputeSkill" but i can buff only on 2 players on group.
struct FComputeSkillParty { FComputeSkillParty(DWORD dwVnum, LPCHARACTER pkAttacker, BYTE bSkillLevel = 0) : m_dwVnum(dwVnum), m_pkAttacker(pkAttacker), m_bSkillLevel(bSkillLevel) { } void operator () (LPCHARACTER ch) { m_pkAttacker->ComputeSkill(m_dwVnum, ch, m_bSkillLevel); } DWORD m_dwVnum; LPCHARACTER m_pkAttacker; BYTE m_bSkillLevel; }; int CHARACTER::ComputeSkillParty(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel) { FComputeSkillParty f(dwVnum, pkVictim, bSkillLevel); if (GetParty() && GetParty()->GetNearMemberCount()) GetParty()->ForEachNearMember(f); else f(this); return BATTLE_NONE; }
-
Awesome, thanks for this amazing fix
-
char_skill.cpp search:
if (IS_SET(pkSk->dwFlag, SKILL_FLAG_SELFONLY)) ComputeSkill(dwVnum, this);
add before:
//Party buff system if (GetParty() && (dwVnum == 94 || dwVnum == 95 || dwVnum == 96 || dwVnum == 110 || dwVnum == 111)) { if (pkVictim->GetParty()){ if (pkVictim->GetParty() == GetParty()){ ComputeSkillParty(dwVnum, this); } } }
- 97
- 2
- 1
- 1
- 1
- 1
- 1
- 30
- 3
- 59
-
We can use CTRL+H for unmount/mount horse, but when we are riding a costume mount, we get an error if we try to use CTRL+H. So if you wanna be able to use it just follow this guide:
cmd_general.cpp Go to function ACMD(do_user_horse_ride) Replace the if block (ch->GetMountVnum()) With this code: if (ch->GetMountVnum()) { LPITEM item = ch->GetWear(WEAR_COSTUME_MOUNT); if (item && item->IsRideItem()) ch->UnequipItem(item); if (ch->UnEquipSpecialRideUniqueItem()) { ch->RemoveAffect(AFFECT_MOUNT); ch->RemoveAffect(AFFECT_MOUNT_BONUS); } //ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ÀÌ¹Ì Å»°ÍÀ» ÀÌ¿ëÁßÀÔ´Ï´Ù.")); return; }
- 3
-
reupload? link down.
-
Can anyone reupload this pls?
-
i have the same error, any fix?
-
#bump
-
Hi guys Im going to explain a promo of one crypto exchange where you can win ~150$ in tokens (cryptocoins).
You need:
- Telegram
- Twitter
- EmailSteps to follow:
- First, create one account here:
https://www.satoexchange.com/register/
- Confirm your account via email.
- Go to the website, log in, and go to the section MYACCOUNT, there you will see a tweet button.
- Click in the button and tweet the stuff (you have to be logged in Twitter).
- Wait 5-10 min and you will see in the same section a code like this:
- Open telegram and enter in this group: https://t.me/satoexchange_official
- Paste the code in the group chat.
And... wala!! You have 1000 tokens of SATX! You will can exchange those tokens for bitcoins or other coins from 1st of August.
-
Wow! Awesome map! Thanks for share!
Revive Event Quest
in Quest Functions & Features
Posted
M2 Download Center
Revive event for use in quests like when kill, when login...
The event is triggered when the player revive.
Example of usage:
when revive begin chat("Hello metin2dev.") end