timer for dynamic cp
#1

How to add a timer when player near x y z it will show cp and when he's not near it, it will disable the cp
Reply
#2

Why not just use Streamer?
Any ways use OnPlayerUpdate, better than timers
Would look something like this
PHP код:
public OnPlayerUpdate(playerid)
{
        if(
IsPlayerInRangeOfPoint(playerid,distance,x,y,z))
    {
     
//do anything here
     
}
        else
        {
        
//if he is not in the range of point
        
}
        return 
1;

Reply
#3

but it will send him a message non stop i want 1 time.
Reply
#4

run 2/3 second timer, no other option
e.g
pawn Код:
//top of GM/FS
new UpdateTimer;
new InPos[MAX_PLAYERS];
//At gememodeint or filterscriptint
UpdateTimer = SetTimer("OnTimerUpdate", 3000, true);

//the callback
forward OnTimerUpdate();
public OnTimerUpdate{
for(new playerid = 0; playerid  < MAX_PLAYERS; playerid ++)
{
     if(IsPlayerInRangeOfPoint(playerid ,distance,x,y,z) && InPos[playerid]==0)
     {
          InPos[playerid]=1;
          //do what ever if the player is in the x,y,z cords
     }else{
          InPos[playerid]=0;
     }
}
return 1;
}
the variables are so there is no loop when checking the timer
Reply
#5

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
but it will send him a message non stop i want 1 time.
Sends the message non stop?use a variable.
Reply
#6

i made something like that..
does not work..
Код:
forward isOnHouse(playerid);
public isOnHouse(playerid)
{
	for(new h = 0; h < sizeof(HouseInfo); h++)
	{
		if(PlayerToPoint(2.0, playerid, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]))
		{
			if(standingOnHouse[playerid] == 0)
			{
				nearHouse[playerid] = h;
				standingOnHouse[playerid] = 1;
				HouseEnter[h][playerid] = CreateDynamicCP(HouseInfo[h][hEntrancex],HouseInfo[h][hEntrancey],HouseInfo[h][hEntrancez], 1.5, -1, -1, -1, 100.0);
			}
		}
	}
	return 1;
}
Reply
#7

HELP SOMEONE?
Reply
#8

Quote:
Originally Posted by DaRk_RaiN
Посмотреть сообщение
Any ways use OnPlayerUpdate, better than timers
Not is isn't.
If you create a timer, you can run like, 1 second each, and not everytime the player does anything.
Then, this way you will be able to create the timer, and create it later, when you leave the cp.


@ot: Check park4bmx post, it is usefull for you.
Reply
#9

Use this:
PHP код:
CreateDynamicCP(xPosyPoszPos1.5, -1, -1, -15.5); 
Example:
PHP код:
CreateDynamicCP(Float:xFloat:yFloat:zFloat:sizeworldid = -1interiorid = -1playerid = -1Float:streamdistance 100.0); 
Floattreamdistance = 100.0 - Distance player from CP, when he is in that distance CP will be shown.
Reply
#10

okay it's working perfect now

checking if on house porch

Код:
public isOnHouse(playerid)
{
	for(new i = 0; i < sizeof(HouseInfo); i++)
	{
		if (gPlayerLogged[playerid] != 0 && nearHouse[playerid] != i && standingOnHouse[playerid] != 1 && PlayerToPoint(1.6, playerid,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]) || (PlayerToPoint(3, playerid,HouseInfo[i][hExitx], HouseInfo[i][hExity], HouseInfo[i][hExitz]) && HouseInfo[i][hWorld] == GetPlayerVirtualWorld(playerid)))
		{
			nearHouse[playerid] = i;
			standingOnHouse[playerid] = 1;
			HouseEnter[i] = CreateDynamicCP(HouseInfo[i][hEntrancex],HouseInfo[i][hEntrancey],HouseInfo[i][hEntrancez], 1.5, -1, -1, -1, 100.0);
		}
	}
	return 1;
}
When leave CP

Код:
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
	for(new i = 0; i < sizeof(HouseInfo); i++)
	{
		nearHouse[playerid] = 255;
		standingOnHouse[playerid] = 0;
		DestroyDynamicCP(HouseEnter[i]);
	}
}
EnterDynamicCP

Код:
for(new i = 0; i < MAX_HOUSES;i++)
	{
		if(checkpointid == HouseEnter[i])
		{
			new pName[24];
			GetPlayerName(playerid,pName,24);
			if(HouseInfo[i][hOwned] == 1 && PlayerInfo[playerid][pHouseKey] != i)
			{
				format(string, sizeof(string), "You're standing on %s's porch.",HouseInfo[i][hOwner]); 
				SCM(playerid, COLOR_LIGHTGREEN, string);
				SCM(playerid, COLOR_WHITE, "Available commands: /enter, /ds(hout)");
			}
			if(HouseInfo[i][hOwned] == 1 && PlayerInfo[playerid][pHouseKey] == i)
			{
				SCM(playerid, COLOR_LIGHTGREEN, "You're standing on your porch.");
				SCM(playerid, COLOR_WHITE, "Available commands: /enter, /open, /setrent, /setrentable, /sellhouse");
			}
			if(HouseInfo[i][hOwned] == 0)
			{
				format(string, sizeof(string), "You're standing on free house to buy.",HouseInfo[i][hOwner]); 
				SCM(playerid, COLOR_LIGHTGREEN, string);
				SCM(playerid, COLOR_WHITE, "Available commands: /buyhouse");
			}
		}
		//Don't need it now |if(checkpointid == HouseExit[i]){}|
	}
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)