15.11.2013, 19:52
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:
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?
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
}
}
Does anyone know what could be wrong with my floatsin and floatcos things?