[FilterScript] Sistema de Plantaзгo e Colheita
#1

Plantaзгo e Colheita



Eae galera bom hoje lhes trago meu segundo fs criado 100% por mim e pensado tambйm, ele й bem simples mas ficaria legal em um servidor RPG como uma profissгo de agricultor ou algo do gкnero.

Vнdeo do sistema

https://www.youtube.com/watch?v=tH7d...ature=*********

Observaзхes

Estб sem acentos porque se eu colocasse iria bugar.

Nгo testei com + 1 player mas creio que nгo vai dar conflito etc...

Nгo sei quem foi o criador da funзгo PlayerToPoint, caso alguйm ai saiba o nome do criador me diga para que eu coloque os crйditos do mesmo.

Talvez eu venha a atualizar esse fs com novas coisas que jб tenho em mente que ira deixar mais real mas ainda nгo sei.

Me avisem se tiver algo errado apesar do cуdigo ser pequeno eu me perco fбcil e esqueзo sempre de algo rsrs.

Ideias sгo bem vindas e crнticas etc...


Versгo 1.0



Cуdigo:

PHP код:
#include <a_samp>
#include <zcmd>
forward Animation(playerid);
forward Plantando(playerid);
new 
objeto[5], 
bool:ComecouAColher[MAX_PLAYERS], 
Aviso[MAX_PLAYERS], 
bool:TerminouDeColher[MAX_PLAYERS], 
CheckPoint[MAX_PLAYERS], 
Time[MAX_PLAYERS], 
bool:Plantado[MAX_PLAYERS],
TimerPlantando[MAX_PLAYERS];
new 
Float:CordenadasCheckPoints[5][3] = //Cordenadas dos Race Checkpoints
{
  {-
18.8881,-25.4280,3.1172},
  {-
20.5661,-30.1633,3.1172},
  {-
22.5412,-36.5166,3.1172},
  
  {-
24.4259,-41.9717,3.1172},
  
  {-
27.0090,-49.3037,3.1172}
};
CMD:plantar(playerid)
{
   if(
Plantado[playerid] == true) return SendClientMessage(playerid, -1"Voce ja plantou, espere crescer e va colher");
   if(
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1"Saia do veiculo para poder plantar");
   
SetPlayerCheckpoint(playeridCordenadasCheckPoints[0][0], CordenadasCheckPoints[0][1], CordenadasCheckPoints[0][2], 3.0);
   
CheckPoint[playerid] = 1;
   
SendClientMessage(playerid, -1"Siga os Checkpoints para plantar");
   return 
1;
}
public 
OnPlayerEnterCheckpoint(playerid)
{
  switch(
CheckPoint[playerid])
  {
    
    case 
1:
    {
       
      
ApplyAnimation(playerid"BOMBER""BOM_Plant",  1.0,1,0,0,0,0);  
      
Time[playerid] = SetTimerEx("Animation"3000false"i",playerid);
      
DisablePlayerCheckpoint(playerid);
      
SetPlayerCheckpoint(playerid,CordenadasCheckPoints[1][0], CordenadasCheckPoints[1][1], CordenadasCheckPoints[1][2],3.0);
      
CheckPoint[playerid] = 2;
    }
    case 
2:
    {
      
      
ApplyAnimation(playerid"BOMBER""BOM_Plant",  1.0,1,0,0,0,0);  
      
Time[playerid] = SetTimerEx("Animation"3000false"i",playerid);
      
DisablePlayerCheckpoint(playerid);
      
SetPlayerCheckpoint(playeridCordenadasCheckPoints[2][0], CordenadasCheckPoints[2][1], CordenadasCheckPoints[2][2],3.0);
      
CheckPoint[playerid] = 3;
    }
    case 
3:
    {
      
      
ApplyAnimation(playerid"BOMBER""BOM_Plant",  1.0,1,0,0,0,0);  
      
Time[playerid] = SetTimerEx("Animation"3000false"i",playerid);
      
DisablePlayerCheckpoint(playerid);
      
SetPlayerCheckpoint(playeridCordenadasCheckPoints[3][0], CordenadasCheckPoints[3][1], CordenadasCheckPoints[3][2],3.0);
      
CheckPoint[playerid] = 4;
    }
    case 
4:
    {
      
      
ApplyAnimation(playerid"BOMBER""BOM_Plant",  1.0,1,0,0,0,0);  
      
Time[playerid] = SetTimerEx("Animation"3000false"i",playerid);
      
DisablePlayerCheckpoint(playerid);
      
SendClientMessage(playerid, -1"Voce terminou a platacao, espera ela crescer e depois colha ela");
      
TimerPlantando[playerid] = SetTimerEx("Plantando"10000false"i",playerid);
      
Plantado[playerid] = true;
    }
  }
}
public 
Animation(playerid)
{
  new 
Float:X,Float:YFloat:Z;
  
GetPlayerPos(playeridXYZ);
  
SetPlayerPos(playeridX+1,Y+1,Z);
  
KillTimer(Time[playerid]);
  return 
1;
}
public 
Plantando(playerid)
{
  
objeto[0] = CreatePlayerObject(playerid806,-18.8881,-25.4280,3.11720096);
  
objeto[1] = CreatePlayerObject(playerid806,-20.5661,-30.1633,3.11720096);
  
objeto[2] = CreatePlayerObject(playerid806,-22.5412,-36.5166,3.11720096);
  
objeto[3] = CreatePlayerObject(playerid806,-24.4259,-41.9717,3.11720096);
  
objeto[4] = CreatePlayerObject(playerid806,-27.0090,-49.3037,3.11720096);
  
KillTimer(TimerPlantando[playerid]);
  
ComecouAColher[playerid] = true;
  
SendClientMessage(playerid, -1"A sua plantacao ja cresceu, pegue sua colheitadeira e va colher");
  return 
1;
}
public 
OnPlayerUpdate(playerid)
{
   if(
PlayerToPoint(3,playerid, -18.8881,-25.4280,3.1172) && Aviso[playerid] == && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532
   {
     
DestroyPlayerObject(playeridobjeto[0]);
     
Aviso[playerid] = 1;
   }
   if(
PlayerToPoint(3,playerid, -20.5661,-30.1633,3.1172) && Aviso[playerid] == && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)  
   {
     
DestroyPlayerObject(playeridobjeto[1]);
     
Aviso[playerid] = 2;
   }   
   if(
PlayerToPoint(3,playerid, -22.5412,-36.5166,3.1172) && Aviso[playerid] == && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532
   {
     
DestroyPlayerObject(playeridobjeto[2]);
     
Aviso[playerid] = 3;
   }   
   if(
PlayerToPoint(3,playerid, -24.4259,-41.9717,3.1172) && Aviso[playerid] == && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)
   {
     
DestroyPlayerObject(playeridobjeto[3]);
     
Aviso[playerid] = 4;
   }   
   if(
PlayerToPoint(3,playerid, -27.0090,-49.3037,3.1172) && Aviso[playerid] == && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532
   {
     
SendClientMessage(playerid, -1"Voce terminou de colher com sucesso e ganhou $1000");
     
GivePlayerMoney(playerid,1000);
     
DestroyPlayerObject(playeridobjeto[4]);
     
Aviso[playerid] = 5;
     
TerminouDeColher[playerid] = true;
     
ComecouAColher[playerid] = false;
   }      
   return 
1;
}
stock PlayerToPoint(Float:radiplayeridFloat:xFloat:yFloat:z)
{
  if(
IsPlayerConnected(playerid))
  {
    
    new 
Float:oldposxFloat:oldposyFloat:oldposz;
    new 
Float:tempposxFloat:tempposyFloat:tempposz;
    
GetPlayerPos(playeridoldposxoldposyoldposz);
    
tempposx = (oldposx -x);
    
tempposy = (oldposy -y);
    
tempposz = (oldposz -z);
    if (((
tempposx radi) && (tempposx > -radi)) && ((tempposy radi) && (tempposy > -radi)) && ((tempposz radi) && (tempposz > -radi)))
    {
      
      return 
1;
    }
  }
  return 
0;



Versгo 2.0


Bom nesta versгo eu arrumei algumas coisas e adicionei outra, sу nгo arrumei a animaзгo pois eu nгo sei mexer muito bem com animaзхes rsrs.


Adicionado um comando para vender a colheita e cada colheita vale 100 ( isto й configurбvel )

PHP код:
#define Valor_Colheita  100 
Nгo adicionei mais checkpoints porque da um certo trabalho e eu estou sem tempo.

Bom nгo adicionei tudo que eu queria porque como eu disse ali em cima estou sem tempo.

Cуdigo:

PHP код:
#include <a_samp> 
#include <zcmd> 
forward Animation(playerid); 
forward Plantando(playerid); 
new 
objeto[5],  
bool:ComecouAColher[MAX_PLAYERS],  
Aviso[MAX_PLAYERS],  
bool:TerminouDeColher[MAX_PLAYERS],  
CheckPoint[MAX_PLAYERS],  
Time[MAX_PLAYERS],  
bool:Esta_Plantando[MAX_PLAYERS], 
TimerPlantando[MAX_PLAYERS],
Colheu[MAX_PLAYERS],
bool:Plantado[MAX_PLAYERS];
#define Valor_Colheita  100
public OnPlayerConnect(playerid)
{
  
ComecouAColher[playerid] = false;
  
Aviso[playerid] = 0;
  
TerminouDeColher[playerid] = false;
  
Esta_Plantando[playerid] = false;
  
Plantado[playerid] = false;
  return 
1;
}
new 
Float:CordenadasCheckPoints[5][3] = //Cordenadas dos Race Checkpoints 

  {-
18.8881,-25.4280,3.1172}, 
  {-
20.5661,-30.1633,3.1172}, 
  {-
22.5412,-36.5166,3.1172}, 
   
  {-
24.4259,-41.9717,3.1172}, 
   
  {-
27.0090,-49.3037,3.1172
}; 
CMD:plantar(playerid

   if(
Esta_Plantando[playerid] == true) return SendClientMessage(playerid, -1"Voce esta ja comecou a plantar, termine");
   if(
TerminouDeColher[playerid] == true) return SendClientMessage(playerid, -1"Voce ainda nao terminou ou nao comecou a colher a antiga plantacao, termine");  
   if(
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1"Saia do veiculo para poder plantar"); 
   
SetPlayerCheckpoint(playeridCordenadasCheckPoints[0][0], CordenadasCheckPoints[0][1], CordenadasCheckPoints[0][2], 3.0); 
   
CheckPoint[playerid] = 1;
   
Esta_Plantando[playerid] = true
   
SendClientMessage(playerid, -1"Siga os Checkpoints para plantar"); 
   return 
1
}
public 
OnPlayerEnterCheckpoint(playerid

  switch(
CheckPoint[playerid]) 
  { 
     
    case 
1
    { 
        
      
ApplyAnimation(playerid"BOMBER""BOM_Plant",  1.0,1,0,0,0,0);   
      
Time[playerid] = SetTimerEx("Animation"3000false"i",playerid); 
      
DisablePlayerCheckpoint(playerid); 
      
SetPlayerCheckpoint(playerid,CordenadasCheckPoints[1][0], CordenadasCheckPoints[1][1], CordenadasCheckPoints[1][2],3.0); 
      
CheckPoint[playerid] = 2
    } 
    case 
2
    { 
       
      
ApplyAnimation(playerid"BOMBER""BOM_Plant",  1.0,1,0,0,0,0);   
      
Time[playerid] = SetTimerEx("Animation"3000false"i",playerid); 
      
DisablePlayerCheckpoint(playerid); 
      
SetPlayerCheckpoint(playeridCordenadasCheckPoints[2][0], CordenadasCheckPoints[2][1], CordenadasCheckPoints[2][2],3.0); 
      
CheckPoint[playerid] = 3
    } 
    case 
3
    { 
       
      
ApplyAnimation(playerid"BOMBER""BOM_Plant",  1.0,1,0,0,0,0);   
      
Time[playerid] = SetTimerEx("Animation"3000false"i",playerid); 
      
DisablePlayerCheckpoint(playerid); 
      
SetPlayerCheckpoint(playeridCordenadasCheckPoints[3][0], CordenadasCheckPoints[3][1], CordenadasCheckPoints[3][2],3.0); 
      
CheckPoint[playerid] = 4
    } 
    case 
4
    { 
       
      
ApplyAnimation(playerid"BOMBER""BOM_Plant",  1.0,1,0,0,0,0);   
      
Time[playerid] = SetTimerEx("Animation"3000false"i",playerid); 
      
DisablePlayerCheckpoint(playerid); 
      
SendClientMessage(playerid, -1"Voce terminou a platacao, espera ela crescer e depois colha ela"); 
      
TimerPlantando[playerid] = SetTimerEx("Plantando"10000false"i",playerid); 
      
Esta_Plantando[playerid] = false;
    } 
  } 

public 
Animation(playerid

  new 
Float:X,Float:YFloat:Z
  
GetPlayerPos(playeridXYZ); 
  
SetPlayerPos(playeridX+1,Y+1,Z); 
  
KillTimer(Time[playerid]); 
  return 
1

public 
Plantando(playerid

  
objeto[0] = CreatePlayerObject(playerid806,-18.8881,-25.4280,3.11720096); 
  
objeto[1] = CreatePlayerObject(playerid806,-20.5661,-30.1633,3.11720096); 
  
objeto[2] = CreatePlayerObject(playerid806,-22.5412,-36.5166,3.11720096); 
  
objeto[3] = CreatePlayerObject(playerid806,-24.4259,-41.9717,3.11720096); 
  
objeto[4] = CreatePlayerObject(playerid806,-27.0090,-49.3037,3.11720096); 
  
KillTimer(TimerPlantando[playerid]); 
  
ComecouAColher[playerid] = true;
  
Plantado[playerid] = true
  
SendClientMessage(playerid, -1"A sua plantacao ja cresceu, pegue sua colheitadeira e va colher"); 
  return 
1

public 
OnPlayerUpdate(playerid

   if(
PlayerToPoint(3,playerid, -18.8881,-25.4280,3.1172) && Aviso[playerid] == && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true &&  Plantado[playerid] == true &&  Esta_Plantando[playerid] == false && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)  
   { 
     
Colheu[playerid] ++;
     
DestroyPlayerObject(playeridobjeto[0]); 
     
Aviso[playerid] = 1;
   } 
   if(
PlayerToPoint(3,playerid, -20.5661,-30.1633,3.1172) && Aviso[playerid] == && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true &&  Plantado[playerid] == true &&  Esta_Plantando[playerid] == false && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)   
   { 
     
Colheu[playerid] ++;
     
DestroyPlayerObject(playeridobjeto[1]); 
     
Aviso[playerid] = 2;
   }    
   if(
PlayerToPoint(3,playerid, -22.5412,-36.5166,3.1172) && Aviso[playerid] == && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true &&  Plantado[playerid] == true &&  Esta_Plantando[playerid] == false && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)  
   { 
     
Colheu[playerid] ++;
     
DestroyPlayerObject(playeridobjeto[2]); 
     
Aviso[playerid] = 3;
   }    
   if(
PlayerToPoint(3,playerid, -24.4259,-41.9717,3.1172) && Aviso[playerid] == && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true &&  Plantado[playerid] == true &&  Esta_Plantando[playerid] == false && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532
   { 
     
Colheu[playerid] ++;
     
DestroyPlayerObject(playeridobjeto[3]); 
     
Aviso[playerid] = 4;
   }    
   if(
PlayerToPoint(3,playerid, -27.0090,-49.3037,3.1172) && Aviso[playerid] == && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true &&  Plantado[playerid] == true &&  Esta_Plantando[playerid] == false && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)  
   { 
     new 
string2[90];
     
Colheu[playerid] ++;
     
DestroyPlayerObject(playeridobjeto[4]); 
     
Aviso[playerid] = 5
     
TerminouDeColher[playerid] = true
     
ComecouAColher[playerid] = false;
     
Plantado[playerid] = false;  
     
Esta_Plantando[playerid] = true;    
     
format(string2sizeof(string2), "Voce terminou de colher e agora voce tem %d colheitas, voce pode colher mais ou vender",Colheu[playerid]);
     
SendClientMessage(playerid, -1string2);
   }       
   return 
1

CMD:vendercolheita(playerid)
{
  new 
string2[40];
  if(
Colheu[playerid] < 1) return SendClientMessage(playerid, -1"Voce precisa ter 1 ou mais colheitas para poder vender");
  
GivePlayerMoney(playerid,Colheu[playerid]*Valor_Colheita);
  
format(string2sizeof(string2), "Voce vendeu %d colheitas e ganhou %d",Colheu[playerid], Colheu[playerid]*Valor_Colheita);
  
SendClientMessage(playerid, -1string2);
  
Colheu[playerid] = 0;
  return 
1;
}
stock PlayerToPoint(Float:radiplayeridFloat:xFloat:yFloat:z

  if(
IsPlayerConnected(playerid)) 
  { 
     
    new 
Float:oldposxFloat:oldposyFloat:oldposz
    new 
Float:tempposxFloat:tempposyFloat:tempposz
    
GetPlayerPos(playeridoldposxoldposyoldposz); 
    
tempposx = (oldposx -x); 
    
tempposy = (oldposy -y); 
    
tempposz = (oldposz -z); 
    if (((
tempposx radi) && (tempposx > -radi)) && ((tempposy radi) && (tempposy > -radi)) && ((tempposz radi) && (tempposz > -radi))) 
    { 
       
      return 
1
    } 
  } 
  return 
0

Crйditos

SA:MP Team - pela include a_samp
Zeex - Pela include zcmd
Reply


Messages In This Thread
Sistema de Plantaзгo e Colheita - by LockedLucas - 09.05.2016, 00:48
Re: Sistema de Plantaзгo e Colheita - by BrianD - 09.05.2016, 01:47
Re: Sistema de Plantaзгo e Colheita - by Malbeck - 09.05.2016, 02:28
Re: Sistema de Plantaзгo e Colheita - by pWesley - 09.05.2016, 02:32
Re: Sistema de Plantaзгo e Colheita - by F1N4L - 09.05.2016, 11:22
Re: Sistema de Plantaзгo e Colheita - by Whoo - 09.05.2016, 14:18
Re: Sistema de Plantaзгo e Colheita - by LockedLucas - 09.05.2016, 14:50
Re: Sistema de Plantaзгo e Colheita - by Joao159159 - 09.05.2016, 16:10
Re: Sistema de Plantaзгo e Colheita - by LockedLucas - 09.05.2016, 16:12
Re: Sistema de Plantaзгo e Colheita - by Joao159159 - 09.05.2016, 16:36

Forum Jump:


Users browsing this thread: 1 Guest(s)