Vehicle shooter
#1

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?
Reply
#2

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));
Reply
#3

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
Reply
#4

Thank you both
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)