Vehicle shooter - 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: Vehicle shooter (
/showthread.php?tid=475945)
Vehicle shooter -
knackworst - 15.11.2013
Hello
I'm trying to pull of a vehicle shooter like this one:
https://sampforum.blast.hk/showthread.php?tid=417349
I tried doing this by creating the flare object when the player shoots, and then move the object, and check if the object is near any other player, if so create the explosion.
However the shooter itself does not work...
Here's my code for it:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys & KEY_FIRE)
{
if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
//AddVehicleComponent(GetPlayerVehicleID(playerid),1010);//Nitro can be added in race too
//
new Float:X, Float:Y, Float:Z, Float:Angle;
new Float:EndX, Float:EndY;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Angle);
EndX = floatcos(Angle * 1000.0);
EndY = floatsin(Angle * 1000.0);
Flare[playerid] = CreateObject(354, X, Y, Z, 0.0, 0.0, Angle); //Object will render at its default distance.
MoveObject(Flare[playerid], EndX, EndY, Z, 5.00);
FlareTimer = SetTimerEx("flare", 500, true, "i", playerid);
FlareTimeout = SetTimerEx("flaretimeout", 20000, false, "i", playerid);
//
//other
}
}
So instead of moving the object in the direction the player is currently facing, it just slowy goes to the right of the player...
Does anyone know what could be wrong with my floatsin and floatcos things?
Re: Vehicle shooter -
Pottus - 15.11.2013
pawn Код:
new Float:x, Float:y, Float:z, Float:FacingA, Float:OffSet;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, FacingA);
x = (x + OffSet * floatsin(-FacingA,degrees));
y = (y + OffSet * floatcos(-FacingA,degrees));
AW: Vehicle shooter -
Nero_3D - 15.11.2013
Just add a Angle += 90.0; before your floatcos, you just forgot that the gta angle start northern
To let that work with slopes you need to use GetVehicleRotationQuat than you need to convert that to euler angles (x, y, z)
Just search for a fitting function because I think 95% of the people here don't understand quaternion
Re: Vehicle shooter -
knackworst - 15.11.2013
Thank you both