Problem with audio and tag mismatch.
#1

Hello, I'd like to get help with my script, it's a bit edited "Simple boombox system".
I just added 3D text, changed language and fixed some bugs. Problem is that everything works but music won't play for anyone. Also compiler gives me 3 warnings about tag mismatch.

Код:
(29) : warning 213: tag mismatch
(69) : warning 213: tag mismatch
(86) : warning 213: tag mismatch
Full code of script:
Код:
#define FILTERSCRIPT
// Incl
#include <a_samp>
#include <streamer>
#include <foreach>
#include <zcmd>
#include <sscanf2>

// Defs
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_RED 0xFF0000FF
#define COLOR_LIGHTBLUE 0x33CCFFFF
#define COLOR_GREY 0xAFAFAFFF

public OnPlayerConnect(playerid)
{
    DeletePVar(playerid, "BoomboxObject"); DeletePVar(playerid, "BoomboxURL");
    DeletePVar(playerid, "bposX"); DeletePVar(playerid, "bposY"); DeletePVar(playerid, "bposZ"); DeletePVar(playerid, "bboxareaid");
    DeletePVar(playerid, "author");
    if(IsValidDynamicObject(GetPVarInt(playerid, "BoomboxObject"))) DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
    return 1;
}

public OnPlayerDisconnect(playerid)
{
	if(GetPVarType(playerid, "BoomboxObject"))
	{
		DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
		DestroyDynamic3DTextLabel(GetPVarInt(playerid, "author"));
		if(GetPVarType(playerid, "bboxareaid"))
		{
   			foreach(new i : Player)
		    {
		    	if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
		        {
		        	StopAudioStreamForPlayer(i);
				}
			}
		}
	}
	return 1;
}

CMD:speaker(playerid, params[])
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[GrandProject] Для доступа к данной команде нужен клиренс RCON уровня.");
	new string[128];
	if(!GetPVarType(playerid, "BoomboxObject"))
	{
	    if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_RED, "[SH-SS][Помощь]: /speaker [URL]");
		foreach(new i : Player)
	    {
	        if(GetPVarType(i, "BoomboxObject"))
	        {
    			if(IsPlayerInRangeOfPoint(playerid, 40.0, GetPVarFloat(i, "bposX"), GetPVarFloat(i, "bposY"), GetPVarFloat(i, "bposZ")))
				{
				    SendClientMessage(playerid, COLOR_GREY, "[SH-SS] Рядом где-то уже есть спикер. Поставьте где-нибудь в другом месте.");
				    return 1;
				}
			}
		}

		new Float:x, Float:y, Float:z, Float:a;
	    GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a);
	    SetPVarInt(playerid, "BoomboxObject", CreateDynamicObject(2103, x, y, z, 0.0, 0.0, 0.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
   		format(string, sizeof(string), "{FFFFFF}[SH-SS] Колонку поставил\n{FF0000}куратор %s", name);
		SetPVarInt(playerid, "author", CreateDynamic3DTextLabel(string, 0xFFFFFFFF, x, y, z + 1.0, 20, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
	    SetPVarFloat(playerid, "bposX", x); SetPVarFloat(playerid, "bposY", y); SetPVarFloat(playerid, "bposZ", z);
		SetPVarInt(playerid, "bboxareaid", CreateDynamicSphere(x, y, z, 40.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
	    format(string, sizeof(string), "[SH-SS] Колонка выставлена на вашей позиции.");
	    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    foreach(new i : Player)
		{
			if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
			{
				PlayAudioStreamForPlayer(i, params, GetPVarFloat(playerid, "bposX"), GetPVarFloat(playerid, "bposY"), GetPVarFloat(playerid, "bposZ"), 30.0, 1);
			}
    	}
		SetPVarString(playerid, "BoomboxURL", params);
	}
	else
	{
	    DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
	    DestroyDynamic3DTextLabel(GetPVarInt(playerid, "author"));
	    DeletePVar(playerid, "BoomboxObject"); DeletePVar(playerid, "BoomboxURL");
	    DeletePVar(playerid, "bposX"); DeletePVar(playerid, "bposY"); DeletePVar(playerid, "bposZ");
	    if(GetPVarType(playerid, "bboxareaid"))
	    {
	        foreach(new i : Player)
	        {
	            if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
	            {
	                StopAudioStreamForPlayer(i);
				}
			}
	        DeletePVar(playerid, "bboxareaid");
		}
		SendClientMessage(playerid, COLOR_LIGHTBLUE, "[SH-SS] Спикер убран.");
	}
	return 1;
}

CMD:setmusic(playerid, params[])
{
    new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[GrandProject] Для доступа к данной команде нужен клиренс RCON уровня.");
	if(!GetPVarType(playerid, "BoomboxObject")) return SendClientMessage(playerid, COLOR_GREY, "[SH-SS] У Вас нет спикера.");
    if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "[SH-SS][Помощь]: /setmusic [URL]");
    SendClientMessage(playerid, COLOR_GREY, "[SH-SS] Музыка успешно изменена.");
    foreach(new i : Player)
	{
		if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
		{
			PlayAudioStreamForPlayer(i, params, GetPVarFloat(playerid, "bposX"), GetPVarFloat(playerid, "bposY"), GetPVarFloat(playerid, "bposZ"), 30.0, 1);
		}
    }
	SetPVarString(playerid, "BoomboxURL", params);
	return 1;
}

public OnPlayerEnterDynamicArea(playerid, areaid)
{
	foreach(new i : Player)
	{
	    if(GetPVarType(i, "bboxareaid"))
	    {
	        new station[256];
	        GetPVarString(i, "BoomboxURL", station, sizeof(station));
	        if(areaid == GetPVarInt(i, "bboxareaid"))
	        {
	            PlayAudioStreamForPlayer(playerid, station, GetPVarFloat(i, "bposX"), GetPVarFloat(i, "bposY"), GetPVarFloat(i, "bposZ"), 30.0, 1);
				return 1;
	        }
	    }
	}
	return 1;
}

public OnPlayerLeaveDynamicArea(playerid, areaid)
{
    foreach(new i : Player)
	{
	    if(GetPVarType(i, "bboxareaid"))
	    {
	        if(areaid == GetPVarInt(i, "bboxareaid"))
	        {
	            StopAudioStreamForPlayer(playerid);
				return 1;
	        }
	    }
	}
	return 1;
}
What's the problem? Thanks for help.
Reply
#2

Show us the lines, not your entire code.
Reply
#3

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
Show us the lines, not your entire code.
Problem with tag mismatch is with 3d text, but main problem is audio, not text.

Line 29: DestroyDynamic3DTextLabel(GetPVarInt(playerid, "author"));

Line 69: SetPVarInt(playerid, "author", CreateDynamic3DTextLabel(string, 0xFFFFFFFF, x, y, z + 1.0, 20, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));

Line 86: DestroyDynamic3DTextLabel(GetPVarInt(playerid, "author"));
Reply
#4

DestroyDynamic3DTextLabel require a integer with the tag
PHP код:
Text3D 
. GetPVarInt only gives a integer without any tags.
If you know what your PVar have, you can do that :
PHP код:
DestroyDynamic3DTextLabel(Text3D:GetPVarInt(playerid"author")); 
This is the same thing but we de-tag the value get by CreateDynamic3DTextLabel
PHP код:
SetPVarInt(playerid"author"_:CreateDynamic3DTextLabel(string0xFFFFFFFFxy1.020INVALID_PLAYER_IDINVALID_VEHICLE_ID0, .worldid GetPlayerVirtualWorld(playerid), .interiorid GetPlayerInterior(playerid))); 
You really should read https://sampwiki.blast.hk/wiki/Scripting:tags
Reply
#5

Thank you very much, problem with 3D Text is gone, but problem that music won't play persists. Any ideas?
Reply
#6

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)