timer for dynamic cp -
PaulDinam - 30.11.2012
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
Re: timer for dynamic cp -
DaRk_RaiN - 30.11.2012
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;
}
Re: timer for dynamic cp -
PaulDinam - 30.11.2012
but it will send him a message non stop i want 1 time.
Re: timer for dynamic cp -
park4bmx - 30.11.2012
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
Re: timer for dynamic cp -
DaRk_RaiN - 30.11.2012
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.
Re: timer for dynamic cp -
PaulDinam - 30.11.2012
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;
}
Re: timer for dynamic cp -
PaulDinam - 30.11.2012
HELP SOMEONE?
Re: timer for dynamic cp -
GWMPT - 30.11.2012
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.
Re: timer for dynamic cp -
B-Matt - 30.11.2012
Use this:
PHP код:
CreateDynamicCP(xPos, yPos, zPos, 1.5, -1, -1, -1, 5.5);
Example:
PHP код:
CreateDynamicCP(Float:x, Float:y, Float:z, Float:size, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 100.0);
Float
treamdistance = 100.0 - Distance player from CP, when he is in that distance CP will be shown.
Re: timer for dynamic cp -
PaulDinam - 30.11.2012
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]){}|
}