SA-MP Forums Archive
IsPlayerInArea help - 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: IsPlayerInArea help (/showthread.php?tid=106362)



IsPlayerInArea help - Ritchie999 - 02.11.2009

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new	cmd[256];
if(strcmp(cmd, "/mycommand", true))
{
if(IsPlayerInArea(playerid, -70.06725, 1646.58, 432.0814, 2125.373))
{
GameTextForPlayer(playerid, "Entering Army Territory", 1, 1);
}
return 1;
}
return 0;
}


IsPlayerInArea(playerid, Float:data[4])
{
	new Float:X, Float:Y, Float:Z;
	GetPlayerPos(playerid, X, Y, Z);
	if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {
		return 1;
	}
	return 0;
}
Код:
(81) : error 035: argument type mismatch (argument 2)
line 81
Код:
if(IsPlayerInArea(playerid, -70.06725, 1646.58, 432.0814, 2125.373))



Re: IsPlayerInArea help - Sergei - 02.11.2009

Change your IsPlayeRInArea function with this:

pawn Код:
IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if (x > minx && x < maxx && y > miny && y < maxy) return 1;
    {
        DM[playerid] = 1;
        }
    return 0;
}



Re: IsPlayerInArea help - Ritchie999 - 02.11.2009

Quote:
Originally Posted by $ЂЯĢ
Change your IsPlayeRInArea function with this:

pawn Код:
IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if (x > minx && x < maxx && y > miny && y < maxy) return 1;
    {
        DM[playerid] = 1;
        }
    return 0;
}
C:\Users\richard\Desktop\samp 0.3 R3\gamemodes\NewProject.pwn(9 : error 017: undefined symbol "DM"
C:\Users\richard\Desktop\samp 0.3 R3\gamemodes\NewProject.pwn(9 : warning 215: expression has no effect
C:\Users\richard\Desktop\samp 0.3 R3\gamemodes\NewProject.pwn(9 : error 001: expected token: ";", but found "]"
C:\Users\richard\Desktop\samp 0.3 R3\gamemodes\NewProject.pwn(9 : error 029: invalid expression, assumed zero
C:\Users\richard\Desktop\samp 0.3 R3\gamemodes\NewProject.pwn(9 : fatal error 107: too many error messages on one line

Код:
98 = DM[playerid] = 1;



Re: IsPlayerInArea help - SaYrOn - 02.11.2009

Код:
if (x > minx && x < maxx && y > miny && y < maxy) return 1;
Delete return 1; in that string.


Re: IsPlayerInArea help - Sergei - 02.11.2009

pawn Код:
IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if (x > minx && x < maxx && y > miny && y < maxy) return 1;
    return 0;
}
Here you go.


Re: IsPlayerInArea help - Ritchie999 - 02.11.2009

Thanks, but now i got another problem

Код:
Army = GangZoneCreate(-70.06725, 1646.58, 432.0814, 2125.373);
co-ords for Area 51 gang zone

Код:
new	cmd[256];
if(strcmp(cmd, "/mycommand", true))
{
if(IsPlayerInArea(playerid, -70.06725, 1646.58, 432.0814, 2125.373))
{
GameTextForPlayer(playerid, "Entering Army Territory", 1, 1);
}
return 1;
}
that message is meant to come up when i enter the zone, but it doesnt.. even if i type "/mycommand" it still doesnt come up


Re: IsPlayerInArea help - Daren_Jacobson - 02.11.2009

or just change when you call to look like this.
pawn Код:
IsPlayerInArea(playerid, {-70.06725, 1646.58, 432.0814, 2125.373})
so here is your complete code

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
if(strcmp(cmd, "/mycommand", true))
{
if(IsPlayerInArea(playerid, {-70.06725, 1646.58, 432.0814, 2125.373}))
{
GameTextForPlayer(playerid, "Entering Army Territory", 1, 1);
}
return 1;
}
return 0;
}


IsPlayerInArea(playerid, Float:data[4])
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {
        return 1;
    }
    return 0;
}



Re: IsPlayerInArea help - MadeMan - 02.11.2009

Use this function:

pawn Код:
IsPlayerInArea(playerid, Float:minx, Float:miny, Float:maxx, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if (x > minx && x < maxx && y > miny && y < maxy) return 1;
    return 0;
}
And

pawn Код:
new cmd[256]; // You don't need it
if(strcmp(cmdtext, "/mycommand", true) == 0) // Few changes here
{
    if(IsPlayerInArea(playerid, -70.06725, 1646.58, 432.0814, 2125.373))
    {
        GameTextForPlayer(playerid, "Entering Army Territory", 1, 1);
    }
    return 1;
}



Re: IsPlayerInArea help - Ritchie999 - 02.11.2009

Quote:
Originally Posted by MadeMan
Use this function:

pawn Код:
IsPlayerInArea(playerid, Float:minx, Float:miny, Float:maxx, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if (x > minx && x < maxx && y > miny && y < maxy) return 1;
    return 0;
}
And

pawn Код:
new cmd[256]; // You don't need it
if(strcmp(cmdtext, "/mycommand", true) == 0) // Few changes here
{
    if(IsPlayerInArea(playerid, -70.06725, 1646.58, 432.0814, 2125.373))
    {
        GameTextForPlayer(playerid, "Entering Army Territory", 1, 1);
    }
    return 1;
}
will it show automatically? i'll go test it now


Re: IsPlayerInArea help - MadeMan - 02.11.2009

Quote:
Originally Posted by Ritchie999
will it show automatically? i'll go test it now
No, you have to type /mycommand.

And also https://sampwiki.blast.hk/wiki/GameTextForPlayer check the display time, 1 millisecond is VERY short time.