SA-MP Forums Archive
GetPosInFrontOfPlayer - 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: GetPosInFrontOfPlayer (/showthread.php?tid=325872)



GetPosInFrontOfPlayer - SnG.Scot_MisCuDI - 15.03.2012

Im using GetPosInFrontOfPlayer to detect where to set the players pos on leaving the checkpoint. But its spawning me underground because the z is set to 0.

How its saving


stock
pawn Код:
stock Float:GetPosInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    switch(IsPlayerInAnyVehicle(playerid))
    {
        case 0: GetPlayerFacingAngle(playerid, a);
        case 1: GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
    return a;
}
saving
pawn Код:
dini_FloatSet(file, "SpawnOutX", X);
    dini_FloatSet(file, "SpawnOutY", Y);
    dini_FloatSet(file, "SpawnOutZ", Z);
Код:
Name=SnG.Scot_MisCuDi
Owner=SnG.Scot_MisCuDi
Cost=10000
Payout=10000
BusX=-1877.430786
BusY=1305.010742
BusZ=7.179687
SpawnOutX=-1879.213989
SpawnOutY=1306.762817
SpawnOutZ=0.000000
World=0
Interior=0
OwnedBus=1
HasOwner=1



Re: GetPosInFrontOfPlayer - eesh - 15.03.2012

set Z same as players original z