SA-MP Forums Archive
Not Work... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Not Work... (/showthread.php?tid=231724)



Not Work... - Bogdanovic - 26.02.2011

pawn Код:
IsObjectInArea(objectid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
new Float:x, Float:y, Float:z;  
GetObjectPos(objectid, x, y, z);
if (x > minx && x < maxx && y > miny && y < maxy) return 1;  
else return 0;
}
pawn Код:
public ControlObject()
{

if(IsObjectInArea(BALL, * Pos GangZone *))
{
SendClientMessageToAll(GREEN, "Object in Area...");
}

if(!IsObjectInArea(BALL, * Pos GangZone *))
{
SendClientMessageToAll(RED, "Object Not in Area...");
}

}
____________________

Help me please,
the Function flood SendClientMessageToAll(RED, "Object Not in Area..."); but the Object is in.
The Problem is not * Pos GangZone * beacouse the CreateGangZone work...


Re: Not Work... - Mean - 26.02.2011

And, how doesn't it work, post what is the problem. And use [ pawn ] [ /pawn ] because this code is HARD to read.


Re: Not Work... - Bogdanovic - 26.02.2011

Yes, sorry... Edit.


Re: Not Work... - Bogdanovic - 26.02.2011

I use:

pawn Код:
GangZoneCreate(Float:minx, Float:miny, Float:maxx, Float:maxy)
I have try to Edit Code:

pawn Код:
IsObjectInArea(objectid, Float:minx, Float:miny, Float:maxx, Float:maxy)
{
new Float:x, Float:y, Float:z;  
GetObjectPos(objectid, x, y, z);
if (x > minx && x < maxx && y > miny && y < maxy) return 1;  
else return 0;
}
But nothing...


Re: Not Work... - Bogdanovic - 26.02.2011

Up, please.


Re: Not Work... - MadeMan - 26.02.2011

How do you call ControlObject ?


Re: Not Work... - Bogdanovic - 26.02.2011

Quote:

How do you call ControlObject ?

With a simple Timer:

pawn Код:
SetTimer("ControlObject", 1000, 1);
Quote:

Add print statements everywhere to view the contents of variables at all points in your code.

Yes, i print all, but i don't undersand where is the problem...


Re: Not Work... - Bogdanovic - 26.02.2011

pawn Код:
new Stats = 0;

forward CheckBall();

SetTimer("CheckBall", 1000, 1);

public OnPlayerCommandText(playerid, cmdtext[]) {
if(strcmp(cmd, "/CreateBall", true) == 0)
{
Stats = 1;
new Float:X, Float:Y, Float:Z;
DestroyObject(Ball);
GetXYZInFrontOfPlayer_ROT(playerid, X, Y, Z, 0.5, 0.0, 0);
Ball = CreateObject(OBJECTBALL, X, Y, Z -0.5, 359.0, 93.0, 10.0);
return 1;
}
}

public CheckBall()
{
if(Stats == 1)
{
if(IsObjectInArea(Ball, 2540.7649,-1514.6029, 2500.8064,-1546.1082))
{
SendClientMessageToAll(COLOR_GREEN, "Ball in Area! ");
}

if(!IsObjectInArea(Ball, 2540.7649,-1514.6029, 2500.8064,-1546.1082))
{
SendClientMessageToAll(COLOR_RED, "Ball not in Area! ");
}
}
}
I didn't add the scripts for playing (It isn't completed)

****** you mean this?


Re: Not Work... - MadeMan - 26.02.2011

Try this

pawn Код:
public CheckBall()
{
    if(Stats == 1)
    {
        if(IsObjectInArea(Ball, 2500.8064, 2540.7649,-1546.1082,-1514.6029))
        {
            SendClientMessageToAll(COLOR_GREEN, "Ball in Area! ");
        }
        else
        {
            SendClientMessageToAll(COLOR_RED, "Ball not in Area! ");
        }
    }
}



Re: Not Work... - Bogdanovic - 26.02.2011

Ok thanks, now try...

Edit: Nothing...