SA-MP Forums Archive
SetPlayerPos problem - 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)
+--- Thread: SetPlayerPos problem (/showthread.php?tid=359796)



SetPlayerPos problem - Superthijs - 15.07.2012

Hi, how do I set a player's X and Y positon only, not the Z one?
Because when I use SetPlayerPos(x, y, z) while skydiving, the player dies instantly,
even when I use the same z position that he is at.


Re: SetPlayerPos problem - Faisal_khan - 15.07.2012

So you mean you want to set the players position to the lowest Z co-ordinate i.e. the ground? Well there is a plugin as well as an include for that the plugin name is MapAndreas the include name is also somewhat same try searching the forums for it. Its on you what you wanna choose plugin or include. I will prefer include since it consumes less memory and is of less KB's while the plugin is 22 MB and it consumes some near 70 MB of your memory.

Wish you luck!


Re: SetPlayerPos problem - Superthijs - 15.07.2012

No, I mean when I use SetPlayerPos while falling/skydiving, the player dies like he hit the ground, but is still in mid-air.


Re: SetPlayerPos problem - Andi_Evandy - 15.07.2012

pawn Код:
new Float:pX, Float:pY, Float:pZ;
    GetPlayerPos(playerid, pX, pY, pZ);
    SetPlayerPos(playerid, /*X Position*/, /*Y Position*/, pZ);



Re: SetPlayerPos problem - clarencecuzz - 15.07.2012

You need to remove the parachute before you SetPlayerPos.

Example:
pawn Код:
ResetPlayerWeapons(playerid);
SetPlayerPos(playerid, X, Y, Z);
And you can use:
pawn Код:
SetPlayerPosFindZ(playerid, X, Y, Z);
So the player will automatically teleport to the ground below the X and Y cord specified.


Re: SetPlayerPos problem - [MM]RoXoR[FS] - 15.07.2012

Hi, wiki said that Players will die if teleported while diving with a parachute. (WEAPON ID PAGE)

I made a quick test code to teleport player with killing them using timers.

Edit it according to your needs
Full Code :
pawn Код:
new weapons[13][2];
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/para", cmdtext, true, 10) == 0)
    {
        GivePlayerWeapon(playerid,46,1);
        SetPlayerPos(playerid,0,0,100000);
        return 1;
    }

    else if (strcmp("/pos", cmdtext, true, 10) == 0)
    {
        for (new i = 0; i < 13; i++)
        {
            GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
        }
        ResetPlayerWeapons(playerid);
        SetPlayerPos(playerid,1000,-500,1000);
        SetTimerEx("ChangePos",500,false,"i",playerid);
        return 1;
    }
    return 0;
}

forward ChangePos(playerid);
public ChangePos(playerid)
{
    for (new i = 0; i < 13; i++)
    {
        GivePlayerWeapon(playerid,weapons[i][0], weapons[i][1]);
    }
    return 1;
}



Re: SetPlayerPos problem - leonardo1434 - 15.07.2012

Quote:
Originally Posted by Samp-Wiki
Players will die if teleported while diving with a parachute.
Parachutes are given when bailing out of aircraft. (be aware of this for Anti-Cheats)
To solve that, just use this function, it remove the player's weapon. i've made a little example, but you could make some calc's to check if he's mid air, i'am too lazy to do.

pawn Код:
stock RemovePlayerWeapon(p,weaponid)
{
    new l_arma[12],l_muni[12],l_arma2,l_muni2;
    for(new Tslots = 0; Tslots != 12;Tslots++ )
    {
        GetPlayerWeaponData(p,Tslots,l_arma2,l_muni2);
        if(l_arma2!= weaponid)GetPlayerWeaponData(p,Tslots,l_arma[Tslots],l_muni[Tslots]);
    }
    ResetPlayerWeapons(p);
    for(new Tslots = 0;Tslots != 12;Tslots++)GivePlayerWeapon(p,l_arma[Tslots],l_muni[Tslots]);
    return 1;
}
how to use that?
pawn Код:
CMD:setpos(playerid,params[])
{
    new
        Float:l_x,
        Float:l_y,
        Float:l_z,
        id;
    if(sscanf(params,"uiii",id,l_x,l_y,l_z))return SendClientMessage(playerid,-1,"/setpos [id] [X] [Y] [Z]");
    if(GetPlayerWeapons(id) == 46) RemovePlayerWeapon(id,46);
    SetPlayerPos(id,,l_x,l_y,l_z);
    return 1;
}



Re: SetPlayerPos problem - Superthijs - 15.07.2012

Thanks to all of you!