i'ts not work good
#1

i'ts not work good,

PHP код:
     new File:file fopen("IsPlayerInArea.ini"io_read);
        if (!
file) return 0;
        new 
line[MAX_AREAS],
            
Float:Pos[6];
 
        while (
fread(fileline))
        {
            
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]);
            if(
IsPlayerInArea(playeridPos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5]))
            {
                
SendClientMessage(playerid0xFF0000FF"You in area!");
            }
        }
 
        
fclose(file); 
Reply
#2

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!
Reply
#3

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)
Reply
#4

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
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)
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;
}


i'ts fine, umm the problem it's , The first line identifies the area well, and the rest is not accurate..
Reply
#5

have you tried to print the Pos array, in order to see where is the problem..!? try to print it in the while loop.
Reply
#6

Quote:
Originally Posted by AdrianG
Посмотреть сообщение
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:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
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:
Originally Posted by Sithis
Посмотреть сообщение
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(playeridparams[], help)
{
    
#pragma unused params, help
    
return ShowPlayerDialog(playeridDIALOG_IPIA_MAKERDIALOG_STYLE_LIST"יוצר אזורים דינאמי""שמירת קצה ראשון\nשמירת קצה שני\n{F58282}שמירת אזור במערכת\nאיפוס שמירת קצוות""בחירה""יציאה"), 1;
}
public 
OnFilterScriptInit()
{
    
SetTimer("InAreaCheck"200true);
    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(fileline))
    {
        
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<MAX_PLAYERSi++) if(IsPlayerConnected(i) && IsPlayerInArea(iPos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5]))
        {
            
SendClientMessage(i0xFF0000FF".!אתה נמצא באזור זה");
        }
    }
    
fclose(file);
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch (
dialogid)
    {
        case 
DIALOG_IPIA_MAKER:
        {
            if(!
response) return 0;
            switch(
listitem)
            {
                case 
0:
                {
                    
GetPlayerPos(playeridAreaInfo[0], AreaInfo[1], AreaInfo[2]);
                    
SendClientMessage(playerid0xCC9900FF"[Area Dynamic]: .קצה ראשון נשמר בהצלחה");
                }
                case 
1:
                {
                    
GetPlayerPos(playeridAreaInfo[3], AreaInfo[4], AreaInfo[5]);
                    
SendClientMessage(playerid0xCC9900FF"[Area Dynamic]: .קצה שני נשמר בהצלחה");
                }
                case 
2:
                {
                    if(!
response) return ShowPlayerDialog(playeridDIALOG_IPIA_MAKERDIALOG_STYLE_LIST"יוצר אזורים דינאמי""שמירת קצה ראשון\nשמירת קצה שני\n{F58282}שמירת אזור במערכת\nאיפוס שמירת קצוות""בחירה""יציאה"), 1;
                    if(!
IsUseOne() && !IsUseTwo()) return SendClientMessage(playerid0xFF0000FF"[Area Dynamic]: .עלייך לשמור שני קצוות");
                    new 
string[128];
                    
format(stringsizeof(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(posstring);
                    
fclose(pos);
                    new 
dialogstring[128];
                    
format(dialogstringsizeof(dialogstring), "\nIsPlayerInArea saved under the name {F58282}IsPlayerInArea_%s.ini {a9c4e4}inside the scriptfiles folder!\n"inputtext);
                    
ShowPlayerDialog(playerid206DIALOG_STYLE_MSGBOX" "dialogstring"Exit""");
                    
ResetAll();
                }
                default:
                {
                    if(!
IsUseOne() && !IsUseTwo()) return SendClientMessage(playerid0xFF0000FF"[Area Dynamic]: .עלייך לשמור שני קצוות");
                    
ResetAll();
                    
SendClientMessage(playerid0xCC9900FF"[Area Dynamic]: .שמירת הקצוות אופסו בהצלחה");
                }
            }
        }
    }
    return 
1;
}
IsUseOne()
    return 
AreaInfo[0] != 0.0 true:false;
    
IsUseTwo()
    return 
AreaInfo[3] != 0.0 true:false;
IsPlayerInArea(playeridFloat:MinXFloat:MinYFloat:MinZ,Float:MaxXFloat:MaxY,Float:MaxZ)
{
    new 
Float:XFloat:YFloat:Z;
    
GetPlayerPos(playeridXYZ);
    return (
>= MinX && <= MaxX && >= MinY && <= MaxY  && >= MinZ && <= MaxZ) ? 0;

i'ts all code, please help me fix the problem ...
Reply
#7

I bet opening and closing a file 5 times a second is not very optimized, lol. Why not load all the areas in an array in OnGameModeInit?
Reply
#8

Quote:
Originally Posted by JasperM
Посмотреть сообщение
I bet opening and closing a file 5 times a second is not very optimized, lol. Why not load all the areas in an array in OnGameModeInit?
Please fix the code for me...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)