09.05.2016, 00:48
(
Последний раз редактировалось LockedLucas; 09.05.2016 в 23:17.
)
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(playerid, CordenadasCheckPoints[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", 3000, false, "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", 3000, false, "i",playerid);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, CordenadasCheckPoints[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", 3000, false, "i",playerid);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, CordenadasCheckPoints[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", 3000, false, "i",playerid);
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, -1, "Voce terminou a platacao, espera ela crescer e depois colha ela");
TimerPlantando[playerid] = SetTimerEx("Plantando", 10000, false, "i",playerid);
Plantado[playerid] = true;
}
}
}
public Animation(playerid)
{
new Float:X,Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
SetPlayerPos(playerid, X+1,Y+1,Z);
KillTimer(Time[playerid]);
return 1;
}
public Plantando(playerid)
{
objeto[0] = CreatePlayerObject(playerid, 806,-18.8881,-25.4280,3.1172, 0, 0, 96);
objeto[1] = CreatePlayerObject(playerid, 806,-20.5661,-30.1633,3.1172, 0, 0, 96);
objeto[2] = CreatePlayerObject(playerid, 806,-22.5412,-36.5166,3.1172, 0, 0, 96);
objeto[3] = CreatePlayerObject(playerid, 806,-24.4259,-41.9717,3.1172, 0, 0, 96);
objeto[4] = CreatePlayerObject(playerid, 806,-27.0090,-49.3037,3.1172, 0, 0, 96);
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] == 0 && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)
{
DestroyPlayerObject(playerid, objeto[0]);
Aviso[playerid] = 1;
}
if(PlayerToPoint(3,playerid, -20.5661,-30.1633,3.1172) && Aviso[playerid] == 1 && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)
{
DestroyPlayerObject(playerid, objeto[1]);
Aviso[playerid] = 2;
}
if(PlayerToPoint(3,playerid, -22.5412,-36.5166,3.1172) && Aviso[playerid] == 2 && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)
{
DestroyPlayerObject(playerid, objeto[2]);
Aviso[playerid] = 3;
}
if(PlayerToPoint(3,playerid, -24.4259,-41.9717,3.1172) && Aviso[playerid] == 3 && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)
{
DestroyPlayerObject(playerid, objeto[3]);
Aviso[playerid] = 4;
}
if(PlayerToPoint(3,playerid, -27.0090,-49.3037,3.1172) && Aviso[playerid] == 4 && 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(playerid, objeto[4]);
Aviso[playerid] = 5;
TerminouDeColher[playerid] = true;
ComecouAColher[playerid] = false;
}
return 1;
}
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
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
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(playerid, CordenadasCheckPoints[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", 3000, false, "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", 3000, false, "i",playerid);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, CordenadasCheckPoints[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", 3000, false, "i",playerid);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, CordenadasCheckPoints[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", 3000, false, "i",playerid);
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, -1, "Voce terminou a platacao, espera ela crescer e depois colha ela");
TimerPlantando[playerid] = SetTimerEx("Plantando", 10000, false, "i",playerid);
Esta_Plantando[playerid] = false;
}
}
}
public Animation(playerid)
{
new Float:X,Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
SetPlayerPos(playerid, X+1,Y+1,Z);
KillTimer(Time[playerid]);
return 1;
}
public Plantando(playerid)
{
objeto[0] = CreatePlayerObject(playerid, 806,-18.8881,-25.4280,3.1172, 0, 0, 96);
objeto[1] = CreatePlayerObject(playerid, 806,-20.5661,-30.1633,3.1172, 0, 0, 96);
objeto[2] = CreatePlayerObject(playerid, 806,-22.5412,-36.5166,3.1172, 0, 0, 96);
objeto[3] = CreatePlayerObject(playerid, 806,-24.4259,-41.9717,3.1172, 0, 0, 96);
objeto[4] = CreatePlayerObject(playerid, 806,-27.0090,-49.3037,3.1172, 0, 0, 96);
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] == 0 && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && Plantado[playerid] == true && Esta_Plantando[playerid] == false && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)
{
Colheu[playerid] ++;
DestroyPlayerObject(playerid, objeto[0]);
Aviso[playerid] = 1;
}
if(PlayerToPoint(3,playerid, -20.5661,-30.1633,3.1172) && Aviso[playerid] == 1 && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && Plantado[playerid] == true && Esta_Plantando[playerid] == false && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)
{
Colheu[playerid] ++;
DestroyPlayerObject(playerid, objeto[1]);
Aviso[playerid] = 2;
}
if(PlayerToPoint(3,playerid, -22.5412,-36.5166,3.1172) && Aviso[playerid] == 2 && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && Plantado[playerid] == true && Esta_Plantando[playerid] == false && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)
{
Colheu[playerid] ++;
DestroyPlayerObject(playerid, objeto[2]);
Aviso[playerid] = 3;
}
if(PlayerToPoint(3,playerid, -24.4259,-41.9717,3.1172) && Aviso[playerid] == 3 && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && Plantado[playerid] == true && Esta_Plantando[playerid] == false && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)
{
Colheu[playerid] ++;
DestroyPlayerObject(playerid, objeto[3]);
Aviso[playerid] = 4;
}
if(PlayerToPoint(3,playerid, -27.0090,-49.3037,3.1172) && Aviso[playerid] == 4 && TerminouDeColher[playerid] == false && ComecouAColher[playerid] == true && Plantado[playerid] == true && Esta_Plantando[playerid] == false && GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)
{
new string2[90];
Colheu[playerid] ++;
DestroyPlayerObject(playerid, objeto[4]);
Aviso[playerid] = 5;
TerminouDeColher[playerid] = true;
ComecouAColher[playerid] = false;
Plantado[playerid] = false;
Esta_Plantando[playerid] = true;
format(string2, sizeof(string2), "Voce terminou de colher e agora voce tem %d colheitas, voce pode colher mais ou vender",Colheu[playerid]);
SendClientMessage(playerid, -1, string2);
}
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(string2, sizeof(string2), "Voce vendeu %d colheitas e ganhou %d",Colheu[playerid], Colheu[playerid]*Valor_Colheita);
SendClientMessage(playerid, -1, string2);
Colheu[playerid] = 0;
return 1;
}
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
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;
}
SA:MP Team - pela include a_samp
Zeex - Pela include zcmd