===============================//
// www.sampextremeoficial.blogspot.com //
// By [SEO]Marcos //
#include <a_samp>
#include <streamer>
#include <sscanf2>
#include <dini>
forward CriarArvore(Float:X,Float:Y,Float:Z);
forward DeletarArvore(arvoreid);
forward CarregarArvores();
new Chapeu[MAX_PLAYERS];
new Arvore[MAX_ARVORES][4];
new ProximaArvore;
new arquivo[128];
new Text3D:Id[MAX_ARVORES];
new counter = 0;
public OnFilterScriptInit()
{
format(arquivo,sizeof(arquivo),"Natal");
if(!dini_Exists(arquivo))
{
for(new i=0;i<=MAX_PLAYERS;i++)
{
if(IsPlayerAdmin(i))
{
SendClientMessage(i,0xFFFF00AA,"A Pasta 'Natal' não está criada!!
Não foi possivel Carregar o Filterscript");
SendClientMessage(i,0xFFFF00AA,"Crie a Pasta 'Natal' dentro do
scriptfiles e depois digite /rcon loadfs [FS]Natal");
}
}
SendRconCommand("unloadfs [FS]Natal");
return 1;
}
print(" [FS] Natal Carregado");
CarregarArvores();
SetTimer("Mensagem",300000,1);
return 1;
}
public OnFilterScriptExit()
{
print(" [FS] Natal Descarregado");
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new
cmd[256], tmp[256], idx
;
cmd = strtok2(cmdtext, idx);
if(strcmp(cmd,"/criararvore", true)==0)
{
if(IsPlayerAdmin(playerid))
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
for(new i=0;i<=MAX_ARVORES;i++)
{
format(arquivo,sizeof(arquivo),PASTA_ARVORES,i);
if(!dini_Exists(arquivo))
{
dini_Create(arquivo);
dini_FloatSet(arquivo,"posX",X);
dini_FloatSet(arquivo,"posX",X);
dini_FloatSet(arquivo,"posY",Y);
dini_FloatSet(arquivo,"posZ",Z);
CriarArvore(X,Y,Z);
SetPlayerPos(playerid,X,Y-3,Z);
SendClientMessage(playerid,-1,"Arvore Criada!");
return 1;
}
}
SendClientMessage(playerid,Vermelho,"Limite de arvores atingido!");
}
return 1;
}
if(strcmp(cmd,"/excluirarvore", true)==0)
{
if (IsPlayerAdmin(playerid))
{
new arvoreid;
tmp = strtok2(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, Vermelho, "| FS - Natal |
Digite: /excluirarvore [id]");
return 1;
}
arvoreid = strval(tmp);
if (arvoreid < 0 || arvoreid > MAX_ARVORES || arvoreid >
ProximaArvore-1) return SendClientMessage(playerid, Vermelho, "Id Inválido!");
DeletarArvore(arvoreid);
counter--;
SendClientMessage(playerid, -1, "Arvore Excluida!");
}
return 1;
}
if (strcmp("/comandosnatal", cmdtext, true, 10) == 0)
{
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid,0xFF0000AA,"========== Comandos Natal
===========");
SendClientMessage(playerid,0xFFFFFFAA,"/criararvore");
SendClientMessage(playerid,0xFFFFFFAA,"/excluirarvore");
SendClientMessage(playerid,0xFFFFFFAA,"/mostrarids -
/ocultarids - /chapeu");
SendClientMessage(playerid,0xFF0000AA,"========== Comandos Natal
===========");
return 1;
}
return 1;
}
if (strcmp("/chapeu", cmdtext, true, 10) == 0)
{
if(Chapeu[playerid]==0)
{
SetPlayerAttachedObject(playerid,1,19066,2,0.13,0.0,0.0,90,90.0,0.0);
Chapeu[playerid] = 1;
SendClientMessage(playerid,-1,"Chapéu de Natal Colocado");
}
else
{
RemovePlayerAttachedObject(playerid,1);
SendClientMessage(playerid,-1,"Chapéu de Natal Retirado");
Chapeu[playerid] = 0;
}
return 1;
}
if (strcmp("/ocultarids", cmdtext, true, 10) == 0)
{
if(IsPlayerAdmin(playerid))
{
OcultarIds();
SendClientMessage(playerid,-1,"Ids Ocultados!");
}
return 1;
}
if (strcmp("/mostrarids", cmdtext, true, 10) == 0)
{
if(IsPlayerAdmin(playerid))
{
MostrarIds();
SendClientMessage(playerid,-1,"Ids Exibidos!");
}
return 1;
}
return 0;
}
public CriarArvore(Float:X,Float:Y,Float:Z)
{
Arvore[ProximaArvore][0] = CreateDynamicObject(19076, X-0.39, Y+0.67, Z-0.9,
0.00, 0.00, 0.00); //Arvore
Arvore[ProximaArvore][1] = CreateDynamicObject(19056, X-1.39, Y+0.10, Z-0.2,
0.00, 0.00, 0.00);
Arvore[ProximaArvore][2] = CreateDynamicObject(19057, X+1.39, Y+0.45, Z-0.2,
0.00, 0.00, 0.00);
Arvore[ProximaArvore][3] = CreateDynamicObject(19054, X-0.07, Y-0.67, Z-0.2,
0.00, 0.00, 0.00);
ProximaArvore++;
counter++;
return (ProximaArvore-1);
}
public DeletarArvore(arvoreid)
{
DestroyDynamicObject(Arvore[arvoreid][0]);
DestroyDynamicObject(Arvore[arvoreid][1]);
DestroyDynamicObject(Arvore[arvoreid][2]);
DestroyDynamicObject(Arvore[arvoreid][3]);
format(arquivo,128,PASTA_ARVORES,arvoreid);
dini_Remove(arquivo);
ProximaArvore--;
return 1;
}
public CarregarArvores()
{
new string[128];
for(new i=0;i<=MAX_ARVORES;i++){
format(string,sizeof(string),PASTA_ARVORES,i);
if(dini_Exists(string)){
CriarArvore(dini_Float(string,"posX"),dini_Float(string,"posY"),dini_Float(string,"
posZ"));
counter++;
}
}
format(string,sizeof(string),"%d árvores de natal carregadas!!",counter);
if(counter>0) print(string);
return 1;
}
stock MostrarIds()
{
new str[50];
for(new i=0;i<=MAX_ARVORES;i++){
format(arquivo,128,PASTA_ARVORES,i);
if(dini_Exists(arquivo)){
format(str,50,"Arvore id: %d",i);
Id[i] =
Create3DTextLabel(str,0xFFFF80AA,dini_Float(arquivo,"posX"),dini_Float(arquivo,"pos
Y"),dini_Float(arquivo,"posZ"),20.0,0);
}
}
return 1;
}
stock OcultarIds()
{
for(new i=0;i<=MAX_ARVORES;i++){
Delete3DTextLabel(Id[i]);
}
return 1;
}
forward Mensagem();
public Mensagem(){
SendClientMessageToAll(0xFF8000AA,"Nossa Equipe Deseja a todos um Feliz Natal!!
Use /chapeu");
return 1;
}
//Se o seu server já tiver strtok não adicione isso abaixo
stock strtok2(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}