[CODE] /doommap, /revivemap & /stripmap

#1
These 3 commands can be useful for certain events that need such action.
Usage: /doommap, /revivemap, /stripmap (where your GM is standing will be the triggered map)

For stripmap command, if you want to make a map that restrict the use of equipments, you will have to do on your own =)

HGServer

Game.h

Find

Code: Select all

class CGame  
{
public:

Add

Code: Select all

// sleeq - /doommap, /revivemap & /stripmap
// useful for certain events that need such action
void AdminOrder_DoomMap(int iClientH);
void AdminOrder_ReviveMap(int iClientH);
void AdminOrder_StripMap(int iClientH);

Game.cpp

Add these functions

Code: Select all

// sleeq - /doommap, /revivemap & /stripmap
// useful for certain events that need such action
void CGame::AdminOrder_DoomMap(int iClientH)
{
 char cMapName[11];
 int i = 0, count = 0;

 strcpy(cMapName, m_pClientList[iClientH]->m_cMapName); // copy the map where the gm is standing on

	for(i = 1; i < DEF_MAXCLIENTS; i++){ // enum all clients
		if (m_pClientList[i] != NULL && m_pClientList[i]->m_iAdminUserLevel == 0) { // list all available players
			if (strcmp(m_pMapList[m_pClientList[i]->m_cMapIndex]->m_cName, cMapName) == 0) { // if the player is in the same map as gm

				if (m_pClientList[i]->m_bIsKilled == TRUE) return; // if the player is dead, do nothing

				// here we kill all players
				m_pClientList[i]->m_iHP = 0;
				m_pClientList[i]->m_bIsKilled = TRUE;

				// close exchange windows if they were doing it
				if (m_pClientList[i]->m_bIsExchangeMode == TRUE) {
					int iExH = m_pClientList[i]->m_iExchangeH;
					_ClearExchangeStatus(iExH);
					_ClearExchangeStatus(i);
				}

				// increase the count for each player triggered for result
				count++;

				// here we updates the player
				RemoveFromTarget(i, DEF_OWNERTYPE_PLAYER);
				SendNotifyMsg(NULL, i, DEF_NOTIFY_KILLED, NULL, NULL, NULL, m_pClientList[i]->m_cCharName);
				SendEventToNearClient_TypeA(i, DEF_OWNERTYPE_PLAYER, MSGID_EVENT_MOTION, DEF_OBJECTDYING, 0, NULL, NULL);
				m_pMapList[m_pClientList[i]->m_cMapIndex]->ClearOwner(12, i, DEF_OWNERTYPE_PLAYER, m_pClientList[i]->m_sX, m_pClientList[i]->m_sY);
				m_pMapList[m_pClientList[i]->m_cMapIndex]->SetDeadOwner(i, DEF_OWNERTYPE_PLAYER, m_pClientList[i]->m_sX, m_pClientList[i]->m_sY);
			}
		}
	}
	// result
	if (count == 1) wsprintf(G_cTxt, "%d player has been killed.", count);
	else wsprintf(G_cTxt, "%d players have been killed.", count);
	SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_NOTICEMSG, NULL, NULL, NULL, G_cTxt);
	return;
}

// sleeq - /doommap, /revivemap & /stripmap
// useful for certain events that need such action
void CGame::AdminOrder_ReviveMap(int iClientH)
{
 char cMapName[11];
 int i = 0, count = 0;

 strcpy(cMapName, m_pClientList[iClientH]->m_cMapName); // copy the map where the gm is standing on

	for(i = 1; i < DEF_MAXCLIENTS; i++){ // enum all clients
		if (m_pClientList[i] != NULL && m_pClientList[i]->m_iAdminUserLevel == 0) { // list all available players
			if (strcmp(m_pMapList[m_pClientList[i]->m_cMapIndex]->m_cName, cMapName) == 0) { // if the player is in the same map as gm

				if (m_pClientList[i]->m_bIsKilled == FALSE) return; // if the player is alive, do nothing

				// here we perform resurrection to players
				m_pClientList[i]->m_bIsKilled = FALSE;
				m_pClientList[i]->m_iHP = iGetMaxHP(i);
				m_pClientList[i]->m_iMP = iGetMaxMP(i);
				m_pClientList[i]->m_iSP = iGetMaxSP(i);

				// increase the count for each player triggered for result
				count++;

				// here we updates the player
				SendNotifyMsg(NULL, i, DEF_NOTIFY_HP, NULL, NULL, NULL, NULL); // updates hp
				SendNotifyMsg(NULL, i, DEF_NOTIFY_MP, NULL, NULL, NULL, NULL); // updates mp
				SendNotifyMsg(NULL, i, DEF_NOTIFY_SP, NULL, NULL, NULL, NULL); // updates sp
				SendEventToNearClient_TypeA(i, DEF_OWNERTYPE_PLAYER, MSGID_EVENT_MOTION, DEF_OBJECTDAMAGE, 0, NULL, NULL);
				m_pMapList[m_pClientList[i]->m_cMapIndex]->SetOwner(i, DEF_OWNERTYPE_PLAYER, m_pClientList[i]->m_sX, m_pClientList[i]->m_sY);
			}
		}
	}
	// result
	if (count == 1) wsprintf(G_cTxt, "%d player has been revived.", count);
	else wsprintf(G_cTxt, "%d players have been revived.", count);
	SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_NOTICEMSG, NULL, NULL, NULL, G_cTxt);
	return;
}

// sleeq - /doommap, /revivemap & /stripmap
// useful for certain events that need such action
void CGame::AdminOrder_StripMap(int iClientH)
{
 char cMapName[11];
 int i = 0, count = 0;
 short sItemIndex;

 strcpy(cMapName, m_pClientList[iClientH]->m_cMapName); // copy the map where the gm is standing on

	for(i = 1; i < DEF_MAXCLIENTS; i++){ // enum all clients
		if (m_pClientList[i] != NULL && m_pClientList[i]->m_iAdminUserLevel == 0) { // list all available players
			if (strcmp(m_pMapList[m_pClientList[i]->m_cMapIndex]->m_cName, cMapName) == 0) { // if the player is in the same map as gm

				// here we perform item checks
				for (int j = 1; j < DEF_MAXITEMEQUIPPOS; j++) { // enum all equip positions
					if (m_pClientList[i]->m_sItemEquipmentStatus[j] != NULL) { // list all equipped items
						sItemIndex = m_pClientList[i]->m_sItemEquipmentStatus[j];

						// now we strip all them
						ReleaseItemHandler(i, m_pClientList[i]->m_sItemEquipmentStatus[j], TRUE);

						// updates the player about the stripped item
						if ((sItemIndex != -1) && (m_pClientList[i]->m_pItemList[sItemIndex] != NULL))
							SendNotifyMsg(NULL, i, DEF_NOTIFY_ITEMRELEASED, m_pClientList[i]->m_pItemList[sItemIndex]->m_cEquipPos, sItemIndex, NULL, NULL);
					}
				}
				// increase the count for each player triggered for result
				count++;
			}
		}
	}
	// result
	if (count == 1) wsprintf(G_cTxt, "%d player has been stripped.", count);
	else wsprintf(G_cTxt, "%d players have been stripped.", count);
	SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_NOTICEMSG, NULL, NULL, NULL, G_cTxt);
	return;
}

Find

Code: Select all

case '/':
ZeroMemory(cBuffer, sizeof(cBuffer));
memcpy(cBuffer, cp, dwMsgSize - 21);
cp = (char *)(cBuffer);

Add these

Code: Select all

// sleeq - /doommap, /revivemap & /stripmap
// useful for certain events that need such action
if (memcmp(cp, "/doommap", 8) == 0) {
	if (m_pClientList[iClientH] == NULL) return;
	if(m_pClientList[iClientH]->m_iAdminUserLevel > 2) AdminOrder_DoomMap(iClientH);
	else SendNotifyMsg (NULL, iClientH, DEF_NOTIFY_ADMINUSERLEVELLOW, NULL, NULL, NULL, NULL);
	return; 
}
if (memcmp(cp, "/revivemap", 10) == 0) {
	if (m_pClientList[iClientH] == NULL) return;
	if(m_pClientList[iClientH]->m_iAdminUserLevel > 2) AdminOrder_ReviveMap(iClientH);
	else SendNotifyMsg (NULL, iClientH, DEF_NOTIFY_ADMINUSERLEVELLOW, NULL, NULL, NULL, NULL);
	return; 
}
if (memcmp(cp, "/stripmap", 9) == 0) {
	if (m_pClientList[iClientH] == NULL) return;
	if(m_pClientList[iClientH]->m_iAdminUserLevel > 2) AdminOrder_StripMap(iClientH);
	else SendNotifyMsg (NULL, iClientH, DEF_NOTIFY_ADMINUSERLEVELLOW, NULL, NULL, NULL, NULL);
	return; 
}
https://www.youtube.com/channel/UCre_Jw ... -k6CHUsWAw
More videos: http://fb.com/helbreath/videos/
My github: https://github.com/sleeqeels/Helbreath-800x600

Who is online

Users browsing this forum: No registered users and 1 guest

cron