#define GetColor(%1) (%1[0]<<24)+(%1[1]<<16)+(%1[2]<<8)+%1[3] enum gInfo { Float:gMinX, Float:gMinY, Float:gMaxX, Float:gMaxY, gColor[12], }; new GangZones[3][gInfo]; new GangZone[sizeof(GangZones)]; public OnGameModeInit() { for(new i; i < sizeof(GangZones); i++) { LoadGangZone(i); } return 1; } public OnGameModeExit() { for(new i; i < sizeof(GangZones); i++) { UpdateGangZone(i); } return 1; } public LoadGangZone(gangzone) { new string[32]; format(string, sizeof(string), "/gangs/gangzone %d.cfg", gangzone); new File: currentfile = fopen(string, io_read); if (currentfile) { new valtmp[128]; fread(currentfile, valtmp);GangZones[gangzone][gMinX] = strval(valtmp); fread(currentfile, valtmp);GangZones[gangzone][gMinY] = strval(valtmp); fread(currentfile, valtmp);GangZones[gangzone][gMaxX] = strval(valtmp); fread(currentfile, valtmp);GangZones[gangzone][gMaxY] = strval(valtmp); fread(currentfile, valtmp);GangZones[gangzone][gColor] = strmid(GangZones[gangzone][gColor], valtmp, false, strlen(valtmp), 12); fclose(currentfile); GangZone[gangzone] = GangZoneCreate(GangZones[gangzone][gMinX], GangZones[gangzone][gMinY], GangZones[gangzone][gMaxX], GangZones[gangzone][gMaxY]); GangZoneShowForAll(GangZone[gangzone], GangZones[gangzone][gColor]); } return 1; } public UpdateGangZone(gangzone) { new string[32]; format(string, sizeof(string), "/gangs/gangzone %d.cfg", gangzone); new File: currentfile = fopen(string, io_write); if (currentfile) { new var[128]; format(var, sizeof(var), "%f gMinX\n",GangZones[gangzone][gMinX]);fwrite(currentfile, var); format(var, sizeof(var), "%f gMinY\n",GangZones[gangzone][gMinY]);fwrite(currentfile, var); format(var, sizeof(var), "%f gMaxX\n",GangZones[gangzone][gMaxX]);fwrite(currentfile, var); format(var, sizeof(var), "%f gMaxY\n",GangZones[gangzone][gMaxY]);fwrite(currentfile, var); format(var, sizeof(var), "0x%s gColor\n",HexToString(GetColor(GangZones[gangzone][gColor])));fwrite(currentfile, var); fclose(currentfile); } return 1; } HexToString(hex) { new str[9]; for (new i = 7; i >= 0; i--) { str[i] = (hex & 0x0F) + 0x30; str[i] += (str[i] > '9') ? 0x07 : 0x00; hex >>= 4; } str[8] = '\0'; return str; }
/scriptfiles/gangs/gangzone 0.cfg /scriptfiles/gangs/gangzone 1.cfg /scriptfiles/gangs/gangzone 2.cfg |
-2826.000000 gMinX -560.000000 gMinY -2242.000000 gMaxX -186.000000 gMaxY 0x0B783042 gColor
GangZoneShowForAll(GangZone[gangzone], 0xFF0000AA);
GangZoneShowForAll(GangZone[gangzone], GangZones[gangzone][gColor]);