SA-MP Forums Archive
SetPlayerPos Not working.... - 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: SetPlayerPos Not working.... (/showthread.php?tid=233518)



SetPlayerPos Not working.... - Alex_Obando - 01.03.2011

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;
}



Re: SetPlayerPos Not working.... - grand.Theft.Otto - 01.03.2011

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?


Re: SetPlayerPos Not working.... - blackwave - 01.03.2011

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;
}



Re: SetPlayerPos Not working.... - JaTochNietDan - 01.03.2011

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.


Respuesta: SetPlayerPos Not working.... - Alex_Obando - 01.03.2011

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


Re: SetPlayerPos Not working.... - grand.Theft.Otto - 01.03.2011

For if(IsPlayerInRangeOfPoint, your coordinates are short again...


Respuesta: SetPlayerPos Not working.... - Alex_Obando - 01.03.2011

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


Re: SetPlayerPos Not working.... - JaTochNietDan - 01.03.2011

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;
}



Respuesta: SetPlayerPos Not working.... - Alex_Obando - 01.03.2011

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 )


Re: SetPlayerPos Not working.... - grand.Theft.Otto - 01.03.2011

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.