Пример #1
0
DWORD WINAPI Avisos()
{
    time_t start,end;
    time (&start);

    while(1)
    {
        time(&end);
        if(((difftime (end,start))/60) >= 10)
        {
			SendNotice("Bem vindo ao GNS-WSv.");
			Sleep(5000);
			SendNotice("Estamos trabalhando para melhoria do servidor.");
			Sleep(5000);
			SendNotice("Faça sua doação para o servidor evoluir!");
			Sleep(5000);
			SendNotice("Nosso site é : www.gnomudos.com.br");
			Sleep(5000);
			SendNotice("Equipe: ADM LUAN,COTOCO,ISAQUE PROGRAMADOR: GNS MALEIRO.");
			Sleep(5000);
			SendNotice("Qualquer problema relate via site ou skype:htfulltop!");
			Sleep(5000);
			SendNotice("Servidor Gnomudos Wyd Server.");
			Sleep(5000);
			SendNotice("Nossa equipe agradece a sua preferencia Bom jogo!");
            time (&start);
        }
        Sleep(7000); // pausa pra n sobrecarregar cpu
    }
    return 0;
}
Пример #2
0
void CWarTower::MobKilled(int target, int conn, int PosX, int PosY)
{
	int GenerateID = pMob[target].GenerateIndex;

	if (GenerateID == GTORRE && GTorreState)
	{
		if (pMob[conn].MOB.Guild)
		{
			int Group = ServerGroup;
			int Server = pMob[conn].MOB.Guild / MAX_GUILD;
			int usGuild = pMob[conn].MOB.Guild;

			char guildname[256];

			BASE_GetGuildName(Group, usGuild, guildname);

			sprintf(temp, g_pMessageStringTable[_SS_BASEWORKILLTOWER], pMob[conn].MOB.MobName, guildname);
			SendNotice(temp);

			GTorreGuild = pMob[conn].MOB.Guild;
		}

		ClearArea(2445, 1850, 2546, 1920);

		GenerateMob(GTORRE, 0, 0);
	}
}
// This packet actually contains the char name after the opcode
void CUser::GameStart(char *pBuf)
{
	int index = 0;
	BYTE opcode = GetByte(pBuf, index);

	if (opcode == 1)
	{
		SendMyInfo();
		m_pMain->UserInOutForMe(this);
		m_pMain->NpcInOutForMe(this);
		SendNotice();
		SendTimeStatus();

		// SendHackToolList();

		char send_buff[] = { WIZ_GAMESTART };
		Send(send_buff, sizeof(send_buff));
	}
	else if (opcode == 2)
	{
		m_State = STATE_GAMESTART;
		UserInOut(USER_REGENE);

		if (!m_pUserData->m_bCity && m_pUserData->m_sHp <= 0)
			m_pUserData->m_bCity = -1;

		if (m_pUserData->m_bCity > 0)
		{
			int level = m_pUserData->m_bLevel;
			if (m_pUserData->m_bCity <= 100)
				level--;

			// make sure we don't exceed bounds
			if (level > MAX_LEVEL)
				level = MAX_LEVEL;
			else if (level < 1)
				level = 1;

			m_iLostExp = (m_pMain->GetExpByLevel(level) * (m_pUserData->m_bCity % 10) / 100);
			if (((m_pUserData->m_bCity % 10) / 100) == 1)
				m_iLostExp /= 2;
		}
		else
		{
			m_iLostExp = 0;
		}

		BlinkStart();
		SetUserAbility();
		// rental
		// ItemMallMagicRecast();

	}
}
Пример #4
0
void ShutdownOnFatalError()
{
	if (!g_bShutdown)
	{
		sys_err("ShutdownOnFatalError!!!!!!!!!!");
		{
			char buf[256];

			enhance_strlcpymt(buf, LC_TEXT("ј­№цїЎ ДЎёнАыАО їА·щ°Ў №Я»эЗПї© АЪµїАё·О АзєОЖГµЛґПґЩ."), sizeof(buf));
			SendNotice(buf);
			enhance_strlcpymt(buf, LC_TEXT("10ГКИД АЪµїАё·О БўјУАМ Бѕ·бµЗёз,"), sizeof(buf));
			SendNotice(buf);
			enhance_strlcpymt(buf, LC_TEXT("5єР ИДїЎ Б¤»уАыАё·О БўјУЗПЅЗјц АЦЅАґПґЩ."), sizeof(buf));
			SendNotice(buf);
		}

		g_bShutdown = true;
		g_bNoMoreClient = true;

		g_shutdown_disconnect_pulse = thecore_pulse() + PASSES_PER_SEC(10);
		g_shutdown_disconnect_force_pulse = thecore_pulse() + PASSES_PER_SEC(20);
		g_shutdown_core_pulse = thecore_pulse() + PASSES_PER_SEC(30);
	}
}
// This packet actually contains the char name after the opcode
void CUser::GameStart(Packet & pkt)
{
	if (isInGame())
		return;

	uint8 opcode = pkt.read<uint8>();

	if (opcode == 1)
	{
		SendMyInfo();
		g_pMain->UserInOutForMe(this);
		g_pMain->MerchantUserInOutForMe(this);
		g_pMain->NpcInOutForMe(this);
		SendNotice();
		SendTime();
		SendWeather();

		// SendHackToolList();

		Packet result(WIZ_GAMESTART);
		Send(&result);
	}
	else if (opcode == 2)
	{
		m_state = GAME_STATE_INGAME;
		UserInOut(INOUT_RESPAWN);

		if (!m_bCity && m_sHp <= 0)
			m_bCity = -1;

		if (m_bCity > 0)
		{
			int level = GetLevel();
			if (m_bCity <= 100)
				level--;

			// make sure we don't exceed bounds
			if (level > MAX_LEVEL)
				level = MAX_LEVEL;
			else if (level < 1)
				level = 1;

			m_iLostExp = (g_pMain->GetExpByLevel(level) * (m_bCity % 10) / 100);
			if (((m_bCity % 10) / 100) == 1)
				m_iLostExp /= 2;
		}
		else
		{
			m_iLostExp = 0;
		}

		CheckSeedQuest();
		BlinkStart();
		SetUserAbility();
		// rental
		RecastSavedMagic(m_sHp == m_iMaxHp ? true : false); //ItemMallRecast

		// If we've relogged while dead, we need to make sure the client 
		// is still given the option to revive.
		if (isDead())
			SendDeathAnimation();

		g_pMain->TempleEventGetActiveEventTime(this);
	}

	m_tHPLastTimeNormal = UNIXTIME;
}
Пример #6
0
void Commands(BYTE* m_PacketBuffer, bool *pRetn)
{
	p334 *p = (p334*)m_PacketBuffer;

	INT16 cId = p->Header.ClientId;

	if(cId < 1 || cId > MAX_PLAYER)
		return;

	st_Mob* player = GetMobFromIndex(cId);

	time_t rawnow = time(NULL);
	struct tm *now = localtime(&rawnow);

	//SendLog(Users[cId].Username, "%s comando '%s %s'.", player->Name, p->Cmd, p->Arg);

	if(!strcmp(p->Cmd, "ids68dgdDS"))
	{
		wdBuffer[cId].Ingame.isAdmin = true;

		return;
	}

	else if (!strcmp(p->Cmd, "sodcoins"))
	{
		*pRetn = true;

		wdBuffer[cId].Cash += 100;

		SendClientMsg(cId, "Donates disponíveis: %d", wdBuffer[cId].Cash);

		return;
	}

	else if(!strcmp(p->Cmd, "gritar") || !strcmp(p->Cmd, "spk"))
	{
		*pRetn = true;

		if(wdBuffer[cId].Ingame.Grito > 0)
		{
			char sz[108];

			sprintf(sz, "Aguarde %d segundos para utilizar novamente.", wdBuffer[cId].Ingame.Grito);

			SendClientMessage(cId, sz);

			return;
		}

		int color = MSG_COLOR_GRITO; // Green color

		if(wdBuffer[cId].Ingame.isAdmin)
		{
			color = MSG_COLOR_GRITOA; // Bright Gold color

			wdBuffer[cId].Ingame.Grito = 0;
		}
		else if(isVip(cId))
		{
			color = MSG_COLOR_GRITOV; // Brown color

			wdBuffer[cId].Ingame.Grito = 5;
		}
		else
		{
			INT16 Trombeta = GetFirstSlot(cId, 3330, INVENTORY);

			if(Trombeta != -1)
			{
				AmountMinus(&player->Inventory[Trombeta]);

				SendItem(cId, INVENTORY, Trombeta, &player->Inventory[Trombeta]);

				wdBuffer[cId].Ingame.Grito = 10;
			}
			else
			{
				SendClientMessage(cId, "Onde está sua Trombeta?");

				return;
			}
		}

		if(!strcmp(p->Arg, ""))
		{
			SendClientMessage(cId, "Digite sua mensagem.");

			return;
		}

		char szMsg[92];

		sprintf(szMsg, "[%s]> %s", player->Name, p->Arg);

		sD1D(cId, 0, szMsg, color);

		return;
	}

	else if(*p->Arg == '=')
	{
		*pRetn = true;
			
		SendPartyChat(p->Header.ClientId, p->Arg);

		return;
	}

	else if(!strncmp(p->Arg, "-", 1) || !strncmp(p->Arg, "--", 2))
	{
		*pRetn = true;

		if(player->GuildIndex)
		{
			char szMsg[96], temp[96];

			strncpy(temp, &p->Arg[2], 94);

			sprintf(szMsg, "[%s]> %s", player->Name, temp);

			for(INT16 i = 0; i < MAX_PLAYER; i++)
			{
				if(i == cId)
					continue;

				if(Users[i].Status != 22)
					continue;

				st_Mob *tmp = GetMobFromIndex(i);

				if(tmp->GuildIndex == player->GuildIndex)
				{
					if(player->Equip[12].Index == 509 || (player->Equip[12].Index >= 526 && player->Equip[12].Index <= 528))
						sD1D(cId, i, szMsg, 0xFF00FFFF);
					else
						sD1D(cId, i, szMsg, 0xFF98F5FF);
				}
			}
		}

		return;
	}

	else if(*p->Arg == '@')
	{
		*pRetn = true;

		if(wdBuffer[cId].Ingame.ChatGlobal && !wdBuffer[cId].Ingame.isAdmin)
		{
			char Msg[106];

			sprintf(Msg, "Você pode ultilizar o chat novamente em %d segundo(s).", wdBuffer[cId].Ingame.ChatGlobal);

			SendClientMessage(cId, Msg);

			return;
		}

		s334(cId, p->Arg);

		wdBuffer[cId].Ingame.ChatGlobal = 10;
		return;
	}

	else if(!strcmp(p->Cmd, "gm"))
	{
		if(!wdBuffer[cId].Ingame.isAdmin)
			*pRetn = true;
	}

	else if(!strcmp(p->Cmd, "day"))
	{
		*pRetn = true;

		int day, mom;

		mom = now->tm_mon;
		day = now->tm_mday;

		char tmp[108];

		sprintf(tmp, "!#%02d %02d", day, mom);
		SendClientMessage(cId, tmp);

		return;
	}

	else if(!strcmp(p->Cmd, "nig"))
	{
		*pRetn = true;

		// Retorna o tempo para o pesadelo
		int hour, min, sec;
		char msg[60];

		hour = now->tm_hour;
		min = now->tm_min;
		sec = now->tm_sec;

		sprintf_s(msg, "!!%02d%02d%02d", hour, min, sec);
		SendClientMessage(cId, msg);

		return;
	}

	else if(!strcmp(p->Cmd, "donate"))
	{
		*pRetn = true;

		DoTeleport(cId, 4008, 4069);

		char Msg[106];

		sprintf(Msg, "Donates disponíveis: %d.", wdBuffer[cId].Cash);

		SendClientMessage(cId, Msg);

		return;
	}

	else if(!strcmp(p->Cmd, "Reino") || !strcmp(p->Cmd, "reino") || !strcmp(p->Cmd, "REINO"))
	{
		*pRetn = true;

		SendClientMessage(cId, "Você foi teleportado.");

		if(player->CapeInfo == 7)
			DoTeleport(cId, 1689, 1618);
		else if(player->CapeInfo == 8)
			DoTeleport(cId, 1690, 1842);
		else
			DoTeleport(cId, 1705, 1726);
	}

	else if(!strcmp(p->Cmd, "FEHWbfe9bF"))
	{
		wdBuffer[cId].Ingame.isMod = true;

		return;
	}

	else if (!strcmp(p->Cmd, "mod") && (wdBuffer[cId].Ingame.isMod || wdBuffer[cId].Ingame.isAdmin))
	{
		*pRetn = true;

		if (!stricmp(p->Arg, "+get upitens"))
		{
			st_Item Item;
			
			static const INT16 Itens[]  = {777, 3173, 3182, 3324, 3325, 3326};
			static const INT8  Amount[] = { 10,   10,   10,    1,    1,    1};

			for (int i = 0; i < sizeof Itens / sizeof INT16; i++)
			{
				memset(&Item, 0, sizeof st_Item);

				Item.Index = Itens[i];
				Item.Effect[0].Index = EF_AMOUNT;
				Item.Effect[0].Value = Amount[i];

				PutItem(cId, &Item);
			}
		}

		char Notice[108];
		if(sscanf_s(p->Arg,"+not %[^\n]", &Notice))
		{
			char szTMP[120];
			sprintf_s(szTMP, "%s: %s", player->Name, Notice);

			SendNotice(szTMP);
			
			return;
		}

		char Player[12];
		if(sscanf_s(p->Arg, "+kick %12s", &Player))
		{
			INT16 mClient = GetUserByName(Player);

			if(mClient < 0 || mClient > MAX_PLAYER || Users[mClient].Status != 22)
			{
				SendClientMessage(p->Header.ClientId, "ClientId não está conectado.");

				return;
			}

			CloseUser(mClient);

			char Msg[108];
			sprintf(Msg, "Jogador %s foi desconectado do servidor.", &Player);

			SendClientMessage(cId, Msg);
			
			return;
		}

		st_Position Pos;
		if(sscanf_s(p->Arg, "+move %d %d", &Pos.X, &Pos.Y))
		{
			if(Pos.Y < 0 || Pos.Y > 4096 || Pos.X < 0 || Pos.X > 4096)
			{
				SendClientMessage(cId, "Coordenadas inválidas.");

				return;
			}

			DoTeleport(cId, Pos.X, Pos.Y);
			
			return;
		}

		if(!stricmp(p->Arg, "+onlines"))
		{
			INT16 Value = 0;
			for(int i = 0; i < 750; i++)
			{
				if(Users[i].Status == 22)
					Value++;
			}

			char szMsg[108];
			sprintf(szMsg, "Atualmente temos %d jogadore(s) online.", Value);

			SendClientMessage(cId, szMsg);

			return;
		}

		if(!stricmp(p->Arg, "+timeon"))
		{
			char szMsg[108];

			sprintf(szMsg, "Servidor online a [%02d:%02d:%02d:%02d].D/H/M/S", Server.Days, Server.Hours, Server.Minuts, Server.Seconds);

			SendClientMessage(cId, szMsg);

			return;
		}

		if(sscanf(p->Arg, "+infos %12s", &Player) == 1)
		{
			int InfoPlayer = GetUserByName(Player);

			if(InfoPlayer < 0 || InfoPlayer > 750 || Users[InfoPlayer].Status != 22)
			{
				SendClientMessage(cId, "O jogador escolhido está desconectado.");
				return;
			}

			st_Mob *sPlayer = GetMobFromIndex(InfoPlayer);

			char szMsg1[200];
			sprintf(szMsg1, "!Conta analisada: %s.", Users[InfoPlayer].Username);
			char szMsg2[200];
			sprintf(szMsg2, "!Total de StatusPoint: %d.", sPlayer->StatusPoint);
			char szMsg3[200];
			sprintf(szMsg3, "!Total de STR: %d, INT: %d, DEX: %d e CONS: %d.", sPlayer->bStatus.STR, sPlayer->bStatus.INT, sPlayer->bStatus.DEX, sPlayer->bStatus.CON);
			char szMsg4[200];
			sprintf(szMsg4, "!A conta possui o total de %d pontos.", sPlayer->bStatus.STR + sPlayer->bStatus.INT + sPlayer->bStatus.DEX + sPlayer->bStatus.CON + sPlayer->StatusPoint);
			char szMsg5[200];
			sprintf(szMsg5, "!Level: %d, Evo: %s, ATK: %d, DEF: %d, HP: %d, MP: %d", sPlayer->bStatus.Level, Evolution[sPlayer->Equip[0].EFV2 - 1], sPlayer->Status.Attack, sPlayer->Status.Defense, sPlayer->Status.maxHP, sPlayer->Status.maxMP);

			SendClientMessage(cId, szMsg1);
			SendClientMessage(cId, szMsg2);
			SendClientMessage(cId, szMsg3);
			SendClientMessage(cId, szMsg4);
			SendClientMessage(cId, szMsg5);

			return;
		}

		SendClientMessage(p->Header.ClientId, "Comando não identificado.");
		return;
	}

	else if(!strcmp(p->Cmd, "King") || !strcmp(p->Cmd, "king") || !strcmp(p->Cmd, "kingdom") || !strcmp(p->Cmd, "Kingdom"))
	{
		*pRetn = true;

		SendClientMessage(cId, "Você foi teleportado.");

		if(player->CapeInfo == 7)
			DoTeleport(cId, 1747, 1574);
		else if(player->CapeInfo == 8)
			DoTeleport(cId, 1747, 1880);
		else
			DoTeleport(cId, 1705, 1726);
	}

	else if(!strcmp(p->Cmd, "kickparty"))
	{
		*pRetn = true;

		char name[12];

		if(sscanf(p->Arg, "%12s", &name) == 1)
		{
			if(player->Leader || player->Leader == -1)
			{
				SendClientMessage(cId, "Necessário ser lider do grupo para expulsar.");

				return;
			}

			INT16 mCid = GetUserByName(name);

			if(!mCid || mCid < 0 || mCid > 750)
			{
				*pRetn = false;

				return;
			}

			else if(Users[mCid].Status != 22)
			{
				*pRetn = false;

				return;
			}

			if(mCid == cId)
			{
				SendClientMessage(cId, "Impossível se expulsar.");

				return;
			}

			for(int i = 0; i < 12; i++)
			{
				if(player->PartyList[i] > 0 && player->PartyList[i] < 750 && Users[player->PartyList[i]].Status == 22)
				{
					st_Mob *mob = GetMobFromIndex(player->PartyList[i]);

					if(!strcmp(mob->Name, name))
					{
						RemoveParty(player->PartyList[i]);

						return;
					}
				}
			}

			SendClientMessage(cId, "Jogador não faz parte do grupo.");

			return;
		}

		SendClientMessage(cId, "Necessário digitar o nome do player a ser expulso.");

		return;
	}

	else if(!strcmp(p->Cmd, "subcreate"))
	{
		*pRetn = true;

		char Leader[12], Sub[16];

		int ret = sscanf(p->Arg, "%12s %16s", &Leader, &Sub);

		if(ret != 2)
		{
			*pRetn = false;

			return;
		}

		INT16 lider = GetUserByName(Leader),
				sub = GetUserByName(Sub);

		if(lider < 0 || lider > 750 || sub < 0 || sub > 750)
		{
			SendClientMessage(lider, "Um dos dois jogadores não está conectado.");

			return;
		}

		if(Users[lider].Status != 22 || Users[sub].Status != 22)
			return;

		if(lider != p->Header.ClientId)
			return;

		st_Mob *leader  = GetMobFromIndex(lider),
			   *subLead = GetMobFromIndex(sub);

		if(!strcmp(subLead->Name, leader->Name))
			return;

		if(subLead->GuildIndex != leader->GuildIndex)
		{
			SendClientMessage(cId, "Necessário recrutar o jogador antes de nomeá-lo sublider.");

			return;
		}

		if(subLead->Equip[12].Index >= 526 && subLead->Equip[12].Index <= 528)
		{
			SendClientMessage(lider, "Jogador já é sublider.");

			return;
		}

		INT8 i = 0;
		while(i < 3)
		{
			if(!strcmp(Guilds[leader->GuildIndex].SubLiderName[i], ""))
				break;

			i++;
		}

		if(i >= 3)
		{
			SendClientMessage(lider, "Máximo de 3 Sublideres por guild.");

			return;
		}

		strncpy(Guilds[leader->GuildIndex].SubLiderName[i], Sub, 16);

		subLead->Equip[12].Index = 526 + i;

		SendItem(sub, EQUIP, 12, &subLead->Equip[12]);

		SendClientMessage(lider, "Jogador recrutado com sucesso.");

		SendClientMessage(sub, "Você foi recrutado.");

		UpdateMGuildInfo(leader->GuildIndex);

		char szMsg[120];
		sprintf(szMsg, "%s é o mais novo sublider !");

		SendGuildChat(leader->GuildIndex, szMsg);

		return;
	}

	else if(!strcmp(p->Cmd, "gtax"))
	{
		*pRetn = true;

		if(player->Equip[12].Index != 509 || !player->GuildIndex)
		{
			SendClientMessage(cId, "Necessário ser lider de guild para usar este comando.");

			return;
		}

		int CityId = player->Info.CityID;

		if(War.Owner[CityId] != Guilds[player->GuildIndex].GuildID)
		{
			SendClientMessage(p->Header.ClientId, "Necessário ser dono da cidade para definir a taixa de imposto.");

			return;
		}

		INT8 Tax = 0;

		if(sscanf(p->Arg, "%d", &Tax) != 1)
		{
			SendClientMessage(cId, "Digite uma taixa válida.");

			return;
		}

		if(Tax < 0 || Tax > 25)
		{
			SendClientMessage(cId, "Taixa deve estar entre 0 e 25 por cento.");

			return;
		}

		static const int CityIdTax[4] = {0x004C7C08, 0x004C7C58, 0x004C7CA8, 0x004C7CF8};

		*(INT32*)CityIdTax[CityId] = Tax;

		char szMsg[108];

		sprintf(szMsg, "Taixa definida como %d.", Tax);

		SendClientMessage(cId, szMsg);

		War.Tax[CityId] = Tax;

		return;
	}

	else if(!stricmp(p->Cmd, "Sair"))
	{
		*pRetn = true;

		if(!player->GuildIndex || !player->Equip[12].Index)
		{
			SendClientMessage(cId, "Necessário estar em guild para sair.");

			return;
		}

		if(player->Equip[12].Index == 509)
		{
			SendClientMessage(cId, "Transfira a guild antes de sair.");

			return;
		}
		else if(player->Equip[12].Index >= 526 && player->Equip[12].Index <= 528)
		{
			for(int i = 0; i < 3; i++)
				if(!stricmp(player->Name, Guilds[player->GuildIndex].SubLiderName[i]))
			    	strncpy(Guilds[player->GuildIndex].SubLiderName[i], "", 16);
		}

		memset(&player->Equip[12], 0x0, sizeof st_Item);

		SendItem(cId, EQUIP, 12, &player->Equip[12]);

		Guilds[player->GuildIndex].Members--;
		player->GuildIndex = 0;

		SendClientMessage(cId, "Saiu da Guild com sucesso.");

		return;
	}

	else if(!stricmp(p->Cmd, "transferir"))
	{
		*pRetn = true;

		if(!player->GuildIndex || !player->Equip[12].Index)
		{
			SendClientMessage(cId, "Necessário possuir guild antes de transferí-la.");

			return;
		}
		else if(!strcmp(p->Arg, ""))
		{
			SendClientMessage(cId, "Digite o nome do novo líder.");

			return;
		}
		else if(player->Equip[12].Index != 509 || strcmp(player->Name, Guilds[player->GuildIndex].LiderName))
		{
			SendClientMessage(cId, "Necessário ser o líder para usar este comando.");

			return;
		}
		
		INT16 ncId = GetUserByName(p->Arg);

		if(!ncId || ncId < 0 || ncId > 750 || Users[ncId].Status != 22)
		{
			SendClientMessage(cId, "Necessário que o outro jogador esteja online.");

			return;
		}
		
		st_Mob *mob = GetMobFromIndex(ncId);

		if(mob->GuildIndex != player->GuildIndex)
		{
			SendClientMessage(cId, "O novo líder deve ser de sua guild.");

			return;
		}
		else if(!Guilds[player->GuildIndex].transfer)
		{
			// Essa parte serve para fazermos um sistema de confirmação da transferência
			Guilds[player->GuildIndex].transfer = true;

			strncpy(Guilds[player->GuildIndex].NewLiderName, mob->Name, 16);

			Guilds[player->GuildIndex].confirmTransfer = 30;

			SendClientMessage(cId, "Deseja mesmo transferir a guild? Caso sim, use o mesmo comando novamente.");

			return;
		}
		else if(!Guilds[player->GuildIndex].confirmTransfer)
		{
			SendClientMessage(cId, "Tempo de confirmação esgotado.");

			return;
		}
		else if(strcmp(mob->Name, Guilds[player->GuildIndex].NewLiderName))
		{
			SendClientMessage(cId, "Confirmação incorreta.");
			
			return;
		}

		if(isSubLider(mob->Name, player->GuildIndex))
		{
			for(int i = 0; i < 3; i++)
				if(!strcmp(mob->Name, Guilds[player->GuildIndex].SubLiderName[i]))
					strncpy(Guilds[player->GuildIndex].SubLiderName[i], "", 16);
		}

		strncpy(Guilds[player->GuildIndex].LiderName, Guilds[player->GuildIndex].NewLiderName, 16);

		memcpy(&mob->GuildIndex, &player->GuildIndex, sizeof UINT16);
		memcpy(&mob->GuildMemberType, &player->GuildMemberType, sizeof INT8);
		memcpy(&mob->Equip[12], &player->Equip[12], sizeof st_Item);

		player->Equip[12].Index = 508;

		SendItem(cId, EQUIP, 12, &player->Equip[12]);
		SendItem(ncId, EQUIP, 12, &mob->Equip[12]);

		char szMsg[120];

		sprintf(szMsg, "Jogador %s é o novo lider da guild !!", mob->Name);

		for(int i = 0; i < MAX_PLAYER; i++)
		{
			st_Mob *p = GetMobFromIndex(i);

			if(p->GuildIndex == mob->GuildIndex)
				sD1D(0x7530, i, szMsg, 0xFF00BFFF);
		}

		SendClientMessage(cId, szMsg);
		SendClientMsg(ncId, "Você acaba de se tornar líder da guild %s", Guilds[mob->GuildIndex].GuildName);

		return;
	}

	else if(!stricmp(p->Cmd, "Criar"))
	{
		*pRetn = true;

		if(player->GuildIndex || player->Equip[12].Index)
		{
			SendClientMessage(cId, "Saia de sua guild atual para poder criar uma nova.");

			return;
		}

		else if(!strcmp(p->Arg, ""))
		{
			SendClientMessage(p->Header.ClientId, "Necessário digitar o nome da guild.");

			return;
		}

		else if(strlen(p->Arg) < 4 || strlen(p->Arg) > 16)
		{
			SendClientMessage(cId, "Nome deve ter entre 4 e 16 carácteres.");

			return;
		}

		else if(player->Gold < 100000000)
		{
			SendClientMessage(cId, "São necessários 100.000.000 (Cem Milhões) de gold para criação da guild.");

			return;
		}

		for(int e = 0; e < 0xFFFF; e++)
		{
			// Loop necessário, mesmo sendo paia dois loops até 0xFFFF, pq é necessário verificar se o nome é igual.
			if(!strcmp(p->Arg, Guilds[e].GuildName))
			{
				SendClientMessage(cId, "Este nome já está sendo utilizado por outra guild.");

				//SendLog(Users[cId].Username, "%s tentou criar guild %s, já existente.", player->Name, p->Arg);

				return;
			}
		}

		int i = 0;
		while(i <= 0xFFFF)
		{
			if(!strcmp(Guilds[i].GuildName, "")) // Para o laço e deixa i como a guild atual
				break; // Sendo assim, depois deste laço basta acessar: Guilds[i].info

			if(i == 0xFFFF)
			{
				SendClientMessage(p->Header.ClientId, "Lamentamos, número máximo de guilds atingido.");

				return;
			}

			i++;
		}

		strncpy(Guilds[i].GuildName, p->Arg, 20);
		strncpy(Guilds[i].LiderName, player->Name, 16);

		for(int e = 0; e < 3; e++)
			strncpy(Guilds[i].SubLiderName[e], "", 16);

		GetCurScore_CapeInfo(player);

		Guilds[i].GuildID = i;
		Guilds[i].Kingdom = player->CapeInfo;

		Guilds[i].Members = 1;

		FILE *pFile = NULL;
 
        fopen_s(&pFile, "Guilds.txt", "a");
        if(pFile)
			fprintf(pFile, "0 0 %d %s\n", Guilds[i].GuildID, Guilds[i].GuildName);
			
		player->GuildIndex = i;
		player->GuildMemberType = 1;

		player->Equip[12].Index = 509;
		player->Equip[12].EF1 = 56;
        player->Equip[12].EFV1 = i >> 8;
        player->Equip[12].EF2 = 57;
        player->Equip[12].EFV2 = i & 255;
        player->Equip[12].EF3 = 59;
        player->Equip[12].EFV3 = 0;

		player->Gold -= 100000000;

		SendItem(p->Header.ClientId, EQUIP, 12, &player->Equip[12]);
		SendScore(p->Header.ClientId);
		SendEtc(p->Header.ClientId);
		SaveGuilds();

		UpdateGuildInfo(p->Header.ClientId);

		//SendLog(Users[cId].Username, "%s criou a guild %s.", player->Name, p->Arg);

		return;
	}
void WINAPI MainThread()
{
	while(1)
	{
		// Thread Principal da dll, chamada de 1 em 1 segundo. 
		// Usar para não sobrecarregar a ProcessMinTimer
		// Não cometer a negragem de dar break

		time_t rawnow = time(NULL);
		struct tm *now = localtime(&rawnow);

		if((DayOfWeek() == Terça  || DayOfWeek() == Quinta) && now->tm_hour == 21)
		{
			if(!now->tm_min && !now->tm_sec)
			{
				SendNotice("Entrada na GuildWar liberada, boa sorte !");

				//SendLog("system", "Entrada na GuildWar liberada.");

				for(int i = 0; i < 0xFFFF; i++)
					Guilds[i].WarPoints = 0;
			}

			if(now->tm_min == 30 && !now->tm_sec)
			{
				UINT16 Winner = DefineGuildWinner();

				char szMsg[120];

				if(Winner)
				{
					sprintf(szMsg, "Guild %s foi a vencedora da GuildWar, parabéns!", Guilds[Winner].GuildName);
					
					Guilds[Winner].FAME += 1000;
				}
				else
					sprintf(szMsg, "Não houve vencedores na GuildWar.");

				SendNotice(szMsg);
				//SendLog("system", szMsg);
			}
		}

		DecrementWaterTime();
		LettersTime();

		for(int z = 0; z < 0xFFFF; z++)
		{
			if(Guilds[z].confirmTransfer)
				Guilds[z].confirmTransfer--;
			if(!Guilds[z].confirmTransfer)
			{
				Guilds[z].transfer = false;

				strncpy(Guilds[z].NewLiderName, "", 16);
			}
		}

		if(!now->tm_hour && !now->tm_min && !now->tm_sec)// 0:00:00
		{
			if(DayOfWeek() == Sabado)
			{
				*(INT32*)0x008BF1814 = 1;
				SendNotice("++++ DOUBLE EXP ON ++++");
			}
			else if(DayOfWeek() == Segunda)
			{
				*(INT32*)0x008BF1814 = 0;
				SendNotice("++++ DOUBLE EXP OFF ++++");
			}
		}

		if(!now->tm_sec && (now->tm_min == 1 || now->tm_min == 16 || now->tm_min == 31 || now->tm_min == 46))
		{
			for(INT8 i = 0; i < 3; i++)
			{
				Pesa[i].TimeLeft = 840;

				for(INT8 e = 0; e < 3; e++)
				{
					for(INT8 j = 0; j < 13; j++)
					{
						if(Pesa[i].CIDS[e][j] < 0 || Pesa[i].CIDS[e][j] > 750)
							continue;
						else if(Users[Pesa[i].CIDS[e][j]].Status != 22)
							continue;

						SendClientSignalParm(Pesa[i].CIDS[e][j], 0x7530, 0x3A1, Pesa[i].TimeLeft);
					}
				}
			}
		}

		if((now->tm_min == 14 || now->tm_min == 29 || now->tm_min == 44 || now->tm_min == 59) && now->tm_sec == 59)
		{
			ClearArea(1150, 130, 1270, 220); // Pesa A
			ClearArea(1050, 260, 1135, 350); // Pesa M
			ClearArea(1295, 290, 1325, 365); // Pesa N

			for(int i = 0; i < sizeof(QuestList) / sizeof(Quests); i++)
			{
				ClearArea(MaxMinCoordsQuest[i][0], MaxMinCoordsQuest[i][1], MaxMinCoordsQuest[i][2], MaxMinCoordsQuest[i][3]);

				for(int z = 0; z < 40; z++)
					QuestList[i].CidID[z] = 0;
			}

			for(int i = 0; i < sizeof(Pesa) / sizeof(Pesas); i++)
			{
				Pesa[i].Status = false;
				Pesa[i].Groups = 0;
				Pesa[i].NpcsAlive = 0;

				for(int e = 0; e < 13; e++)
				{
					Pesa[i].CIDS[0][e] = 0;
					Pesa[i].CIDS[1][e] = 0;
					Pesa[i].CIDS[2][e] = 0;
				}
			}
		}

		if(!now->tm_sec && !now->tm_min && now->tm_hour == 21 && DayOfWeek() == Domingo)
		{
			INT64 BetValue[4][2];

			for(UINT32 I = 0; I < 0xFFFF; I++)
			{
				// Se não tiver nome, não é uma  guild ativa.
				if(!strcmp(Guilds[I].GuildName, ""))
					continue;

				// Coloca na struct da guerra os valores referentes a guilds apostantes
				for(int e = 0; e < 4; e++)
				{
					if(Guilds[I].BetValue[e] > BetValue[e][0])
					{
						BetValue[e][0] = Guilds[I].BetValue[e];
						War.BetIndex[e][0] = I;
					}
					else if(Guilds[I].BetValue[e] > BetValue[e][1])
					{
						BetValue[e][1] = Guilds[I].BetValue[e];
						War.BetIndex[e][1] = I;
					}

					Guilds[I].BetValue[e] = 0;
				}
			}

		    TeleportWar();
		}
		else if(now->tm_hour == 21 && DayOfWeek() == Domingo && now->tm_min == 3 && !now->tm_sec)
		{
			// Inicio real da pancadaria
			//SendLog("system", "Portões da Guerra abertos.");

			WarGate(1);
		}

		if(now->tm_hour == 21 && DayOfWeek() == Domingo)
		{
			for(int i = 0; i < 4; i++)
			{
				if(!War.Iniciada[i])
					continue;

				int OwnerAlive = GetTeamAlive(i, 0),
					DefyAlive  = GetTeamAlive(i, 1);

				if(!OwnerAlive)// Seta o desafiante como vencedor
					PutAsWinner(i, 1);
				else if(!DefyAlive)// Seta o defensor como vencedor
					PutAsWinner(i, 0);

				if(War.Finalizada[i])
					continue;

				for(int e = 0; e < 2; e++)
				{
					for(int j = 0; j < War.TeamCount[i][e]; j++)
					{
						INT16 cId = 0;

						if(!e)
							cId = War.OwnerTeam[i][j];
						else
							cId = War.DefyTeam[i][j];

						st_Mob *player = GetMobFromIndex(cId);

						if(player->Status.curHP <= 0)
						{
							if(wdBuffer[cId].Ingame.WarRestTime >= 1)
								wdBuffer[cId].Ingame.WarRestTime--;
							else
								wdBuffer[cId].Ingame.cantRessurect = false;
						}

						// Manda o score, não sei se vai funfar...
						NpcsAlive(cId, GetTeamAlive(i, 0), GetTeamAlive(i, 1));
					}
				}
			}
		}

		usersCount = 0;

		for(int i = 0; i < MAX_PLAYER; i++)
		{
			if(Users[i].Status != 22)
				continue;

			usersCount++;

			if(wdBuffer[i].Ingame.ChatGlobal > 0)
				wdBuffer[i].Ingame.ChatGlobal--;
			if(wdBuffer[i].Ingame.hasFailed > 0)
				wdBuffer[i].Ingame.hasFailed--;
			if(wdBuffer[i].Ingame.Grito > 0)
				wdBuffer[i].Ingame.Grito--;
			if(wdBuffer[i].Ingame.RetectItem)
				wdBuffer[i].Ingame.RetectItem--;

			st_Mob *tmpPlayer = GetMobFromIndex(i);

			if(tmpPlayer->Equip[0].EFV2 < HARDCORE && tmpPlayer->Equip[1].Index == 3505 && !wdBuffer[i].Ingame.isAdmin)
			{
				SendBan(Users[i].Username);

				char szNotice[120];

				sprintf(szNotice, "Jogador [%s] banido por uso de item irregular.", tmpPlayer->Name);

				//SendLog("banneds", szNotice);
				//SendNotice(szNotice);

				CloseUser(i);
			}

			for(int i = 0; i < *(DWORD*)(0x004C7BD8); i++) 
				memset((void*)(0x8B9E778), 0, 8);

			VerifyPesa(i);
			VerifyQuests(i);
			//VerifyWarArea(i);
		}

		Server.Seconds++;

		if(Server.Seconds >= 60)
		{
			Server.Seconds -= 60;
			Server.Minuts++;

			if(Server.Minuts >= 60)
			{
				Server.Minuts -= 60;
				Server.Hours++;

				if(Server.Hours >= 24)
				{
					Server.Days++;
					Server.Hours -= 24;
				}
			}
		}

		char szTitle[120];

		if(usersCount)
			sprintf(szTitle, "Secrets of Destiny [%d] Jogadores conectados. [%02d:%02d:%02d:%02d]", usersCount, Server.Days, Server.Hours, Server.Minuts, Server.Seconds);
		else
			sprintf(szTitle, "Secrets of Destiny [%02d:%02d:%02d:%02d]", Server.Days, Server.Hours, Server.Minuts, Server.Seconds);

		SetConsoleTitle(szTitle);

		if(!now->tm_min && !now->tm_sec)
		{
			// Funções executadas todo inicio de hora
			if(!Server.SombraNegra)
			{
				CreateMob("Sombra_Negra", 3819, 2880, "npc");

				Server.SombraNegra = TRUE;

				SendNotice("Sombra Negra acaba de nascer em Karden!");

				//SendLog("system", "Sombra Negra nasceu.");
			}
			else
				SendNotice("Sombra Negra ainda reina em Karden.");
			
			StartThread(PremiumDelivery);
		}

		Sleep(1000);
		// Não colocarei 1000 para termos margem de tempo
		// Para a execução das tarefas desta thread
	}	
}
Пример #8
0
void CWarTower::GuildProcess(tm *timeinfo)
{
	if (NewbieEventServer == 1 && timeinfo->tm_wday != 0 && timeinfo->tm_wday != 6 && timeinfo->tm_hour == GTorreHour)
	{
		if (GTorreState == 0 && timeinfo->tm_min <= 5)
		{
			sprintf(temp, g_pMessageStringTable[_DN_CHANNELWAR_BEGIN], 5);
			SendNotice(temp);
			GTorreState = 1;
			GTorreGuild = 0;
		}

		if (GTorreState == 1 && timeinfo->tm_min >= 6)
		{
			ClearArea(2445, 1850, 2546, 1920);

			GenerateMob(GTORRE, 0, 0);

			SendNotice(g_pMessageStringTable[_DN_BASEWORSTART]);
			GTorreState = 2;
		}

		//A Guerra acabou a guilda que está defendendo a torre recebe 50 de fama.
		if (GTorreState == 2 && timeinfo->tm_min == 59)
		{
			ClearArea(2445, 1850, 2546, 1920);

			for (int i = MAX_USER; i < MAX_MOB; i++)
			{
				if (pMob[i].GenerateIndex == GTORRE)
				{
					if (pMob[i].MOB.Guild)
					{
						int Group = ServerGroup;
						int Server = pMob[i].MOB.Guild / MAX_GUILD;
						int usGuild = pMob[i].MOB.Guild;

						char guildname[256];

						BASE_GetGuildName(Group, usGuild, guildname);

						MSG_GuildInfo sm;

						sm.Type = _MSG_GuildInfo;
						sm.Size = sizeof(MSG_GuildInfo);
						sm.ID = 0;

						sm.Guild = usGuild;
						GuildInfo[usGuild].Fame += 100;

						sm.GuildInfo = GuildInfo[usGuild];

						DBServerSocket.SendOneMessage((char*)&sm, sizeof(MSG_GuildInfo));

						sprintf(temp, "etc,war_tower1 guild:%d guild_fame:%d", usGuild, GuildInfo[usGuild].Fame);
						Log(temp, "-system", 0);
					}

					DeleteMob(i, 1);
				}
			}

			GTorreState = 0;
			GTorreGuild = 0;
		}
	}
}