IsPlayerInRangeOfPoint problem :/ -
knackworst - 04.11.2011
Hello for my race system I'm making something simular to I99 race system, when a player gets in range of a starting point of a race there will be a racecheckpoint and a gametext that says, ur at the startging point of... blahblah
ok so heres the code:
pawn Код:
public OnPlayerUpdate(playerid)
{
//==============================================================================
//Race CheckPoint showing
//==============================================================================
for(new i; i<sizeof(rInfo); i++)
{
if(rInfo[i][rRacing][playerid] == false && rInfo[i][rInRange][playerid] == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 20.0, rInfo[i][rCheckPoint_X][0], rInfo[i][rCheckPoint_Y][0], rInfo[i][rCheckPoint_Z][0]))
{
new string[128];
SetPlayerRaceCheckpoint(playerid, 0, rInfo[i][rCheckPoint_X][0], rInfo[i][rCheckPoint_Y][0], rInfo[i][rCheckPoint_Z][0], rInfo[i][rCheckPoint_X][1], rInfo[i][rCheckPoint_Y][1], rInfo[i][rCheckPoint_Z][1], 10.0);
format(string, sizeof(string), "~y~You are at the startpoint of the race~n~~r~%s ~n~~y~type /startrace to start this race", rInfo[i][rName]);
GameTextForPlayer(playerid, string, 5000, 5);
rInfo[i][rInRange][playerid] = 1;
}
else
{
DisablePlayerRaceCheckpoint(playerid);
rInfo[i][rInRange][playerid] = 0;
}
}
}
return 1;
}
I don't really see what is wrong with this code...
ok so the problems, it doesn't matter how much I change the radius of IsPlayerInRangeOfPoint the RaceCheckPoint will always show up on the same distance... wich is about 10 and u can see I set it to 20 but it still is 10 ingame...
also when the checkpoint was shown sometimes the gametext dissapears immediately...
and a third problem when I'm not near the checkpoint no more (f.e: about 400 meters away from it, the checkpoint is still visable...
NOTE: there's no problem with the chords, nor is there one with the other info from the rInfo array...
thanks in advance
rep for helper!
Re: IsPlayerInRangeOfPoint problem :/ -
Stigg - 04.11.2011
Try setting up a timer to test it instead of using OnPlayerUpdate. See if that helps.
Re: IsPlayerInRangeOfPoint problem :/ -
knackworst - 04.11.2011
pawn Код:
public NearRaceCheck(playerid)
{
//==============================================================================
//Race CheckPoint showing
//==============================================================================
for(new i; i<sizeof(rInfo); i++)
{
if(rInfo[i][rRacing][playerid] == false && rInfo[i][rInRange][playerid] == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 20.0, rInfo[i][rCheckPoint_X][0], rInfo[i][rCheckPoint_Y][0], rInfo[i][rCheckPoint_Z][0]))
{
new string[128];
SetPlayerRaceCheckpoint(playerid, 0, rInfo[i][rCheckPoint_X][0], rInfo[i][rCheckPoint_Y][0], rInfo[i][rCheckPoint_Z][0], rInfo[i][rCheckPoint_X][1], rInfo[i][rCheckPoint_Y][1], rInfo[i][rCheckPoint_Z][1], 10.0);
format(string, sizeof(string), "~y~You are at the startpoint of the race~n~~r~%s ~n~~y~type /startrace to start this race", rInfo[i][rName]);
GameTextForPlayer(playerid, string, 5000, 5);
rInfo[i][rInRange][playerid] = 1;
}
else
{
DisablePlayerRaceCheckpoint(playerid);
rInfo[i][rInRange][playerid] = 0;
}
}
}
return 1;
}
pawn Код:
forward NearRaceCheck(playerid); //Timer to check wheter a player is near a race to display the CP
pawn Код:
SetTimer("NearRaceCheck", 200, true); //1/5 seconds
Same effect only, the gametext works now, but that's not the biggest problem...
Re: IsPlayerInRangeOfPoint problem :/ -
Stigg - 04.11.2011
Just for testing purposes try:
pawn Код:
if(rInfo[i][rRacing][playerid] == false)
Re: IsPlayerInRangeOfPoint problem :/ -
knackworst - 04.11.2011
pawn Код:
public NearRaceCheck(playerid)
{
//==============================================================================
//Race CheckPoint showing
//==============================================================================
for(new i; i<sizeof(rInfo); i++)
{
if(rInfo[i][rRacing][playerid])// == false && rInfo[i][rInRange][playerid] == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 20.0, rInfo[i][rCheckPoint_X][0], rInfo[i][rCheckPoint_Y][0], rInfo[i][rCheckPoint_Z][0]))
{
new string[128];
SetPlayerRaceCheckpoint(playerid, 0, rInfo[i][rCheckPoint_X][0], rInfo[i][rCheckPoint_Y][0], rInfo[i][rCheckPoint_Z][0], rInfo[i][rCheckPoint_X][1], rInfo[i][rCheckPoint_Y][1], rInfo[i][rCheckPoint_Z][1], 10.0);
format(string, sizeof(string), "~y~You are at the startpoint of the race~n~~r~%s ~n~~y~type /startrace to start this race", rInfo[i][rName]);
GameTextForPlayer(playerid, string, 5000, 5);
rInfo[i][rInRange][playerid] = 1;
}
else
{
DisablePlayerRaceCheckpoint(playerid);
rInfo[i][rInRange][playerid] = 0;
}
}
}
return 1;
}
now it doesn't even show the checkpoint :/
isn't there an alternative way of doing the thing that I need?