05.04.2013, 19:03
Can anyone show me how to create Dynamic turf system using dini?
stock CreateTurfs()
{
new nomefile[32];
for(new r = 0; r<sizeof(Turfs); r++)
{
format(nomefile, sizeof(nomefile),"turfs/Turf%d.txt",r);
if (!dini_Exists(nomefile))
{
dini_Create(nomefile);
dini_IntSet(nomefile,"tgid", Turfs[r][tfactionid]);
dini_FloatSet(nomefile,"minX", Turfs[r][minX]);
dini_FloatSet(nomefile,"minY", Turfs[r][minY]);
dini_FloatSet(nomefile,"maxX", Turfs[r][maxX]);
dini_FloatSet(nomefile,"maxY", Turfs[r][maxY]);
}
else
{
Turfs[r][turfid] = dini_Int(nomefile,"turfid");
Turfs[r][tfactionid] = dini_Int(nomefile,"tfactionid");
Turfs[r][minX] = dini_Float(nomefile, "minX");
Turfs[r][minY] = dini_Float(nomefile, "minY");
Turfs[r][maxX] = dini_Float(nomefile, "maxX");
Turfs[r][maxY] = dini_Float(nomefile, "maxY");
turfzone[r]=GangZoneCreate(Turfs[r][minX],Turfs[r][minY],Turfs[r][maxX],Turfs[r][maxY]);
}
}
print("Turfs created/loaded");
}
stock GangZoneCreateEx()
{
new nomefile[32];
for(new r=0; r<sizeof(Turfs); r++)
{
format(nomefile,sizeof(nomefile),"turfs/Turf%d.txt",r);
if(dini_Exists(nomefile))
{
Turfs[r][tfactionid]=dini_Int(nomefile,"tfactionid");
Turfs[r][minX] = dini_Float(nomefile, "minX");
Turfs[r][minY] = dini_Float(nomefile, "minY");
Turfs[r][maxX] = dini_Float(nomefile, "maxX");
Turfs[r][maxY] = dini_Float(nomefile, "maxY");
turfzone[r]=GangZoneCreate(Turfs[r][minX],Turfs[r][minY],Turfs[r][maxX],Turfs[r][maxY]);
}
}
return 1;
}
stock LoadTurfs(playerid)
{
for(new r = 0; r<sizeof(Turfs); r++)
{
if(MafiaMember(playerid))
{
new colorx;
switch(Turfs[r][tfactionid])
{
case 1: colorx = COLOR_GANG_CORLEONE;
case 2: colorx = COLOR_GANG_TATTAGLIA;
case 3: colorx = COLOR_GANG_Paterno;
case 4: colorx = COLOR_GANG_CUNEO;
case 5: colorx = COLOR_GANG_BARZINI;
}
GangZoneShowForPlayer(playerid,turfzone[r], colorx);
}
else
{
GangZoneHideForPlayer(playerid,turfzone[r]);
}
}
return 1;
}