GangZone won't load -
JaKe Elite - 12.01.2013
I'm creating a turf war server
but this one is different. The zone saves in a file.
I've the file but it doesn't work.
Here is the code
pawn Код:
enum GangInfo
{
Owner[100],
TeamID,
ID,
Float:MinX,
Float:MinY,
Float:MaxX,
Float:MaxY,
Float:TakeX,
Float:TakeY,
Float:TakeZ,
Color,
CP,
MID
};
new gInfo[MAX_ZONES][GangInfo];
public loadzone_data(idx, name[], value[])
{
INI_String("Owner", gInfo[idx][Owner], 100);
INI_Int("ID", gInfo[idx][ID]);
INI_Int("TeamID", gInfo[idx][TeamID]);
INI_Hex("Color", gInfo[idx][Color]);
INI_Int("CheckpointID", gInfo[idx][CP]);
INI_Int("MapID", gInfo[idx][MID]);
INI_Float("MaxX", gInfo[idx][MaxX]);
INI_Float("MaxY", gInfo[idx][MaxY]);
INI_Float("MinX", gInfo[idx][MinX]);
INI_Float("MinY", gInfo[idx][MinY]);
INI_Float("TakeX", gInfo[idx][TakeX]);
INI_Float("TakeY", gInfo[idx][TakeY]);
INI_Float("TakeZ", gInfo[idx][TakeZ]);
return 1;
}
public OnGameModeInit()
{
//=====================[Script]=====================//
new str[40];
for(new idx = 0; idx < sizeof(gInfo); idx++)
{
format(str, sizeof(str), GangPath, idx);
INI_ParseFile(str, "loadzone_%s", .bExtra = true, .extra = idx);
gInfo[idx][CP] = CreateDynamicCP(gInfo[idx][TakeX], gInfo[idx][TakeY], gInfo[idx][TakeZ], 3.0, -1, -1, -1, 40.0);
gInfo[idx][MID] = CreateDynamicMapIcon(gInfo[idx][TakeX], gInfo[idx][TakeY], gInfo[idx][TakeZ], 19, COLOR_WHITE, -1, -1, -1, 40.0);
gInfo[idx][ID] = GangZoneCreate(gInfo[idx][MinX], gInfo[idx][MinY], gInfo[idx][MaxX], gInfo[idx][MaxY]);
}
print("[Debug] OnGameModeInit is called, Los Santos Turf War");
return 1;
}
public OnPlayerConnect(playerid)
{
for(new idx = 0; idx < sizeof(gInfo); idx++)
{
GangZoneShowForPlayer(playerid, gInfo[idx][ID], gInfo[idx][Color]);
}
return 1;
}
stock SaveZones(id)
{
new file[256], owner[100];
format(file, sizeof(file), GangPath, id);
new INI:File = INI_Open(file);
INI_SetTag(File, "Zones");
switch(gInfo[id][TeamID])
{
case 0: owner = "Ballas";
case 1: owner = "Grove Street";
case 2: owner = "Los Vagos";
case 3: owner = "Las Aztecas";
}
INI_WriteString(File, "Owner", owner);
INI_WriteInt(File, "ID", gInfo[id][ID]);
INI_WriteInt(File, "TeamID", gInfo[id][TeamID]);
INI_WriteHex(File, "Color", gInfo[id][Color]);
INI_WriteInt(File, "CheckpointID", gInfo[id][CP]);
INI_WriteInt(File, "MapID", gInfo[id][MID]);
INI_WriteFloat(File, "MaxX", gInfo[id][MaxX]);
INI_WriteFloat(File, "MaxY", gInfo[id][MaxY]);
INI_WriteFloat(File, "MinX", gInfo[id][MinX]);
INI_WriteFloat(File, "MinY", gInfo[id][MinY]);
INI_WriteFloat(File, "TakeX", gInfo[id][TakeX]);
INI_WriteFloat(File, "TakeY", gInfo[id][TakeY]);
INI_WriteFloat(File, "TakeZ", gInfo[id][TakeZ]);
INI_Close(File);
return 1;
}
here is the file i used to test with.
Path: "LS Turf/GangZone/0.ini"
Код:
[Zones]
Owner = Ballas
ID = 0
TeamID = 0
Color = 0x00FF00FF
CheckpointID = 0
MapID = 19
MaxX = 1972.1477
MaxY = -2191.7231
MinX = 1950.7703
MinY = -2156.0007
TakeX = 1953.7517
TakeY = -2188.3179
TakeZ = 13.5469
Re: GangZone won't load -
EAsT-OAK_510 - 12.01.2013
What do you mean by it doesn't work? Like it won't load it?
Re: GangZone won't load -
JaKe Elite - 12.01.2013
Yes it won't load.
Edit:
I've made a debug during the loading.
i print
pawn Код:
printf("Debug: %d", gInfo[id][ID]);
but it always result as zero.
Edit2:
I think i got it working on it!
Re: GangZone won't load -
JaKe Elite - 12.01.2013
It works now however the Capturing of the turf doesn't work.
Yes it work. But after the take over it spam
"The turf ballas has been taken over (then a weird symbol)"
And even the turf is already taken by the Grove Street
i can still take over the turf even it's already owned by my team.
Code
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
new str[128], owner[100];
for(new id = 1; id < sizeof(gInfo); id++)
{
if(checkpointid == gInfo[id][CP])
{
if(tCheck[gInfo[id][TeamID]] == GetPlayerTeam(playerid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This zone is already captured by your team!");
if(UnderAttack[gInfo[id][ID]] == 1) return SendClientMessage(playerid, COLOR_RED, "ERROR: This zone is already being taken over!");
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot capture while in a vehicle!");
UnderAttack[gInfo[id][ID]] = 1;
timer[playerid][gInfo[id][ID]] = SetTimerEx("SetZone", 25000, false, "i", playerid);
GangZoneFlashForAll(gInfo[id][ID], COLOR_RED);
switch(gInfo[id][TeamID])
{
case 0: owner = "Ballas";
case 1: owner = "Grove Street";
case 2: owner = "Los Vagos";
case 3: owner = "Las Aztecas";
}
format(str, sizeof(str), "TURFWAR: The Turf owned by Team %s (ID: %d) has been taken over started by %s(%d)", owner, gInfo[id][ID], GetName(playerid), playerid);
SendClientMessageToAll(COLOR_ORANGE, str);
SendClientMessage(playerid, COLOR_YELLOW, "INFO: Stand there for 25 seconds in order to take the turf!");
zDefine[playerid] = gInfo[id][ID];
}
}
return 1;
}
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
new str[128], owner[100];
for(new id = 1; id < sizeof(gInfo); id++)
{
if(checkpointid == gInfo[id][CP])
{
UnderAttack[gInfo[id][ID]] = 0;
GangZoneStopFlashForAll(gInfo[id][ID]);
KillTimer(timer[playerid][gInfo[id][ID]]);
switch(gInfo[id][TeamID])
{
case 0: owner = "Ballas";
case 1: owner = "Grove Street";
case 2: owner = "Los Vagos";
case 3: owner = "Las Aztecas";
}
format(str, sizeof(str), "TURFWAR: The Turf War on Team %s (ID: %d) has been stopped!", owner, gInfo[id][ID]);
SendClientMessageToAll(COLOR_YELLOW, str);
}
}
return 1;
}
forward SetZone(playerid);
public SetZone(playerid)
{
SetPlayerScore(playerid, GetPlayerScore(playerid) + 3);
GivePlayerMoney(playerid, 3000);
SendClientMessage(playerid, COLOR_LIME, "TURFTAKEN: Congratulations! You have gained 3 scores & $3000 money for taking over the turf!");
for(new id = 1; id < sizeof(gInfo); id++)
{
UnderAttack[gInfo[id][ID]] = 0;
KillTimer(timer[playerid][gInfo[id][ID]]);
SetGangZone(playerid);
}
return 1;
}
forward SetGangZone(playerid);
public SetGangZone(playerid)
{
new str[128], owner[100], file[256];
for(new id = 1; id < sizeof(gInfo); id++)
{
if(zDefine[playerid] == gInfo[id][ID])
{
GangZoneShowForAll(gInfo[id][ID], GetPlayerColor(playerid));
switch(gInfo[id][TeamID])
{
case 0: owner = "Ballas";
case 1: owner = "Grove Street";
case 2: owner = "Los Vagos";
case 3: owner = "Las Aztecas";
}
format(str, sizeof(str), "TURFTAKEN: %s has captured the Team %s's Zone (ID: %d)", owner, gInfo[id][ID]);
SendClientMessageToAll(COLOR_ORANGE, str);
GangZoneStopFlashForAll(gInfo[id][ID]);
tCheck[gInfo[id][ID]] = GetPlayerTeam(playerid);
format(file, sizeof(file), GangPath, id);
new INI:File = INI_Open(file);
INI_SetTag(File, "Zones");
INI_WriteString(File, "Owner", owner);
INI_WriteHex(File, "Color", GetPlayerColor(playerid));
INI_Close(File);
}
}
return 1;
}
Re: GangZone won't load -
JaKe Elite - 17.01.2013
6 days later...
Topic Dead.
Bump Bump!
Re: GangZone won't load -
JaKe Elite - 17.01.2013
Topic Locked.
Works now.