24.05.2016, 13:40
Quote:
have you tried to print the Pos array, in order to see where is the problem..!? try to print it in the while loop.
|
Quote:
Code looks fine, nothing wrong with it (except IsPlayerInArea function but that is custom so its probably fine)
Please how us IsPlayerInArea function (how its defined). And file format how you save that coordinates (what each one is representing) |
Quote:
What's not working well? Do you get any errors? Does the file exist and contain the right values? You really must be more specific!
|
PHP код:
new
Float:AreaInfo[6];
YCMD:areaweapon(playerid, params[], help)
{
#pragma unused params, help
return ShowPlayerDialog(playerid, DIALOG_IPIA_MAKER, DIALOG_STYLE_LIST, "יוצר אזורים דינאמי", "שמירת קצה ראשון\nשמירת קצה שני\n{F58282}שמירת אזור במערכת\nאיפוס שמירת קצוות", "בחירה", "יציאה"), 1;
}
public OnFilterScriptInit()
{
SetTimer("InAreaCheck", 200, true);
return 1;
}
function InAreaCheck()
{
new File:file = fopen("IsPlayerInArea.ini", io_read);
if (!file) return 0;
new line[MAX_AREAS],
Float:Pos[6];
while (fread(file, line))
{
sscanf(line, "p<,>ffffff", Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5]);
printf("%f, %f, %f, %f, %f, %f", Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5]);
for(new i; i <MAX_PLAYERS; i++) if(IsPlayerConnected(i) && IsPlayerInArea(i, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5]))
{
SendClientMessage(i, 0xFF0000FF, ".!אתה נמצא באזור זה");
}
}
fclose(file);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch (dialogid)
{
case DIALOG_IPIA_MAKER:
{
if(!response) return 0;
switch(listitem)
{
case 0:
{
GetPlayerPos(playerid, AreaInfo[0], AreaInfo[1], AreaInfo[2]);
SendClientMessage(playerid, 0xCC9900FF, "[Area Dynamic]: .קצה ראשון נשמר בהצלחה");
}
case 1:
{
GetPlayerPos(playerid, AreaInfo[3], AreaInfo[4], AreaInfo[5]);
SendClientMessage(playerid, 0xCC9900FF, "[Area Dynamic]: .קצה שני נשמר בהצלחה");
}
case 2:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_IPIA_MAKER, DIALOG_STYLE_LIST, "יוצר אזורים דינאמי", "שמירת קצה ראשון\nשמירת קצה שני\n{F58282}שמירת אזור במערכת\nאיפוס שמירת קצוות", "בחירה", "יציאה"), 1;
if(!IsUseOne() && !IsUseTwo()) return SendClientMessage(playerid, 0xFF0000FF, "[Area Dynamic]: .עלייך לשמור שני קצוות");
new string[128];
format(string, sizeof(string), "%f, %f, %f, %f, %f, %f\r\n",
(AreaInfo[0] < AreaInfo[3]) ? AreaInfo[0] : AreaInfo[3],
(AreaInfo[1] < AreaInfo[4]) ? AreaInfo[1] : AreaInfo[4],
(AreaInfo[2] < AreaInfo[5]) ? AreaInfo[2] : AreaInfo[5],
(AreaInfo[0] > AreaInfo[3]) ? AreaInfo[0] : AreaInfo[3],
(AreaInfo[1] > AreaInfo[4]) ? AreaInfo[1] : AreaInfo[4],
(AreaInfo[2] > AreaInfo[5]) ? AreaInfo[2] : AreaInfo[5]
);
new File:pos=fopen("IsPlayerInArea.ini", io_append);
fwrite(pos, string);
fclose(pos);
new dialogstring[128];
format(dialogstring, sizeof(dialogstring), "\nIsPlayerInArea saved under the name {F58282}IsPlayerInArea_%s.ini {a9c4e4}inside the scriptfiles folder!\n", inputtext);
ShowPlayerDialog(playerid, 206, DIALOG_STYLE_MSGBOX, " ", dialogstring, "Exit", "");
ResetAll();
}
default:
{
if(!IsUseOne() && !IsUseTwo()) return SendClientMessage(playerid, 0xFF0000FF, "[Area Dynamic]: .עלייך לשמור שני קצוות");
ResetAll();
SendClientMessage(playerid, 0xCC9900FF, "[Area Dynamic]: .שמירת הקצוות אופסו בהצלחה");
}
}
}
}
return 1;
}
IsUseOne()
return AreaInfo[0] != 0.0 ? true:false;
IsUseTwo()
return AreaInfo[3] != 0.0 ? true:false;
IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MinZ,Float:MaxX, Float:MaxY,Float:MaxZ)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
return (X >= MinX && X <= MaxX && Y >= MinY && Y <= MaxY && Z >= MinZ && Z <= MaxZ) ? 1 : 0;
}