[FilterScript] Satchelfix
#1

Hi there!

Somewhere, I heard satchels were desynced. Upon deploying one, it will only be synced for everyone who was in range of the deployed satchel.

This will (hopefully) fix this. Basically, it determines the position of the deployed satchel and stores the coordinates in a detonatable explosion.

It is untested, so feel free to post some comments about your experiences.

Code:
#include <a_samp>
#include <ZCMD>


#define COLOR_GRAD2	0xB4B5B7FF
#define MAX_BOMBS 5
#define DIALOG_SATCHEL 10000



new Float:p_Bomb[MAX_BOMBS][MAX_PLAYERS][3];
new a_Bomb[MAX_PLAYERS] = 0;
/*
CMD:bsatchel(playerid, params[])
{
	return GivePlayerWeapon(playerid, 39, 1);
}	
*/

CMD:satchel(playerid, params[])
{
	return ShowPlayerDialog(playerid, DIALOG_SATCHEL, DIALOG_STYLE_INPUT, "Bomb selection menu", "Amount of bombs:", "Choose", "Cancel");
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) 
{
	switch(dialogid)
	{
		case DIALOG_SATCHEL:
		{
			if(!isnull(inputtext))
			{
				if(strval(inputtext) <= MAX_BOMBS)
				{
					GivePlayerWeapon(playerid, 39, strval(inputtext));
				}
				else return SendClientMessage(playerid, COLOR_GRAD2, "You can't take that many bombs with you.");
			}
			return 1;
		}
	}
	return 0;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE))
	{
		if(GetPlayerWeapon(playerid) == 39)
		{
			switch(a_Bomb[playerid])
			{
				case 0:
				{
					GetPlayerPos(playerid, p_Bomb[playerid][a_Bomb[playerid]][0], p_Bomb[playerid][a_Bomb[playerid]][1], p_Bomb[playerid][a_Bomb[playerid]][2]);
					GetXYInFrontOfPlayer(playerid, p_Bomb[playerid][0][0], p_Bomb[playerid][0][1], 2.0); // Satchel throw distance = 2.0 in this example.

				}
				case 1:
				{
					GetPlayerPos(playerid, p_Bomb[playerid][a_Bomb[playerid]][0], p_Bomb[playerid][a_Bomb[playerid]][1], p_Bomb[playerid][a_Bomb[playerid]][2]);
					GetXYInFrontOfPlayer(playerid, p_Bomb[playerid][a_Bomb[playerid]][0], p_Bomb[playerid][a_Bomb[playerid]][1], 2.0); // Satchel throw distance = 2.0 in this example.
				}
				case 2:
				{
					GetPlayerPos(playerid, p_Bomb[playerid][a_Bomb[playerid]][0], p_Bomb[playerid][a_Bomb[playerid]][1], p_Bomb[playerid][a_Bomb[playerid]][2]);
					GetXYInFrontOfPlayer(playerid, p_Bomb[playerid][a_Bomb[playerid]][0], p_Bomb[playerid][a_Bomb[playerid]][1], 2.0); // Satchel throw distance = 2.0 in this example.
				}
				case 3:
				{
					GetPlayerPos(playerid, p_Bomb[playerid][a_Bomb[playerid]][0], p_Bomb[playerid][a_Bomb[playerid]][1], p_Bomb[playerid][a_Bomb[playerid]][2]);
					GetXYInFrontOfPlayer(playerid, p_Bomb[playerid][a_Bomb[playerid]][0], p_Bomb[playerid][a_Bomb[playerid]][1], 2.0); // Satchel throw distance = 2.0 in this example.
				}
				case 4:
				{
					GetPlayerPos(playerid, p_Bomb[playerid][a_Bomb[playerid]][0], p_Bomb[playerid][a_Bomb[playerid]][1], p_Bomb[playerid][4][2]);
					GetXYInFrontOfPlayer(playerid, p_Bomb[playerid][a_Bomb[playerid]][0], p_Bomb[playerid][a_Bomb[playerid]][1], 2.0); // Satchel throw distance = 2.0 in this example.
				}
			}
			a_Bomb[playerid]++;
			SetPVarInt(playerid, "Bomb", 1);
		}
		if(GetPlayerWeapon(playerid) == 40 && GetPVarInt(playerid, "Bomb") == 1)
		{
			SetPVarInt(playerid, "Bomb", 0);
			for(new i; i < MAX_BOMBS; ++i)
			{
				CreateExplosion(p_Bomb[playerid][i][0], p_Bomb[playerid][i][1], p_Bomb[playerid][i][2], 6, 10.0); // Explosion range = 10
				a_Bomb[playerid] = 0;
			}
		}
	}
	return 1;
}

			

			
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));
}
Cheers,
Jingles
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)