[Ajuda]Sistema De Evento
#3

Ta Ai Os Codigos

Код:

#include <a_samp>

#define COR_VERMELHA 0xF66767AA
#define COR_BRANCO   0xFFFFFFAA
#define COR_AZUL     0x447FECAA
enum DataSystem
{
	Float:HP,
	Float:Colete,
	Float:PosX,
	Float:PosY,
	Float:PosZ,
	vw,
	grana,
	interior,
	ang,
	Skin,
};
new AirtonData[MAX_PLAYERS][DataSystem];
enum EventoSystem
{
	bool:Eventoiniciado,//bool irб indicar sim ou nгo (false or true) melhor doque 0 ou 1
	bool:Eventotrancado,
	bool:Eventodestrancado,
	bool:Entrar,
	bool:Eventocontagem,
	vw,
	interior,
};
new Airton[MAX_PLAYERS][EventoSystem];
new Float:ex,Float:ey,Float:ez;
new Float:entroux,Float:entrouy,Float:entrouz;
new entraram;
new CountDown = -1;
new Veiculos[MAX_VEHICLES];
new tmp[128];
new VeiculosCriados = 0;
forward countdown();

public OnFilterScriptInit()
{
	print("--**Evento System Iniciado com sucesso**--");
	print("--**Desenvolvido para o SA-MP 0.3b RC2**--");
	print("--**Progamado por Airton.Vitor**--");
	SendClientMessageToAll(COR_VERMELHA,"Evento System Iniciado com sucesso by  Airton");
	return 1;
}

public OnFilterScriptExit()
{
	print("--**Evento System Finalizado com sucesso**--");
	SendClientMessageToAll(COR_AZUL,"Evento System Finalizado com sucesso by  Airton");
	return 1;
}

main(){}

public OnPlayerConnect(playerid)
{
    Airton[playerid][Eventoiniciado] = false;
    Airton[playerid][Eventodestrancado] = false;
    Airton[playerid][Eventotrancado] = false;
    Airton[playerid][Entrar] = false;
	return 1;
}

public OnPlayerSpawn(playerid)
{
	if(IsPlayerAdmin(playerid))
	{
	   	SendClientMessage(playerid, COR_AZUL, "[EVENTOS]: Uso> /comandos para ver os comandos disponiveis");
	}
	return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
    Airton[playerid][Entrar] = false;
    SetPlayerVirtualWorld(playerid, 0);
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[128]; new streventu[128]; new idcmd;
    new admnick[20];
    cmd = strtok(cmdtext, idcmd);
    if(strcmp(cmd, "/comandos", true) == 0&&IsPlayerAdmin(playerid))
	{
	   	SendClientMessage(playerid, COR_AZUL, "[EVENTOS]: /einiciar,/etrancar,/edestrancar,/eventoterminar,/ekick,/evw,/skin");
       	SendClientMessage(playerid, COR_AZUL, "[EVENTOS]: /ecarro,/evida,/earma,/ecolete,/econtar,/econgelar,/edescongelar,/eterminar");
    	return 1;
	}
    if(strcmp(cmd, "/einiciar", true) == 0&&Airton[playerid][Eventoiniciado] == false &&IsPlayerAdmin(playerid))
	{
    	SalvarPlayer(playerid);
		GetPlayerPos(playerid, ex, ey, ez);
		Airton[playerid][interior] = GetPlayerInterior(playerid);
		//Airton[playerid][vw] = GetPlayerVirtualWorld(playerid);
       	SendClientMessageToAll(COR_AZUL, "-INFO- Um evento acaba de ser iniciado! Digite /evento para se teleportar atй o evento");
       	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(IsPlayerConnected(possiveis))
       	{
         	GameTextForPlayer(possiveis,"~y~novo evento aberto ~n~digite ~b~/evento", 2200, 1);
         	Airton[possiveis][Eventoiniciado] = true;
         	Airton[possiveis][Eventotrancado] = false;
         	Airton[possiveis][Eventodestrancado] = false;
         	Airton[playerid][Entrar] = false;
       	}
    	return 1;
	}
    if(strcmp(cmd, "/etrancar", true) == 0&&Airton[playerid][Eventoiniciado] == true&&Airton[playerid][Eventotrancado] == false &&IsPlayerAdmin(playerid))
	{
    	format(streventu, 128, "-INFO- O evento foi trancado - %d jogadores(ras) entrarao", entraram);
       	SendClientMessageToAll(COR_AZUL, streventu);
       	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(IsPlayerConnected(possiveis))
       	{
         	GameTextForPlayer(possiveis,"~y~evento ~r~fechado", 2500, 1);
         	Airton[possiveis][Eventotrancado] = true;
         	Airton[possiveis][Eventodestrancado] = true;
       	}
    	return 1;
	}
    if(strcmp(cmd, "/edestrancar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&Airton[playerid][Eventodestrancado] == true&&IsPlayerAdmin(playerid))
	{
       	SendClientMessageToAll(COR_AZUL, "-INFO- O evento foi destrancado! Digite /evento");
       	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(IsPlayerConnected(possiveis))
       	{
         	GameTextForPlayer(possiveis,"~b~evento ~g~aberto", 2500, 1);
         	Airton[possiveis][Eventotrancado] = false;
         	Airton[possiveis][Eventodestrancado] = false;
       	}
    	return 1;
	}
    if(strcmp(cmd, "/eterminar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
	{
    	GetPlayerName(playerid,admnick, 24);
       	format(streventu, 128, "-INFO- O Administrador RCON %s evento foi finalizado!", admnick);
       	SendClientMessageToAll(COR_AZUL, streventu);
       	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(IsPlayerConnected(possiveis))
       	{
         	GameTextForPlayer(possiveis,"~w~evento ~r~terminado", 2500, 1);
         	Airton[possiveis][Eventotrancado] = false;
         	Airton[possiveis][Eventoiniciado] = false;
         	Airton[possiveis][Eventodestrancado] = false;
       	}
       	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
       	{
         	Airton[possiveis][Entrar] = false;
         	SetPlayerInterior(playerid, 0);
         	SetPlayerPos(playerid, entroux, entrouy, entrouz);
         	SetPlayerVirtualWorld(playerid, 0);
       		//SetPlayerVirtualWorld(playerid, Airton[playerid][vw]);
    		SetPlayerInterior(playerid, Airton[playerid][interior]);
       	}
       	for(new carros = 0; carros < MAX_VEHICLES; carros++)
		{
		    if(Veiculos[carros])
			{
			    DestroyVehicle(Veiculos[carros]);
				Veiculos[carros] = 0;
				VeiculosCriados = 0;
			}
		}
       	entraram = 0;
    	return 1;
	}
    if(strcmp(cmd, "/evento", true) == 0&&Airton[playerid][Entrar] == false&&Airton[playerid][Eventoiniciado] == true &&Airton[playerid][Eventotrancado] == false&&IsPlayerAdmin(playerid))
	{
    	SalvarPlayer(playerid);
      	Airton[playerid][Entrar] = true;
      	entraram++;
      	GetPlayerPos(playerid, entroux, entrouy, entrouz);
		SetPlayerPos(playerid, ex, ey, ez);
		SetPlayerVirtualWorld(playerid, 5);
		//SetPlayerVirtualWorld(playerid, Airton[playerid][vw]);
		SetPlayerInterior(playerid, Airton[playerid][interior]);
    	return 1;
	}
    if(strcmp(cmd, "/esair", true) == 0&&Airton[playerid][Entrar] == true&&Airton[playerid][Eventoiniciado] == true &&Airton[playerid][Eventotrancado] == false&&IsPlayerAdmin(playerid))
  	{
    	SetPlayerVirtualWorld(playerid, 0);
      	Airton[playerid][Entrar] = false;
      	entraram -- ;
		SetPlayerPos(playerid, entroux, entrouy, entrouz);
    	return 1;
	}
    if(strcmp(cmd, "/edesarmar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
	{
    	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
	    {
         	ResetPlayerWeapons(possiveis);
        	SetPlayerArmedWeapon(possiveis,0);
   		}
    	GetPlayerName(playerid,admnick, 24);
      	format(streventu, 128, "-INFO- O Administrador RCON %s desarmou todos jogadores do evento!", admnick);
       	SendClientMessageToAll(COR_AZUL, streventu);
   		return 1;
	}
    if(strcmp(cmd, "/ekick", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
	{
    	tmp = strtok(cmdtext, idcmd);
		if(!strlen(tmp))
		{
	    	SendClientMessage(playerid, COR_AZUL, "Digite: /ekick [id]");
    		return 1;
		}
		new id;
		id = strval(tmp);
    	if(Airton[id][Entrar] == true)
	    {
         	ResetPlayerWeapons(id);
         	SetPlayerInterior(id, 0);
         	SetPlayerVirtualWorld(id, 0);
        	SetPlayerPos(id, entroux, entrouy, entrouz);
        	Airton[id][Entrar] = false;
        	new jogadornick[24];
        	GetPlayerName(playerid,admnick, 24);
        	GetPlayerName(id,jogadornick, 24);
         	format(streventu, 128, "-INFO- O Administrador RCON %s kickou jogador %s do evento!", admnick,jogadornick);
         	SendClientMessageToAll(COR_AZUL, streventu);
         	entraram --;
         	UsarPlayer(id);
   		}
   		else if(Airton[id][Entrar] == true)
   		{
   	    	SendClientMessage(playerid, COR_AZUL, "O jogador selecionado nгo encontra-se no evento!");
   		}
   		return 1;
    }
    if(strcmp(cmd, "/eskin", true) == 0&&IsPlayerAdmin(playerid))
	{
  		new skinide;
	   	tmp = strtok(cmdtext, idcmd);
	   	skinide = strval(tmp);
	   	if(!strlen(tmp))
	   	{
	     	SendClientMessage(playerid, COR_BRANCO, "Digite o id da skin que desejas setar!");
	    	return 1;
	   	}
    	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
	    {
			SetPlayerSkin(possiveis, skinide);
   		}
   		return 1;
	}
    /*if(strcmp(cmd, "/evw", true) == 0&&IsPlayerAdmin(playerid))
	{
  		new virtualtele;
	   	tmp = strtok(cmdtext, idcmd);
	   	virtualtele = strval(tmp);
	   	if(!strlen(tmp))
	   	{
	     	SendClientMessage(playerid, COR_BRANCO, "Digite o id do virtualworld que queres ir para iniciar o evento em outro mundo!");
	    	return 1;
	   	}
	   	SetPlayerVirtualWorld(playerid, virtualtele);
   		return 1;
	}*/
    if(strcmp(cmd, "/earma", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
	{
  		new gun;
	   	new ammo;
	   	tmp = strtok(cmdtext, idcmd);
	   	gun = strval(tmp);
	   	if(!strlen(tmp))
	   	{
	     	SendClientMessage(playerid, COR_BRANCO, "Digite o id da arma e a muniзгo!");
	    	return 1;
	   	}
	   	tmp = strtok(cmdtext, idcmd);
	   	ammo = strval(tmp);
	   	/*if(ammo < 1||ammo > 9999)
	   	{
	   		return 1;
		}*/
    	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
	    {
			GivePlayerWeapon(possiveis, gun, ammo);
   		}
    	GetPlayerName(playerid,admnick, 24);
       	format(streventu, 128, "-INFO- O Administrador RCON %s deu arma %d muniзгo %d aos jogadores do evento!", admnick,gun,ammo);
       	SendClientMessageToAll(COR_AZUL, streventu);
   		return 1;
	}
    if(strcmp(cmd, "/ecarro", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
	{
    	tmp = strtok(cmdtext, idcmd);
  		new carro;
	   	carro = strval(tmp);
	   	if(!strlen(tmp))
	   	{
	     	SendClientMessage(playerid, COR_BRANCO, "Digite o id do carro!");
	    	return 1;
	   	}
	   	if(carro < 400 || carro > 611)
	   	{
    	   	SendClientMessage(playerid, COR_VERMELHA, "   O ID do veiculo digitado estб invalido! veiculos de 400 б 611");
	   		return 1;
		}
    	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[possiveis][Entrar] == true)
	    {
			new Float:X = 0,Float:Y = 0,Float:Z = 0,Float:Angulo = 0;
		   	GetPlayerPos(possiveis, X,Y,Z);
		   	GetPlayerFacingAngle(playerid, Angulo);
		   	Veiculos[VeiculosCriados++] = CreateVehicle(carro, X, Y, Z, 0, random(126), random(126), 60000);
		   	LinkVehicleToInterior(Veiculos[VeiculosCriados-1], GetPlayerInterior(possiveis));
			SetVehicleVirtualWorld(Veiculos[VeiculosCriados-1], GetPlayerVirtualWorld(possiveis));
	    	PutPlayerInVehicle(possiveis, Veiculos[VeiculosCriados-1], 0);
   		}
   	   	GetPlayerName(playerid,admnick, 24);
       	format(streventu, 128, "-INFO- O Administrador RCON %s deu veiculo %d aos jogadores do evento!", admnick,carro);
       	SendClientMessageToAll(COR_AZUL, streventu);
   		return 1;
	}
    if(strcmp(cmd, "/econtar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
	{
        if(CountDown == -1)
		{
			CountDown = 6;
			SetTimer("countdown",1000,0);
  	        GetPlayerName(playerid,admnick, 24);
         	format(streventu, 128, "-INFO- O Administrador RCON %s iniciou a contagem do evento!", admnick);
        	SendClientMessageToAll(COR_AZUL, streventu);
		}
   		return 1;
	}
    if(strcmp(cmd, "/econgelar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
	{
    	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
	    {
         	TogglePlayerControllable(possiveis, false);
   		}
    	GetPlayerName(playerid,admnick, 24);
       	format(streventu, 128, "-INFO- O Administrador RCON %s congelou os jogadores do evento!", admnick);
       	SendClientMessageToAll(COR_AZUL, streventu);
   		return 1;
	}
    if(strcmp(cmd, "/edescongelar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
	{
    	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
	    {
         	TogglePlayerControllable(possiveis, true);
   		}
    	GetPlayerName(playerid,admnick, 24);
       	format(streventu, 128, "-INFO- O Administrador RCON %s descongelou os jogadores do evento!", admnick);
       	SendClientMessageToAll(COR_AZUL, streventu);
   		return 1;
	}
    if(strcmp(cmd, "/evida", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
	{
    	tmp = strtok(cmdtext, idcmd);
    	new vida = strval(tmp);
     	if(!strlen(tmp))
		{
    		SendClientMessage(playerid, COR_BRANCO, "Digite a quantidade do HP!");
			return 1;
		}
     	/*if(vida < 1 || vida > 9999)
        {
			return 1;
		}*/
    	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
	    {
         	SetPlayerHealth(possiveis,vida);
   		}
    	GetPlayerName(playerid,admnick, 24);
       	format(streventu, 128, "-INFO- O Administrador RCON %s setou HP %d para os jogadores do evento", admnick,vida);
       	SendClientMessageToAll(COR_AZUL, streventu);
   		return 1;
	}
    if(strcmp(cmd, "/ecolete", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
    {
    	tmp = strtok(cmdtext, idcmd);
    	new colete = strval(tmp);
     	if(!strlen(tmp))
	 	{
	     	SendClientMessage(playerid, COR_BRANCO, "Digite a quantidade do Colete!");
			return 1;
		}
       	/*if(colete < 1 || colete > 9999)
		{
			return 1;
		}*/
    	for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
	    {
         	SetPlayerArmour(possiveis, colete);
   		}
    	GetPlayerName(playerid,admnick, 24);
       	format(streventu, 128, "-INFO- O Administrador RCON %s setou Colete %d para os jogadores do evento", admnick, colete);
       	SendClientMessageToAll(COR_AZUL, streventu);
   		return 1;
	}
	return 1;
}

public countdown()
{
	if(CountDown==6) GameTextForAll("~p~Starting...",1000,6);

	CountDown--;
	if(CountDown==0)
	{
		GameTextForAll("~g~GO~ r~!",1000,6);
		CountDown = -1;
		for(new i = 0; i < MAX_PLAYERS; i++) {
			TogglePlayerControllable(i,true);
			PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
		}
		return 0;
	}
	else
	{
		new text[7]; format(text,sizeof(text),"~w~%d",CountDown);
		for(new i = 0; i < MAX_PLAYERS; i++) {
			PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
			TogglePlayerControllable(i,false);
		}
	 	GameTextForAll(text,1000,6);
	}

	SetTimer("countdown",1000,0);
	return 0;
}

stock SalvarPlayer(playerid)
{
	new Float: health, Float: armour, Float: SX, Float: SY, Float: SZ;
	GetPlayerHealth(playerid, health);
	GetPlayerArmour(playerid, armour);
	GetPlayerPos(playerid, SX, SY, SZ);
	AirtonData[playerid][grana] = GetPlayerMoney(playerid);
	AirtonData[playerid][Skin] = GetPlayerSkin(playerid);
	AirtonData[playerid][HP] = health;
	if (armour > 0) AirtonData[playerid][Colete] = armour;
	AirtonData[playerid][PosX] = SX;
	AirtonData[playerid][PosY] = SY;
	AirtonData[playerid][PosZ] = SZ;
	AirtonData[playerid][interior] = GetPlayerInterior(playerid);
}
stock UsarPlayer(playerid)
{
	SetPlayerSkin(playerid,AirtonData[playerid][Skin]);
    GivePlayerMoney(playerid, AirtonData[playerid][grana]);
    SetPlayerHealth(playerid, AirtonData[playerid][HP]);
    SetPlayerArmour(playerid, AirtonData[playerid][Colete]);
    SetPlayerPos(playerid, AirtonData[playerid][PosX],
	AirtonData[playerid][PosY], AirtonData[playerid][PosZ]);
	SetPlayerFacingAngle(playerid, AirtonData[playerid][grana]);
	SetPlayerInterior(playerid, AirtonData[playerid][grana]);
	SetPlayerInterior(playerid, AirtonData[playerid][interior]);
	return 1;
}
/*

	Discriзгo: Sistema de eventos v0.3b
	Progamado por: Airton.Vitor
	Manual: Para criar,trancar,setar,etc vocк deve estar logado como Administrador RCON
	Dica: /rcon login [suasenha]
	Lembrete: Sejб um bom menino e mantenha os crйditos :p

*/
strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}
Reply


Messages In This Thread
[Ajuda]Sistema De Evento - by Ultra!! - 24.09.2012, 04:46
Re: [Ajuda]Sistema De Evento - by Nill.Oliveira - 24.09.2012, 05:20
Re: [Ajuda]Sistema De Evento - by Ultra!! - 24.09.2012, 16:09
Re: [Ajuda]Sistema De Evento - by Ultra!! - 25.09.2012, 00:26
Re: [Ajuda]Sistema De Evento - by Ultra!! - 26.09.2012, 04:19
Re: [Ajuda]Sistema De Evento - by Aleex_Mason - 26.09.2012, 15:53
Re: [Ajuda]Sistema De Evento - by Ultra!! - 26.09.2012, 17:05

Forum Jump:


Users browsing this thread: 1 Guest(s)