SA-MP Forums Archive
PlayerToPoint - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: PlayerToPoint (/showthread.php?tid=224733)



PlayerToPoint - NewbBeginner - 12.02.2011

Код:
forward PlayertoPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
Код:
public PlayertoPointFloat:radi, playerid, Float:x, Float:y, Float:z)
{
	new Float:oldposx, Float:oldposy, Float:oldposz;
	new Float:tempposx, Float:tempposy, Float:tempposz;
	GetPlayerPos(playerid, oldposx, oldposy, oldposz);
	tempposx = (oldposx -x); tempposy = (oldposy -y); tempposz = (oldposz -z);
	if(((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
	{ return true; }
	return false;
}
If the player is in point then it returns as wrong command. I mean OnPlayerCommandPerformed or smth and it says wrong command. But it still does what the command needs to do. Problem is in this public


Re: PlayerToPoint - Cypress - 12.02.2011

Try this one, i'm not sure if it will do the same thing. I used this and i have no problems with it.

pawn Код:
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);

pawn Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid)){
    new Float:oldposx, Float:oldposy, Float:oldposz;
    new Float:tempposx, Float:tempposy, Float:tempposz;
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    tempposx = (oldposx -x);
    tempposy = (oldposy -y);
    tempposz = (oldposz -z);
    if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))){
    return 1;}}
    return 0;
}



Re: PlayerToPoint - Hiddos - 12.02.2011

Use IsPlayerInRangeOfPoint (https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint), it's faster.


Re: PlayerToPoint - Mean - 12.02.2011

Also, if you wanna use playertopoint, use a stock, not public, it just makes AMX bigger:
pawn Код:
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid)){
    new Float:oldposx, Float:oldposy, Float:oldposz;
    new Float:tempposx, Float:tempposy, Float:tempposz;
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    tempposx = (oldposx -x);
    tempposy = (oldposy -y);
    tempposz = (oldposz -z);
    if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))){
    return 1;}}
    return 0;
}
And delete the forward.


Re: PlayerToPoint - NewbBeginner - 12.02.2011

Still same problem. It just returns as wrong command, but it does what this command needs to do.
Or how to make such kind of command with IsPlayerInPointOfRange


Re: PlayerToPoint - Mean - 12.02.2011

Use the code you firstly posted^^, and put
pawn Код:
return true;
or
pawn Код:
return 1;
At end of your commands. Like:
pawn Код:
CMD:something( playerid, params[ ] )
{
    SendClientMessage( playerid, 0xAAAAAA, "BlaBla" );
    return 1; // This
}
Or shorter:
pawn Код:
CMD:something( playerid, params[ ] )
{
    return SendClientMessage( playerid, 0xAAAAAA, "BlaBla" );
}
But you need to return something else than 0. OnPlayerCommandText will return 0 if you don't put any return upthere.

And for IsPlayerInRangeOfPoint:
pawn Код:
if( IsPlayerInRangeOfPoint( playerid, 5.0, 0.0, 0.0, 0.0 ) )
{
    SendClientMessage( playerid, 0xAAAAAA, "You are in range of 5 meters in the position: X: 0.0, Y: 0.0 and Z: 0.0" );
}
else
{
    SendClientMessage( playerid, 0xAAAAAA, "You are not in range of 5 meter for the X: 0.0, Y: 0.0 and Z: 0.0" );
}



Re: PlayerToPoint - NewbBeginner - 12.02.2011

I have command /buybizz . And it returns true;


Re: PlayerToPoint - Mean - 12.02.2011

Then read the IsPlayerInRangeOfPoint part I edited.


Re: PlayerToPoint - NewbBeginner - 12.02.2011

I looked and tried, but it still returns as wrong command . Im going to check my command, and add clientmessages.


Re: PlayerToPoint - Hiddos - 12.02.2011

Post the command and corresponding code by the way, this way we aren't able to offer any help lol.