PlayerToPoint
#1

Код:
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
Reply
#2

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;
}
Reply
#3

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

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.
Reply
#5

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
Reply
#6

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" );
}
Reply
#7

I have command /buybizz . And it returns true;
Reply
#8

Then read the IsPlayerInRangeOfPoint part I edited.
Reply
#9

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)