IsPlayerInRangeOfPoint Problem -
JackBurgani - 21.04.2013
I have this function set up to a tiimer to actively scan if the player is in a given checkpoint, problem is, it always returns 0, even though I use the same coordinates for a command that requires that space and that works fine. The value that's passed through the timer and into the function isn't being read either. Any ideas?
pawn Код:
new robberytimers[MAX_PLAYERS];
new PlayerText:CountDown[MAX_PLAYERS];
//blah blah blah
dcmd_robauto(playerid, params[])
{
//if(strlen(params)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/robauto\"");
if(IsPlayerInRangeOfPoint(playerid, 3.0, 2200.2834, 1393.2366, 10.8203))
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER && GetPlayerState(playerid) != PLAYER_STATE_PASSENGER)
{
if(autoRobTime[playerid] < gettime())
{
//SetTimerEx("IsInCheckPointe", 1000, true, %d, %d, %d, %d, %d, playerid, 2200.2834, 1393.2366, 10.8203, 3);
autoRobTime[playerid] = gettime()+ 120;
robbingauto(playerid, 30);
//new moneywon = random(30000)+30000;
//robskill[playerid]++;
//SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
//GivePlayerMoney(playerid, moneywon);
//format(robskillstring, sizeof(robskillstring), "You're robskill is now: %i, and you've stolen $%i.", robskill[playerid], moneywon);
//SendClientMessage(playerid, 0xAAAAAAAA, robskillstring);
//SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+ 4);
} else {
SendClientMessage(playerid,0xAAAAAAAA, "You've just robbed the place; there is no more cash");
}
} else {
SendClientMessage(playerid, 0xAAAAAAAA, "Robbing the place in a vehicle is proving to be too hard..Try getting out and trying again.");
}
} else {
SendClientMessage(playerid, 0xAAAAAAAA, "You must be at an AutoBahn to rob it silly!");
}
return 1;
}
/ blah blah blah
forward robbingauto(playerid, countdownfrom);
public robbingauto(playerid, countdownfrom)
{
new stringah[5];
format(stringah, 5, "%i", countdownfrom);
CountDown[playerid] = CreatePlayerTextDraw(playerid, 250.0, 250.0, stringah);
PlayerTextDrawFont(playerid, CountDown[playerid], 3);
PlayerTextDrawLetterSize(playerid, CountDown[playerid], 0.499999,1.600000);
PlayerTextDrawColor(playerid, CountDown[playerid], 0xffffffff);
PlayerTextDrawShow(playerid, CountDown[playerid]);
printf("String: %i Playerid: %i CountDown: %i", countdownfrom, playerid, CountDown[playerid]);
robberytimers[playerid] = SetTimerEx("setcounter", 1000, true, "i", "i", playerid, countdownfrom);
}
/bla h blah blah
forward setcounter(playerid, countdownfrom);
public setcounter(playerid, countdownfrom)
{
new counters[57];
if(IsPlayerInRangeOfPoint(playerid, 3.0, 2200.2834, 1393.2366, 10.8203))
{
format(counters, 57, "%i", countdownfrom);
countdownfrom--;
PlayerTextDrawSetString(playerid, CountDown[playerid], counters);
if(countdownfrom <= 0)
{
GivePlayerMoney(playerid, 50000);
PlayerTextDrawDestroy(playerid, CountDown[playerid]);
KillTimer(robberytimers[playerid]);
}
} else {
SendClientMessage(playerid, 0xFF0000AA, "Robbery Failed");
PlayerTextDrawDestroy(playerid, CountDown[playerid]);
KillTimer(robberytimers[playerid]);
}
}
The command "/robauto" works as it should, it executes when you're in given checkpoint and doesn't if you aren't. What's up? Also the countdownfrom doesn't stay over. Forgive me for the sloppyness, I kinda tore it up trying to fix it :L
Re: IsPlayerInRangeOfPoint Problem -
JackBurgani - 21.04.2013
Also, is it normal for it to report playerid as 105 when I'm the only player in the server? I'd expect the player id to be 0. What's going on here?
Re: IsPlayerInRangeOfPoint Problem -
Pottus - 21.04.2013
robberytimers[playerid] = SetTimerEx("setcounter", 1000, true, "i", "i", playerid, countdownfrom);
robberytimers[playerid] = SetTimerEx("setcounter", 1000, true, "ii", playerid, countdownfrom);
Re: IsPlayerInRangeOfPoint Problem -
JackBurgani - 21.04.2013
Wow, thanks! Never would've guessed that.
Re: IsPlayerInRangeOfPoint Problem -
JackBurgani - 21.04.2013
It does bring me up to another problem, the counter value freezes when I try to decrement it by 1, this fixes if I get rid of the countdown values altogether and declare it globally, but I really don't want to do it that way. Any way to declare the variable locally and have the setcounter not keep resetting the value? Thanks in advanced
Re: IsPlayerInRangeOfPoint Problem -
Vince - 21.04.2013
Why don't you use OnPlayerEnterCheckpoint/OnPlayerLeaveCheckpoint? Or the streamer equivalent?
Re: IsPlayerInRangeOfPoint Problem -
JackBurgani - 21.04.2013
Scratch that, I think I get what you're saying, could you explain what you meant by streamer equivalent or give a link?