IsPlayerInRangeOfPoint -
Levtu - 24.07.2013
Hi guys.
I loaded
balloon script and add function IsPlayerInRangeOfPoint, don't know why message don't show in the chat.
I tried:
pawn Код:
public OnPlayerSpawn(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 836.1324,-1976.8779,12.4362))
{
SendClientMessage(playerid,0xFFFFFFFF,"You are near the balloon, type /fly to control balloon.");
}
SetPlayerPos(playerid,834.964,-2040.216,12.867);
return 1;
}
and
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/lec", cmdtext, true, 10) == 0)
{
PlayerInfo[playerid][BalloonPlayer] = 1;
SendClientMessage(playerid,GREEN,"Kontrolowany || Użyj /list by kontrolować latający balon. || /stop || /powrot aby przywrуcić balon na pozycję startową.");
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 836.1324,-1976.8779,12.4362))
{
SendClientMessage(playerid,0xFFFFFFFF,"You are near the balloon, type /fly to control balloon.");
}
}
return 1;
}
Now works. Any ideas?
Re: IsPlayerInRangeOfPoint -
Pottus - 24.07.2013
Well, after reviewing that balloon script it will cause some real desync problems moving it around it's not scripted correctly. Anyways I don't think you have that code in the right spot you would have to spawn within 7 meters of the balloon to see the text.
I would make a stock like this
pawn Код:
stock IsNearBalloon(playerid, Float:range = 7.0)
{
new Float:x, Float:y, Float:z;
GetObjectPos(Balloon, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, range, x, y ,z)) return 1;
return 0;
}
To fix the desync issues you need to set the balloon position when you get the position this will prevent desync issues for clients.
pawn Код:
public MoveBalloonRight()
{
new Float:X,Float:Y,Float:Z;
GetObjectPos(Balloon,X,Y,Z);
MoveObject(Balloon,X+0.5,Y,Z,10.0);
return 1;
}
Update all these like this to fix desync issues as redundant as it seems it will keep the balloon synced for all client.
pawn Код:
public MoveBalloonRight()
{
new Float:X,Float:Y,Float:Z;
GetObjectPos(Balloon,X,Y,Z);
SetObjectPos(Balloon,X,Y,Z);
MoveObject(Balloon,X+0.5,Y,Z,10.0);
return 1;
}
Re: IsPlayerInRangeOfPoint -
Levtu - 24.07.2013
Updated. But how to add this stock? ^^ I am really newbie about pawno.