Sistema de Plantação - wiliamm - 21/12/2021
Olá, bom tenho esse sistema na minha GM, porém ao plantar o tempo passa muito rápido (tempo para regar antes de secar), e o tempo de colher passa muito rapido. Os codigos:
Código: public TimerPlantas()
{
new string[256], query[254];
for(new e; e < MAX_MARIHUANA; e++)
{
if(Marihuana[e][Created] > 0)
{
Marihuana[e][Time] --;
if(TimerMaria > 300) GuardarPlanta(e),TimerMaria = 0;
TimerMaria ++;
switch(Marihuana[e][Status])
{
case 1:
{
if(Marihuana[e][Time] < 1)
{
Marihuana[e][Status] = 0;
Marihuana[e][Created] = 0;
if(IsValidDynamicObject(Marihuana[e][Object])) DestroyDynamicObject(Marihuana[e][Object]);
if(IsValidDynamic3DTextLabel(Marihuana[e][Etiqueta])) DestroyDynamic3DTextLabel(Marihuana[e][Etiqueta]);
mysql_format(handle_db, query, sizeof(query), "DELETE FROM marihuana WHERE ID = '%d'", Marihuana[e][mID]);
mysql_tquery(handle_db, query);
format(Marihuana[e][Owner], 24, "Nadie");
return true;
}
format(string, sizeof(string), "{91ed00}Semillas de Marihuana{FFFFFF}\nSembradas por {4C94F6}%s{FFFFFF}\nSe seca en %dm %ds\n{DBED15}/regar{FFFFFF}", Marihuana[e][Owner], Marihuana[e][Time]/60,Marihuana[e][Time]%(60));
if(IsValidDynamic3DTextLabel(Marihuana[e][Etiqueta])) UpdateDynamic3DTextLabelText(Marihuana[e][Etiqueta], COLOR_ROJO, string);
}
case 2:
{
new hora = Marihuana[e][Time]/3600;
new minuto = Marihuana[e][Time]/60%(60);
if(hora > 0 && minuto == 0)
{
if(IsValidDynamicObject(Marihuana[e][Object])) DestroyDynamicObject(Marihuana[e][Object]);
switch(hora)
{
case 2: Marihuana[e][Object] = CreateDynamicObject(19473, Marihuana[e][PosX], Marihuana[e][PosY], Marihuana[e][PosZ]-1.52, 0.000000, 0.000000, -0.000000);
case 3: Marihuana[e][Object] = CreateDynamicObject(19473, Marihuana[e][PosX], Marihuana[e][PosY], Marihuana[e][PosZ]-1.26, 0.000000, 0.000000, -0.000000);
case 4: Marihuana[e][Object] = CreateDynamicObject(19473, Marihuana[e][PosX], Marihuana[e][PosY], Marihuana[e][PosZ]-1.78, 0.000000, 0.000000, -0.000000);
case 5: Marihuana[e][Object] = CreateDynamicObject(19473, Marihuana[e][PosX], Marihuana[e][PosY], Marihuana[e][PosZ]-2.4, 0.000000, 0.000000, -0.000000);
default: Marihuana[e][Object] = CreateDynamicObject(19473, Marihuana[e][PosX], Marihuana[e][PosY], Marihuana[e][PosZ]-1, 0.000000, 0.000000, -0.000000);
}
}
if(Marihuana[e][Time] <= 0)
{
Marihuana[e][Status] = 3;
Marihuana[e][Time] = 86400;
if(IsValidDynamicObject(Marihuana[e][Object])) DestroyDynamicObject(Marihuana[e][Object]);
if(!IsValidDynamicObject(Marihuana[e][Object])) Marihuana[e][Object] = CreateDynamicObject(19473, Marihuana[e][PosX], Marihuana[e][PosY], Marihuana[e][PosZ]-1, 0.000000, 0.000000, -0.000000);
format(string, sizeof(string), "{00cc00}Planta de Marihuana{FFFFFF}\nSembrada por {00ccff}%s{FFFFFF}\nSe seca en %dh %dm %ds\n{DBED15}/cosechar planta{FFFFFF}", Marihuana[e][Owner],Marihuana[e][Time]/3600, Marihuana[e][Time]/60%(60),Marihuana[e][Time]%(60));
}
else format(string, sizeof(string), "{00cc00}Planta de Marihuana{FFFFFF}\nSembrada por {00ccff}%s{FFFFFF}\nMadura en %dh %dm %ds", Marihuana[e][Owner],Marihuana[e][Time]/3600, Marihuana[e][Time]/60%(60),Marihuana[e][Time]%(60));
if(IsValidDynamic3DTextLabel(Marihuana[e][Etiqueta])) UpdateDynamic3DTextLabelText(Marihuana[e][Etiqueta], COLOR_ROJO, string);
}
case 3:
{
if(Marihuana[e][Time] <= 0)
{
Marihuana[e][Created] = 0;
if(IsValidDynamicObject(Marihuana[e][Object])) DestroyDynamicObject(Marihuana[e][Object]);
if(IsValidDynamic3DTextLabel(Marihuana[e][Etiqueta])) DestroyDynamic3DTextLabel(Marihuana[e][Etiqueta]);
mysql_format(handle_db, query, sizeof(query), "DELETE FROM marihuana WHERE ID = '%d'", Marihuana[e][mID]);
mysql_tquery(handle_db, query);
format(Marihuana[e][Owner], 24, "Nadie");
}
else
{
format(string, sizeof(string), "{00cc00}Planta de Marihuana{FFFFFF}\nSembrada por {00ccff}%s{FFFFFF}\nSe seca en %dh %dm %ds\n{DBED15}/cosechar planta{FFFFFF}", Marihuana[e][Owner],Marihuana[e][Time]/3600, Marihuana[e][Time]/60,Marihuana[e][Time]%(60));
if(IsValidDynamic3DTextLabel(Marihuana[e][Etiqueta])) UpdateDynamic3DTextLabelText(Marihuana[e][Etiqueta], COLOR_ROJO, string);
}
}
}
}
}
return 1;
}
Código: public CargarPlanta(id)
{
new string[256];
switch(Marihuana[id][Status])
{
case 1:
{
if(IsValidDynamicObject(Marihuana[id][Object])) DestroyDynamicObject(Marihuana[id][Object]);
if(IsValidDynamic3DTextLabel(Marihuana[id][Etiqueta])) DestroyDynamic3DTextLabel(Marihuana[id][Etiqueta]);
if(!IsValidDynamicObject(Marihuana[id][Object])) Marihuana[id][Object] = CreateDynamicObject(19473, Marihuana[id][PosX], Marihuana[id][PosY], Marihuana[id][PosZ]-2.3, 0.000000, 0.000000, -0.000000);
format(string,sizeof(string),"{91ed00}Semillas de Marihuana{FFFFFF}\nSembradas por {4C94F6}%s{FFFFFF}\nSe secan en %dm %ds\n{DBED15}/regar{FFFFFF}", Marihuana[id][Owner], Marihuana[id][Time]/60,Marihuana[id][Time]%(60));
if(!IsValidDynamic3DTextLabel(Marihuana[id][Etiqueta])) Marihuana[id][Etiqueta] = CreateDynamic3DTextLabel(string, COLOR_ROJO, Marihuana[id][PosX], Marihuana[id][PosY], Marihuana[id][PosZ]+0.9, 8.0);
GuardarPlanta(id);
}
case 2:
{
if(IsValidDynamicObject(Marihuana[id][Object])) DestroyDynamicObject(Marihuana[id][Object]);
if(IsValidDynamic3DTextLabel(Marihuana[id][Etiqueta])) DestroyDynamic3DTextLabel(Marihuana[id][Etiqueta]);
if(Marihuana[id][Time]/3600 <= 1) Marihuana[id][Object] = CreateDynamicObject(19473, Marihuana[id][PosX], Marihuana[id][PosY], Marihuana[id][PosZ]-1, 0.000000, 0.000000, -0.000000);
else if(Marihuana[id][Time]/3600 == 2) Marihuana[id][Object] = CreateDynamicObject(19473, Marihuana[id][PosX], Marihuana[id][PosY], Marihuana[id][PosZ]-1.26, 0.000000, 0.000000, -0.000000);
else if(Marihuana[id][Time]/3600 == 3) Marihuana[id][Object] = CreateDynamicObject(19473, Marihuana[id][PosX], Marihuana[id][PosY], Marihuana[id][PosZ]-1.52, 0.000000, 0.000000, -0.000000);
else if(Marihuana[id][Time]/3600 == 4) Marihuana[id][Object] = CreateDynamicObject(19473, Marihuana[id][PosX], Marihuana[id][PosY], Marihuana[id][PosZ]-1.78, 0.000000, 0.000000, -0.000000);
else Marihuana[id][Object] = CreateDynamicObject(19473, Marihuana[id][PosX], Marihuana[id][PosY], Marihuana[id][PosZ]-2.04, 0.000000, 0.000000, -0.000000);
format(string,sizeof(string),"{00cc00}Planta de Marihuana{FFFFFF}\nSembrada por {00ccff}%s{FFFFFF}\nMadura en %dh %dm %ds", Marihuana[id][Owner],Marihuana[id][Time]/3600, Marihuana[id][Time]/60%(60),Marihuana[id][Time]%(60));
if(!IsValidDynamic3DTextLabel(Marihuana[id][Etiqueta])) Marihuana[id][Etiqueta] = CreateDynamic3DTextLabel(string, COLOR_ROJO, Marihuana[id][PosX], Marihuana[id][PosY], Marihuana[id][PosZ]+0.9, 8.0);
GuardarPlanta(id);
}
case 3:
{
if(IsValidDynamicObject(Marihuana[id][Object])) DestroyDynamicObject(Marihuana[id][Object]);
if(IsValidDynamic3DTextLabel(Marihuana[id][Etiqueta])) DestroyDynamic3DTextLabel(Marihuana[id][Etiqueta]);
if(!IsValidDynamicObject(Marihuana[id][Object])) Marihuana[id][Object] = CreateDynamicObject(19473, Marihuana[id][PosX], Marihuana[id][PosY], Marihuana[id][PosZ]-1, 0.000000, 0.000000, -0.000000);
format(string, sizeof(string), "{00cc00}Planta de Marihuana{FFFFFF}\nSembrada por {00ccff}%s{FFFFFF}\nSe seca en %dh %dm %ds\n{DBED15}/cosechar planta{FFFFFF}", Marihuana[id][Owner],Marihuana[id][Time]/3600, Marihuana[id][Time]/60%(60),Marihuana[id][Time]%(60));
if(!IsValidDynamic3DTextLabel(Marihuana[id][Etiqueta])) Marihuana[id][Etiqueta] = CreateDynamic3DTextLabel(string, COLOR_ROJO, Marihuana[id][PosX], Marihuana[id][PosY], Marihuana[id][PosZ]+0.9, 8.0);
GuardarPlanta(id);
}
}
return true;
}
RE: Sistema de Plantação - SrBlue - 23/12/2021
verifique se tens alguma função SetTimer, na gamemodeinit ou SetPlayerTimer no onplayerconnect, se tiver alguma coisa do genero mande aqui, obs, o timer precisa chamar o "TimerPlantas"
exemplo
SetTimer("TimerPlantas",1000,1)
RE: Sistema de Plantação - wiliamm - 23/12/2021
(23/12/2021 19:53)SrBlue Escreveu: verifique se tens alguma função SetTimer, na gamemodeinit ou SetPlayerTimer no onplayerconnect, se tiver alguma coisa do genero mande aqui, obs, o timer precisa chamar o "TimerPlantas"
exemplo
SetTimer("TimerPlantas",1000,1)
Opa, posso lhe enviar a GM em seu PV? assim fica mais fácil.
RE: Sistema de Plantação - wiliamm - 23/12/2021
Resolvido! SrBlue me ajudou bastante +1 reputação
|