SA-MP Forums Archive
Boombox bugged - 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: Boombox bugged (/showthread.php?tid=484445)



Boombox bugged - Antoniohl - 30.12.2013

Something is wrong with boombox Actually when i place a boombox and picking it up it doesn't want to disappear, is there a problem with this code?

Код:
dcmd_placeboombox(playerid, params[])
{
	if(PlayerInfo[playerid][pBoomBox] == 0) return SendClientMessage(playerid, COLOR_WHITE, "You don't have a BoomBox");
	if(GetPVarType(playerid, "pDynamicBB")) return SendClientMessage(playerid, COLOR_WHITE, "You already have a boombox out, use /pickupboombox.");

	foreach(Player, i)
	{
 		if(GetPVarType(i, "pDynamicBB"))
   		{
  			if(IsPlayerInRangeOfPoint(playerid, 30.0, GetPVarFloat(i, "pDynamicBBX"), GetPVarFloat(i, "pDynamicBBY"), GetPVarFloat(i, "pDynamicBBZ")))
			{
   				SendClientMessage(playerid, COLOR_WHITE, "You cannot put your boombox in this Radius");
			    return 1;
			}
		}
		new string[128];
		format(string, sizeof(string), "%s has placed a boombox on the floor!", SenderName(playerid));
		SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);

	    new Float:x, Float:y, Float:z, Float:a;
	    GetPlayerPos(playerid, x, y, z);
	    GetPlayerFacingAngle(playerid, a);
	    ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
	    x += (2 * floatsin(-a, degrees));
    	y += (2 * floatcos(-a, degrees));
    	z -= 1.0;

	    SetPVarInt(playerid, "pDynamicBB", CreateDynamicObject(2226, x, y, z, 0.0, 0.0, 0.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
	    SetPVarFloat(playerid, "pDynamicBBX", x); SetPVarFloat(playerid, "pDynamicBBY", y); SetPVarFloat(playerid, "pDynamicBBZ", z);
		format(string, sizeof(string), "{00FF00}Boombox Owner:{FFFFFF}%s\n{FF0000}/turnon{FFFFFF} to set your boombox \n{FFFF00}or\n{FF0000}/pickupboombox", SenderName(playerid));
	    SetPVarInt(playerid, "pDynamicBBLabel", _:CreateDynamic3DTextLabel(string, COLOR_WHITE, x, y, z+0.6, 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
		SetPVarInt(playerid, "pDynamicBBArea", CreateDynamicSphere(x, y, z, 30.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
		SetPVarInt(playerid, "pDynamicBBInt", GetPlayerInterior(playerid));
		SetPVarInt(playerid, "pDynamicBBVW", GetPlayerVirtualWorld(playerid));
	}
	return 1;
}

dcmd_pickupboombox(playerid, params[])
{
	if(GetPVarType(playerid, "pDynamicBB"))
	{
	    if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) return SendClientMessage(playerid, COLOR_WHITE, " You must be crouched to pick a the boombox.");
	    if(!IsPlayerInRangeOfPoint(playerid, 3.0, GetPVarFloat(playerid, "pDynamicBBX"), GetPVarFloat(playerid, "pDynamicBBY"), GetPVarFloat(playerid, "pDynamicBBZ"))) return SendClientMessage(playerid, COLOR_WHITE, "You're not near in your BoomBox");
	    DestroyDynamicObject(GetPVarInt(playerid, "pDynamicBB"));
	    DestroyDynamic3DTextLabel(Text3D:GetPVarInt(playerid, "pDynamicBBLabel"));
	    DeletePVar(playerid, "pDynamicBB"); DeletePVar(playerid, "pDynamicBBStation"); DeletePVar(playerid, "pDynamicBBLabel");
	    DeletePVar(playerid, "pDynamicBBX"); DeletePVar(playerid, "pDynamicBBY"); DeletePVar(playerid, "pDynamicBBZ");
	    if(GetPVarType(playerid, "pDynamicBBArea"))
	    {
	        new string[128];
			format(string, sizeof(string), "* %s has pickedup their boombox.", SenderName(playerid));
			SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	        foreach(Player, i)
			{
	            if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "pDynamicBBArea")))
	            {
	                StopAudioEx(i);
	                SendClientMessage(i, COLOR_PURPLE, string);
				}
			}
	        DeletePVar(playerid, "pDynamicBBArea");
		}
		SendClientMessage(playerid, COLOR_WHITE, "You've pickedup your boombox!");
	}
	else
	{
	    foreach(Player, i)
		{
	        if(GetPVarType(i, "pDynamicBB"))
	        {
				if(GetPVarInt(i, "pDynamicBBVW") == GetPlayerVirtualWorld(playerid) && GetPVarInt(i, "pDynamicBBInt") == GetPlayerInterior(playerid) && IsPlayerInRangeOfPoint(playerid, 5.0, GetPVarFloat(i, "pDynamicBBX"), GetPVarFloat(i, "pDynamicBBY"), GetPVarFloat(i, "pDynamicBBZ")))
				{
				    if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) return SendClientMessage(playerid, COLOR_WHITE, " You must be crouched to pick a the boombox.");
				    if(!IsPlayerInRangeOfPoint(playerid, 3.0, GetPVarFloat(playerid, "pDynamicBBX"), GetPVarFloat(playerid, "pDynamicBBY"), GetPVarFloat(playerid, "pDynamicBBZ"))) return SendClientMessage(playerid, COLOR_WHITE, "You're not near in your BoomBox");
				    DestroyDynamicObject(GetPVarInt(i, "pDynamicBB"));
				    DestroyDynamic3DTextLabel(Text3D:GetPVarInt(i, "pDynamicBBLabel"));

				    DeletePVar(i, "pDynamicBB");
					DeletePVar(i, "pDynamicBBStation");
					DeletePVar(i, "pDynamicBBLabel");
				    DeletePVar(i, "pDynamicBBX");
					DeletePVar(i, "pDynamicBBY");
					DeletePVar(i, "pDynamicBBZ");
					DeletePVar(i, "pDynamicBBInt");
					DeletePVar(i, "pDynamicBBVW");

				    new string[128];
				    if(GetPVarType(i, "pDynamicBBArea"))
				    {
				        for(new x=0; x<MAX_PLAYERS; x++)
						{
				            if(IsPlayerInDynamicArea(x, GetPVarInt(x, "pDynamicBBArea")))
				            {
				                StopAudioEx(x);
				                SendClientMessage(x, COLOR_PURPLE, string);
							}
						}
				        DeletePVar(i, "pDynamicBBArea");
					}
					return 1;
				}
			}
	    }
	    SendClientMessage(playerid, COLOR_WHITE, "You don't have a boombox or you are not near one to be pickup");
	}
	return 1;
}



Re: Boombox bugged - NikO1 - 30.12.2013

if that code compiles then theres nothing wrong with it.


Re: Boombox bugged - PrivatioBoni - 30.12.2013

Quote:
Originally Posted by NikO1
Посмотреть сообщение
if that code compiles then theres nothing wrong with it.
Not true. Just because it compiles without errors doesn't mean it works as intended.


Re: Boombox bugged - Antoniohl - 30.12.2013

Thanks ,problem resloved