10
« le: 05 Février 2011, 00:19:28 »
Voila la je me lance dans un projet mais le problème il me faut les GangZone contrôlable sa sais simple j'ai juste à prendre de Génération street mais le problème sais sur un dossier Turfs mais pour mon serveur se dossier sert a autre chose donc je voulez savoir si je pouvez crée un dossier qui ferez office de Turfs donc voila:
foward IsPlayerInTurf
forward SaveTurfs();
forward LoadTurfs();
if(celuiattaque[playerid] == 1)
{
KillTimer(timerattaque);
for(new i = 0; i < sizeof(TurfInfo); i++)
{
GangZoneStopFlashForAll(Turfs[i]);
}
new string[256];
format(string, sizeof(string), "**** La personne qui attaquait le teritoire s'est deconnecter. ****");
SendRadioMessage(20, COLOR_LIGHTBLUE, string);
SendRadioMessage(21, COLOR_LIGHTBLUE, string);
celuiattaque[playerid] = 0;
attaquegang = 0;
}
for(new i = 0; i < sizeof(TurfInfo); i++)
{
if(TurfInfo[i][zOwned] == 20)
{
GangZoneShowForPlayer(playerid,Turfs[i],COLOR_RED);
}
else if(TurfInfo[i][zOwned] == 21)
{
GangZoneShowForPlayer(playerid,Turfs[i],COLOR_GREEN);
}
}
if(MapIconsShown[playerid] != 1)
{
MapIconsShown[playerid] = 1;
}
return 1;
}
for(new i = 0; i < sizeof(TurfInfo); i++)
{
Turfs[i] = GangZoneCreate(TurfInfo[i][zMinX],TurfInfo[i][zMinY],TurfInfo[i][zMaxX],TurfInfo[i][zMaxY]);
}
if(strcmp(cmd, "/gangattaque", true) == 0) // faudra mettre une limite comme pour le brquage (montre la zone)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pLeader] == 20 || PlayerInfo[playerid][pLeader] == 21 || PlayerInfo[playerid][pMember] == 20 || PlayerInfo[playerid][pMember] == 21)
{
if(attaquegang == 0)
{
new Found = 0;
for(new j=0; j<sizeof(TurfInfo);j++)
{
if(IsPlayerInTurf(playerid,j))
{
Found = 1;
attaquegang = 1;
if(PlayerInfo[playerid][pLeader] == 20 || PlayerInfo[playerid][pMember] == 20)
{
GangZoneFlashForAll(Turfs[j],COLOR_RED);
}
else if(PlayerInfo[playerid][pLeader] == 21 || PlayerInfo[playerid][pMember] == 21)
{
GangZoneFlashForAll(Turfs[j],COLOR_LIGHTGREEN);
}
timerattaque = SetTimerEx("AttaqueTeritoire", 10 * 60000, 0, "ii", playerid, j);
celuiattaque[playerid] = 1;
format(string, sizeof(string), "**** Un teritoire est attaqué. ****");
SendRadioMessage(20, COLOR_LIGHTBLUE, string);
SendRadioMessage(21, COLOR_LIGHTBLUE, string);
break;
}
}
if(Found)
{
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Vous n'êtes pas dans un teritoire!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Il y'a déjà une attaque en cours !");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Vous n'êtes pas gangster !");
return 1;
}
}
return 1;
}
public AttaqueTeritoire(playerid,terid)
{
if(IsPlayerInTurf(playerid,terid))
{
new string[256];
GangZoneStopFlashForAll(Turfs[terid]);
SendClientMessage(playerid,COLOR_GREEN,"Territoire Acquis ! Bravo.");
if(PlayerInfo[playerid][pLeader] != 0)
{
TurfInfo[terid][zOwned] = PlayerInfo[playerid][pLeader];
}
else
{
TurfInfo[terid][zOwned] = PlayerInfo[playerid][pMember];
}
GangZoneHideForAll(Turfs[terid]);
if(PlayerInfo[playerid][pLeader] == 20 || PlayerInfo[playerid][pMember] == 20)
{
GangZoneShowForAll(Turfs[terid],COLOR_RED);
}
else if(PlayerInfo[playerid][pLeader] == 21 || PlayerInfo[playerid][pMember] == 21)
{
GangZoneShowForAll(Turfs[terid],COLOR_LIGHTGREEN);
}
celuiattaque[playerid] = 0;
format(string, sizeof(string), "**** L'attaquant du teritoire a gagner, un gang gagne un teritoire ****");
SendRadioMessage(20, COLOR_LIGHTBLUE, string);
SendRadioMessage(21, COLOR_LIGHTBLUE, string);
attaquegang = 0;
SaveTurfs();
return 1;
}
else
{
GangZoneStopFlashForAll(Turfs[terid]);
attaquegang = 0;
SendClientMessage(playerid,COLOR_RED,"Vous n'êtes plus sur le teritoire.");
return 1;
}
}
public LoadTurfs()
{
new arrCoords[5][64];
new strFromFile2[256];
new File: file = fopen("turfs.cfg", io_read);
if (file)
{
new idx;
while (idx < sizeof(TurfInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
TurfInfo[idx][zMinX] = floatstr(arrCoords[0]);
TurfInfo[idx][zMinY] = floatstr(arrCoords[1]);
TurfInfo[idx][zMaxX] = floatstr(arrCoords[2]);
TurfInfo[idx][zMaxY] = floatstr(arrCoords[3]);
TurfInfo[idx][zOwned] = strval(arrCoords[4]);
idx++;
}
fclose(file);
}
return 1;
}
public IsPlayerInTurf(playerid, turfid)
{
if(IsPlayerConnected(playerid))
{
if(turfid == -1)
{
return 0;
}
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
if(x <= TurfInfo[turfid][zMaxX] && x >= TurfInfo[turfid][zMinX] && y <= TurfInfo[turfid][zMaxY] && y >= TurfInfo[turfid][zMinY])
{
return 1;
}
}
return 0;
}
public SaveTurfs()
{
new idx;
new File: file2;
while (idx < sizeof(TurfInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%f|%f|%f|%f|%d\n",
TurfInfo[idx][zMinX],
TurfInfo[idx][zMinY],
TurfInfo[idx][zMaxX],
TurfInfo[idx][zMaxY],
TurfInfo[idx][zOwned]);
if(idx == 0)
{
file2 = fopen("turfs.cfg", io_write);
}
else
{
file2 = fopen("turfs.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
es ce que je peut faire autre chose car faire les gangzone 1 par 1 sa va être chaud je préféré le mettre sur un dossier sais plus rapide et deuxième question voila je sais comment prendre les coordonner des position X,Y,Z mais voila sur quant j'ai ouvert le Turfs et j'ai trouver sa :
2098.163085|-1193.914428,2098.163085|-1185.914428|0
1858.641723|-1255.789306,2066.641601|-1143.789306|0
1965.22|-1263.401|2064.094|-1141.021|20
1857.240234|-1458.934814, 2105.240234|-1354.934814|0
2219.193115|-1558.732299, 2331.193115|-1398.732299|0
2028.175781|-1071.676513, 2300.175781|-943.676513|0
2458.036865|-1446.888305, 2634.036865|-1270.888305|0
2349.327880|-1731.765014, 2621.327880|-1635.765014|0
2434.131347|-1603.630859, 2634.131347|-1459.630859|0
2811.6375|-1888.5114|2426.5627|-2067.2529|0
donc voila merci si non merci si vous avez pas trouver ;).
EDIT: Sasuke78200: Tu as foiré ta balise [ CODE ], pense à lire les règles car les bouts de code de plus de 20 lignes sont à mettre sur Pastebin