SetPlayerPos Not working....
#1

Im trying to put /enter while on the range point and then I put /enter and it doesnt teleport

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp("/enter",cmdtext))

	if(IsPlayerInRangeOfPoint(playerid, 3.0, 2935.96, 1842.19, 15.80))
    {
    SetPlayerPos(264.78, 77.62, 1001.04,0.06);
    return 1;
	}
	return 0;
}
Reply
#2

Your SetPlayerPos line is wrong.

Yours:

pawn Код:
SetPlayerPos(264.78, 77.62, 1001.04,0.06);
Should be:

pawn Код:
SetPlayerPos(playerid,264.78, 77.62, 1001.04,0.06);
Also, I don't think your coordinates are right. Can you re-paste it from your savedpostions.txt in your SAMP directory?
Reply
#3

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/enter", true))
{

    if(IsPlayerInRangeOfPoint(playerid, 3.0, 2935.96, 1842.19, 15.80))
        {
            SetPlayerPos(264.78, 77.62, 1001.04,0.06);
           
    }
        return 1;
}
    return 0;
}
Reply
#4

Well your code needs some serious indentation, it's already becoming hard to read and it's only a few lines long! Also your usage of SetPlayerPos is wrong, you're setting the position of player 264.78? That doesn't make sense, look at my example:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/enter",cmdtext))
    if(IsPlayerInRangeOfPoint(playerid, 3.0, 2935.96, 1842.19, 15.80))
    {
        SetPlayerPos(playerid, 264.78, 77.62, 1001.04);
        return 1;
    }
    return 0;
}
So then you're passing the playerid of the person that typed the command which is available in this callback, do you see what I mean?

You can keep using the shorthand if statement in this case, but I recommend using brackets to again make it structurally easier to read, like so:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/enter",cmdtext))
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 2935.96, 1842.19, 15.80))
        {
            SetPlayerPos(playerid, 264.78, 77.62, 1001.04);
        }
        return 1;
    }
    return 0;
}
Additionally if you want to change the players angle, you need to use SetPlayerFacingAngle, as SetPlayerPos only accepts the X Y Z co-ordinates.
Reply
#5

Douing /enter and it does teleport, but....The if(IsPlayerInRangeOfPoint(playerid, )) Is not working...What to do?
Reply
#6

For if(IsPlayerInRangeOfPoint, your coordinates are short again...
Reply
#7

Ok, I want this:

If the player is in this cordenates (or near):
(Cordenates from /save)

AddPlayerClass(269,2835.8623,1842.2155,15.8016,95. 1021,0,0,0,0,0,0); //

Do /enter and teleport to this cordentates:

AddPlayerClass(269,2826.1431,1852.9651,17.6838,21. 4681,0,0,0,0,0,0); //

Like, If im on LS and I do /enter dont execute the command....So Plese Help me
Reply
#8

Then you would use the first 3 co-ordinates, which are the x y z co-ordinates, and implement them, for example:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/enter",cmdtext))
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 2835.8623,1842.2155,15.8016))
        {
            SetPlayerPos(playerid, 2826.1431,1852.9651,17.6838);
        }
        return 1;
    }
    return 0;
}
Reply
#9

One thing else, Unnamed brothel (Interior Bar) I want it to teleport to it but....When I set the cordenates on the serplayerpos it doesnt teleports me to the cordenates, of the interior...
Im putting too this:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
 if(!strcmp("/enter",cmdtext))
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 2835.8623,1842.2155,15.8016))
        {
            SetPlayerPos(playerid,942.171997, -16.542755, 1000.929687);
			SetPlayerInterior(playerid, 1);
        }
        return 1;
( http://weedarr.wikidot.com/interior )
Reply
#10

Ah, you need the SetPlayerVirtualWorld function.

Add this under SetPlayerInterior...

pawn Код:
SetPlayerVirtualWorld(playerid, 1);
(0 = Regular world , 1 = Virtual world)

Also, change the Interior ID in your SetPlayerInterior function from 1 to 3 like so...

pawn Код:
SetPlayerInterior(playerid, 3);
(Unnamed brothel interior id = 3)

Altogether, your script should be like this:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/enter",cmdtext))
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 2835.8623,1842.2155,15.8016))
        {
            SetPlayerPos(playerid, 2826.1431,1852.9651,17.6838);
            SetPlayerInterior(playerid,3);
            SetPlayerVirtualWorld(playerid, 1);          
        }
        return 1;
    }
    return 0;
}
Let me know if it doesn't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)