02/01/2023 18:42
(Esta mensagem foi modificada pela última vez a: 02/01/2023 18:43 por Rcon2014.)
Olá, gostaria de saber se vocês podem me ajudar a passar esse save e load do Msql para o INI, como meu GM é ini, tentei fazer sozinho, mas não consigo. Por favor, alguém pode fazer isso? Será apreciado..
É um sistema para capturar x pontos no mapa, é um sistema para role-playing game. Sistema somente para gangues. Deixo o código completo para melhor entendimento
É um sistema para capturar x pontos no mapa, é um sistema para role-playing game. Sistema somente para gangues. Deixo o código completo para melhor entendimento
Código:
#define MAX_GANGSPOINTS 5
//enums
enum gpInfo
{
gName[15],
gFaction[24],
gTimePoint,
Float:gPosX,
Float:gPosY,
Float:gPosZ,
Text3D:gTextLabel,
gPickup,
gGangZone,
gAvailable,
Bar:gPointBarID,
gCapturePoint,
Float:gCaptureX,
Float:gCaptureY,
Float:gCaptureZ,
gCaptureTime
};
new GangPoint[MAX_GANGSPOINTS][gpInfo];
//OnplayerSpawn
if(GetPlayerFactionType(playerid) == 2 || PlayerInfo[playerid][pAdmin] > 0)
{
for(new i = 0; i < MAX_GANGSPOINTS; i++)
{
GangZoneShowForPlayer(playerid, GangPoint[i][gGangZone], 0x274BB088);
if(GangPoint[i][gAvailable] == 1)
{
GangZoneFlashForPlayer(playerid, GangPoint[i][gGangZone], COLOR_FLASH);
}
}
}
//OngamemodeInit
for(new g = 0; g < MAX_GANGSPOINTS; g++)
{
GangPoint[g][gGangZone] = GangZoneCreate(ZoneData[g][0], ZoneData[g][1], ZoneData[g][2], ZoneData[g][3]);
}
//Eject x hora
if(ServerPoints == 60) { GangsPointsCheck(); TillTimer(); }
//functions
function CreateGlobalGangPointIcon()
{
for(new i = 0; i < MAX_GANGSPOINTS; i++)
{
UpdateGangPointIcon(i)
}
}
function UpdateGangPointIcon(i)
{
new string[130];
if(GangPoint[i][gTimePoint] == 0)
{
DestroyDynamic3DTextLabel(GangPoint[i][gTextLabel]);
DestroyDynamicPickup(GangPoint[i][gPickup]);
format(string, sizeof string, "{9EC73D}Punto de Pandilla [ {FFFFFF}%d{9EC73D} ]\nNombre: %s", i+1, GangPoint[i][gName]);
GangPoint[i][gTextLabel] = CreateDynamic3DTextLabel(string,-1,GangPoint[i][gPosX],GangPoint[i][gPosY],GangPoint[i][gPosZ],6.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1,0,0);
GangPoint[i][gPickup] = CreateDynamicPickup(1313, 1, GangPoint[i][gPosX], GangPoint[i][gPosY], GangPoint[i][gPosZ]);
}
else
{
DestroyDynamic3DTextLabel(GangPoint[i][gTextLabel]);
DestroyDynamicPickup(GangPoint[i][gPickup]);
format(string, sizeof string, "{9EC73D}Punto de Pandilla [ {FFFFFF}%d{9EC73D} ]\nNombre: %s\nFaccion: %s\nHoras: %d", i+1, GangPoint[i][gName], GangPoint[i][gFaction], GangPoint[i][gTimePoint]);
GangPoint[i][gTextLabel] = CreateDynamic3DTextLabel(string,-1,GangPoint[i][gPosX],GangPoint[i][gPosY],GangPoint[i][gPosZ],6.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1,0,0);
GangPoint[i][gPickup] = CreateDynamicPickup(1254, 1, GangPoint[i][gPosX], GangPoint[i][gPosY], GangPoint[i][gPosZ]);
}
return 1;
}
//delete factions
if(FactionInfo[f][fType] == 2)
{
for(new i = 0; i < MAX_GANGSPOINTS; i++)
{
if(strcmp(FactionInfo[f][fName], GangPoint[i][gFaction], true) == 0){
GangPoint[i][gTimePoint] = 0;
format(GangPoint[i][gFaction], 24, "Ninguna");
UpdateGangPointIcon(i);
}
}
}
//functions
function GangsPointsCheck()
{
new string[130], fd = -1;
ServerPoints = 0;
for(new i = 0; i < MAX_GANGSPOINTS; i++)
{
if(GangPoint[i][gTimePoint] == 0 && GangPoint[i][gAvailable] == 1)
{
if(strcmp(GangPoint[i][gFaction], "Ninguna", true) != 0)
{
GangPoint[i][gTimePoint] = TIME_VULNERABLE+1;
format(string, sizeof string, "{DC092F}ATENCION: {FFFFFF}El punto {BDE92D}%s {FFFFFF}no ha sido capturado y seguirá perteneciendo a la misma pandilla.", GangPoint[i][gName]);
SendPointMessage(-1, string);
GangZoneStopFlashForAll(GangPoint[i][gGangZone]);
}
GangPoint[i][gAvailable] = 0;
}
if(GangPoint[i][gTimePoint] > 0)
{
fd = GetFactionID(GangPoint[i][gFaction]);
if(fd != -1) {
FactionInfo[fd][fFounds] += 75;
UpdateFactionFounds(fd);
}
GangPoint[i][gTimePoint] --;
UpdateGangPoint(i);
}
if(GangPoint[i][gTimePoint] == 0 && GangPoint[i][gAvailable] == 0)
{
format(string, sizeof string, "{DC092F}ATENCION: {FFFFFF}El punto {BDE92D}%s {FFFFFF}está disponible para la captura.", GangPoint[i][gName]);
SendPointMessage(-1, string);
GangPoint[i][gAvailable] = 1;
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(GetPlayerFactionType(p) == 2 || PlayerInfo[p][pAdmin] > 0)
{
GangZoneFlashForPlayer(p, GangPoint[i][gGangZone], COLOR_FLASH);
}
}
}
UpdateGangPointIcon(i);
}
return 1;
}
function ProgressTimer(playerid, point)
{
if(playerid != INVALID_PLAYER_ID && GangPoint[point][gCapturePoint] == 1)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(GangPoint[point][gCaptureX] == X && GangPoint[point][gCaptureY] == Y && GangPoint[point][gCaptureZ] == Z)
{
GangPoint[point][gCaptureTime]--;
SetProgressBarValue(GangPoint[point][gPointBarID], GetProgressBarValue(GangPoint[point][gPointBarID])-1.0);
UpdateProgressBar(GangPoint[point][gPointBarID], playerid);
if(GangPoint[point][gCaptureTime] >= 1) SetTimerEx("ProgressTimer", 1000, false, "id", playerid, point);
else if(GangPoint[point][gCaptureTime] <= 0)
{
CapturePointEnd(playerid, point);
GangPoint[point][gCaptureTime] = 0;
DestroyProgressBar(GangPoint[point][gPointBarID]);
}
}
else
{
Message(playerid, COLOR_GRAD2, "No pudiste capturar el punto, te moviste o fuiste asesinado.");
DestroyProgressBar(GangPoint[point][gPointBarID]);
GangPoint[point][gCapturePoint] = 0;
GangPoint[point][gCaptureTime] = 0;
}
}
else
{
DestroyProgressBar(GangPoint[point][gPointBarID]);
GangPoint[point][gCapturePoint] = 0;
GangPoint[point][gCaptureTime] = 0;
}
return 1;
}
function CapturePointEnd(playerid, point)
{
if(playerid != INVALID_PLAYER_ID && GangPoint[point][gCapturePoint] == 1)
{
new string[160];
GangPoint[point][gAvailable] = 0;
GangPoint[point][gCapturePoint] = 0;
GangPoint[point][gTimePoint] = TIME_VULNERABLE;
format(GangPoint[point][gFaction], 24, PlayerStatInfo[playerid][3]);
format(string, sizeof string, "{DC092F}ATENCION: {FFFFFF}El punto {BDE92D}%s {FFFFFF}ha sido tomado por la pandilla %s (%s).", GangPoint[point][gName], GangPoint[point][gFaction], PlayerNameFixed[playerid]);
SendPointMessage(-1, string);
UpdateGangPoint(point);
UpdateGangPointIcon(point);
GangZoneStopFlashForAll(GangPoint[point][gGangZone]);
}
return 1;
}
//load points
LoadPoints()
{
mysql_function_query(g_Handle, "SELECT * FROM `GangsPoints`", true, "GetPointsData", "");
return 1;
}
//
function GetPointsData()
{
new rows, fields;
cache_get_data(rows, fields, g_Handle);
if(rows){
for(new p = 0; p < MAX_GANGSPOINTS; p++)
{
cache_get_field_content(p, "Name", GangPoint[p][gName], g_Handle, 15);
cache_get_field_content(p, "Faction", GangPoint[p][gFaction], g_Handle, 24);
GangPoint[p][gTimePoint] = cache_get_field_content_int(p, "TimePoint", g_Handle);
GangPoint[p][gPosX] = cache_get_field_content_float(p, "PosX", g_Handle);
GangPoint[p][gPosY] = cache_get_field_content_float(p, "PosY", g_Handle);
GangPoint[p][gPosZ] = cache_get_field_content_float(p, "PosZ", g_Handle);
}
CreateGlobalGangPointIcon();
print("MySQL: Datos cargados desde la tabla GangsPoints.");
}
else {
print("MySQL: Ha ocurrido un error al obtener datos de la tabla GangsPoints.");
SendRconCommand("exit");
}
return 1;
}
UpdateGangPoint(p)
{
new Query[110];
format(Query, sizeof Query, "UPDATE `GangsPoints` SET Faction = '%s', TimePoint = %d WHERE `ID_Point` = '%d'", GangPoint[p][gFaction], GangPoint[p][gTimePoint], p);
mysql_query(Query, THREAD_UPDATEPOINTS, 1, g_Handle);
return 1;
}