Jump to content
  • 0

CE am gresit la IsPlayerinArea?


Question

Posted

Functia :

public 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;

}

Scriptu pus in OnPlayerSpawn :

if(IsPlayerInArea(playerid, -1591.064, 1702.824, -1741.078, 1539.302))

    {

        PD = TextDrawCreate(0.0, 434.0,"Police Departament Turf.");

        TextDrawFont(PD,3);

        TextDrawLetterSize(PD,10,10);

        TextDrawColor(PD,0xF6F6F6FF);

        TextDrawSetShadow(PD,1);

        TextDrawSetOutline(PD,1);

        TextDrawBackgroundColor(PD,0x000FF);

        TextDrawUseBox(PD,0);

return 1;

    }

LE:

Nu se vede nimic :|

18 answers to this question

Recommended Posts

Posted

Ia-o de la inceput ca sa ne asiguram ca merge, sterge tot ce ai: IsPlayerInArea, textdraw-ul, si ti le fac eu, sa incepem:

-sus in script adaugi:

new Text:PD;
-undeva in script adaugi functia IsPlayerInArea:
public 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;
}
-la OnGameModeInit adaugi:
        PD = TextDrawCreate(0.0, 434.0,"Police Departament Turf.");
        TextDrawFont(PD,3);
        TextDrawLetterSize(PD,10,10);
        TextDrawColor(PD,0xF6F6F6FF);
        TextDrawSetShadow(PD,1);
        TextDrawSetOutline(PD,1);
        TextDrawBackgroundColor(PD,0x000FF);
        TextDrawUseBox(PD,0);
-la OnPlayerUpdate adaugi:
if(IsPlayerInArea(playerid, -1591.064, 1702.824, -1741.078, 1539.302))
{
    TextdrawSetString(PD, "Police Departament Turf");
    TextDrawShowForPlayer(playerid, PD);
}
else
{
    TextDrawHideForPlayer(playerid,PD);
}


Sfarsit, acum ar trebui sa-ti mearga.


Posted

Nu folosi OnPlayerUpdate, n-are rost sa verifici din milisecunda in milisecunda pozitia -> lag. Foloseste un timer de 3-5 secunde.

Posted

off: double post

vezi ca sar putea ca coordonatele sa fie gresite

foloseste xvehicle plotter din programele de la farse

>>  http://forum.sa-mp.ro/index.php/topic,280.0.html

daca esti in filter script folosesti OnFilterScriptInit in loc de OnGameModeInit

Posted

/***********************************
* 		  Simple GPS System 	   *
*             Version 1            *
*       Creator: Littlejohny       *
*    Script by GTA-Scripting.tk    *
************************************/
/* Thanks to Mabako for the Zones! */

#include <a_samp>

new Text:gps[MAX_PLAYERS];
enum GPSInfo
{
	zone_name[30],
    Float:zone_minx,
    Float:zone_miny,
    Float:zone_minz,
    Float:zone_maxx,
    Float:zone_maxy,
    Float:zone_maxz
}

new Float:Zones[][GPSInfo] = {
{ "Police Departament Turf.",                   1508.879, -1741.078, 1721.838, -1595.012}
};

new gMax;
new GPS_Spawned[MAX_PLAYERS];

forward GPS();

public OnFilterScriptInit()
{
    print("************************************");
    print("*         Simple GPS System        *");
    print("*             Version 1            *");
    print("*       Creator: Littlejohny       *");
    print("*    Script by GTA-Scripting.tk    *");
    print("************************************");
    SetTimer("GPS", 500, 1);
    
	gMax = GetMaxPlayers();
    
    for(new i=0; i<gMax; i++)
	{
  	 	gps[i] = TextDrawCreate(0.0, 0.0,"GPS");
		TextDrawAlignment(gps[i],0);
		TextDrawBackgroundColor(gps[i],0x000000ff);
		TextDrawFont(gps[i],3);
		TextDrawLetterSize(gps[i],0.199999,1.100000);
		TextDrawColor(gps[i],0xffffffff);
		TextDrawSetOutline(gps[i],1);
		TextDrawSetProportional(gps[i],1);
	}
	return 1;
}

public OnFilterScriptExit()
{
    print("************************************");
    print("*         Simple GPS System        *");
    print("*             Version 1            *");
    print("*       Creator: Littlejohny       *");
    print("*    Script by GTA-Scripting.tk    *");
    print("************************************");
	return 1;
}

public OnPlayerConnect(playerid)
{
    GPS_Spawned[playerid] = 0;
	return 1;
}

public OnPlayerSpawn(playerid)
{
    GPS_Spawned[playerid] = 1;
	return 1;
}

public OnPlayerDeath(playerid,killerid,reason)
{
    GPS_Spawned[playerid] = 0;
	return 1;
}

public GPS()
{
	new str[256];
    for(new i=0; i<gMax; i++)
	{
	    if(IsPlayerConnected(i))
		{
		    if(GPS_Spawned[i] == 1)
		    {
	    		format(str,sizeof(str),"%s", GetPlayerArea(i));
				TextDrawSetString(gps[i], str);
				TextDrawShowForPlayer(i, gps[i]);
			}
			else
			{
			    TextDrawHideForPlayer(i, gps[i]);
			}
		}
	}
	return 1;
}

stock GetPlayerArea(playerid)
{
	new str[130];
	format(str,sizeof(str),"%s",Zones[GetPlayerZone(playerid)][zone_name]);
	return str;
}

stock GetPlayerZone(playerid)
{
	new Float:x,Float:y,Float:z;
	GetPlayerPos(playerid,x,y,z);
	for(new i=0;i<sizeof(Zones);i++)
	{
		if(x > Zones[i][zone_minx] && y > Zones[i][zone_miny] && z > Zones[i][zone_minz] && x < Zones[i][zone_maxx] && y < Zones[i][zone_maxy] && z < Zones[i][zone_maxz])
		return i;
	}
	return false;
}

Dar nu se vede unde trebuie, dupa ce m-am loghat, apare pe ecran, ce are :|?

Posted

Unde sa pun

    if(IsPlayerInArea(playerid, 1501.274, -1737.13, 1634.373, -1595.012))

    {

        TextDrawShowForPlayer(playerid, PD);

    }

    else

    {

        TextDrawHideForPlayer(playerid,PD);

    }

Ca sa mearga :(?

Posted

Unde sa pun

    if(IsPlayerInArea(playerid, 1501.274, -1737.13, 1634.373, -1595.012))

    {

        TextDrawShowForPlayer(playerid, PD);

    }

    else

    {

        TextDrawHideForPlayer(playerid,PD);

    }

Ca sa mearga :(?

Intr-un callback, si apoi creezi un timer.

Guest PlayON
Posted

Asa a zis si MoroJr, si ce am inteles, Nimic.. mai explicit? Un exemplu poate?

Vai doamne habar n-ai pawn...

Asta vine sus detot deasupra la new, sau mai bine zis oriunde.

forward CheckArea(playerid);
Cu asta pornesti timerul
SetTimerEx("CheckArea",500,1,"i",playerid);
Si asta oriunde dar numai nu intr-un public.
public CheckArea(playerid)
{
if(IsPlayerInArea(playerid, 1501.274, -1737.13, 1634.373, -1595.012))
             {
                 TextDrawShowForPlayer(playerid, PD);
             }
             else
             {
                 TextDrawHideForPlayer(playerid,PD);
             }
}
Dar o sa iti arata la fiecare 500 de milisecunde textdrawul...Poti omora timerul si porni cand nu iesti 

Posted

Nu pot sa fac cordonatele stiti cum pot schimba asta :

public 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;

}

in minx miny maxx maxy?

Posted
stock 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;
}

Guest PlayON
Posted

Da dar :

if (x > minx && x < maxx && y > miny && y < maxy) return 1;

?

Aia nu are de a face nimic.Poti continua.

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.