Ramp Problem
#1

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(newkeys == KEY_ACTION)
        {
            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                if(RampActivated[playerid] == 1)
                {
                    if(Ramp[playerid] != -1)
                    {
                         DestroyObject(Ramp[playerid]);
                         KillTimer(RampTimer[playerid]);
                    }
                    new Float:X, Float:Y, Float:Z, Float:Ang;
                    GetPlayerPos(playerid, X, Y, Z);
                    GetXYInFrontOfPlayer(playerid, X, Y, 5);
                    Ramp[playerid] = CreateObject(1503, X, Y, Z, 0.0, 0.0, Ang); //Replace ObjID with the ramp object ID
                    RampTimer[playerid] = SetTimerEx("RemoveRamp", 5000, false, "i", playerid);
                }
            }
        }
    }
    return 1;
}

stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);
    if (GetPlayerVehicleID(playerid))
    {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
this is a Code which spawns Ramp if i press the Left ctrl and it completely works but the problem is when ever i go towards West, East,South The ramp spawns towards the North Always

Just a Quick help
Reply
#2

Bump
Reply
#3

It's not working because you forgot to assign Float:Ang (angle) variable.
Reply
#4

same problem
Reply
#5

Ups my fault,it would just roate object xd
Reply
#6

HELP
Reply
#7

Please help
Reply
#8

use https://sampwiki.blast.hk/wiki/GetVehicleZAngle like:

Код:
GetPlayerFacingAngle(playerid, Ang);
//then it should work.
Hope it helped
Reply
#9

Try getting player's facing angle.
Then set the object facing angle to player's facing angle.
Reply
#10

Check:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(newkeys == KEY_ACTION)
        {
            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                if(RampActivated[playerid] == 1)
                {
                    if(Ramp[playerid] != -1)
                    {
                         DestroyObject(Ramp[playerid]);
                         KillTimer(RampTimer[playerid]);
                    }
                    new Float:X, Float:Y, Float:Z, Float:Ang;
                    GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z);
                    GetVehicleZAngle(GetPlayerVehicleID(playerid), Ang);
                    GetXYInFrontOfPlayer(playerid, X, Y, 5.0);
                    Ramp[playerid] = CreateObject(1503, X, Y, Z, 0.0, 0.0, Ang); //Replace ObjID with the ramp object ID
                    RampTimer[playerid] = SetTimerEx("RemoveRamp", 5000, false, "i", playerid);
                }
            }
        }
    }
    return 1;
}

stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);
    if (GetPlayerVehicleID(playerid))
    {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)