Ramp 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: Ramp Problem (
/showthread.php?tid=371685)
Ramp Problem[+rep] -
ZBits - 24.08.2012
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
Re: Ramp Problem -
ZBits - 24.08.2012
Bump
Re: Ramp Problem -
AqEeNo - 24.08.2012
It's not working because you forgot to assign Float:Ang (angle) variable.
Re: Ramp Problem -
ZBits - 24.08.2012
same problem
Re: Ramp Problem -
AqEeNo - 24.08.2012
Ups my fault,it would just roate object xd
Re: Ramp Problem -
ZBits - 24.08.2012
HELP
Re: Ramp Problem -
ZBits - 24.08.2012
Please help
Re: Ramp Problem -
Ranama - 24.08.2012
use
https://sampwiki.blast.hk/wiki/GetVehicleZAngle like:
Код:
GetPlayerFacingAngle(playerid, Ang);
//then it should work.
Hope it helped
Re: Ramp Problem -
JaKe Elite - 24.08.2012
Try getting player's facing angle.
Then set the object facing angle to player's facing angle.
Re: Ramp Problem -
Riddick94 - 24.08.2012
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));
}