Массив со строками

Primo

типа серьёзный тип
Сообщения
1,532
Реакции
759
Больная тема, но всё же. Не могу разобраться.
Имеется массив строк. Через FormatEx получается строка из массива. Проблема в том, что получает не целую строку, а букву скорее.
Чтобы было понятнее:
Через FormatEx в функцию AddFileToDownloadsTable текст, т.е., фактически, набор букв :D
Заходишь на сервер, должно загрузить, к примеру sounds/vround/beentohell.mp3, а загружает sounds/vround/eentohell.mp3, потом пытается загрузить entohell, потом ntohell и т.д.
Что не так?
PHP:
#include <sourcemod>
#include <dpinfo>
#include <sdktools>
#include <emitsoundany>

new Sounds = 26; //Количество треков
new const String:SoundF[] = //Название файлов треков
{
	"beentohell",
	"calypso",
	"extinction",
	"henniegath",
	"higher",
	"landline",
	"mambo",
	"mechalove",
	"mryeah",
	"mywinona",
	"something",
	"parasite",
	"theonly",
	"thesparpestlives",
	"thriftshop",
	"turnitup",
	"undead",
	"warofchange",
	"whore",
	"witchcraft",
	"apologize",
	"anthem",
	"immatry",
	"getfree",
	"painkiller",
	"shook",
}

new String:SoundName[] = //Названия треков
{
	"Hollywood Undead - Been To Hell",
	"Blonde Acid Cult – Calypso",
	"Thousand Foot Krutch - E For Extinction",
	"Kraddy - Henniegath",
	"Just Blaze and Baauer – Higher",
	"A-Trak ft. GTA - Landline",
	"Tropkillaz – Mambo",
	"Hadouken! - Mecha Love",
	"Mr. Yeah! – Get Ya Hands Up",
	"Fall Out Boy – Shes My Winona",
	"Hadouken! - Something Very Bad",
	"Hadouken! - Parasite",
	"Static-X - The Only",
	"My Chemical Romance - The Sharpest Lives",
	"Macklemore - Thrift Shop (Remix)",
	"Yellow Claw – DJ Turn It Up",
	"Hollywood Undead - Undead",
	"Thousand Foot Krutch - War of Change",
	"Papa Roach - Hollywood Whore",
	"Pendulum - Witchcraft",
	"Hollywood Undead - Apologize",
	"Kraddy - Bomb Anthem",
	"Skrillex - Imma Try It Out",
	"Major Lazer – Get Free ft. Amber (What So Not Remix)",
	"Freestylers feat. Pendulum – Painkiller",
	"Thousand Foot Krutch - Shook",	
}

public Plugin:myinfo = 
{ 
    name = "dP_EndSound", 
    author = "Primo", 
    description = "Playing sounds on end round.", 
    version = "1.1", 
} 

public OnPluginStart() 
{
	HookEvent("round_end", RoundEnd);
}

public OnMapStart()
{
	for(new i; i<=Sounds; i++)
	{
		new String:Sound[256];
		FormatEx(Sound, sizeof(Sound), "sound/vround/%s.mp3", SoundF[i]);
		AddFileToDownloadsTable(Sound);
		FormatEx(Sound, sizeof(Sound), "vround/%s.mp3", SoundF[i]);
		PrecacheSoundAny(Sound);
	}
}

public RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) 
{
	new i = GetRandomInt(0, Sounds-1); 
	new String:Sound[256];
	FormatEx(Sound, sizeof(Sound), "vround/%s.mp3", SoundF[i]);
	EmitSoundToAllAny(Sound);
	PrintToChatAll("Играет x01\x04 %s", SoundName[i]);
}
 

R1KO

fuck society
Сообщения
9,457
Реакции
7,786
  • Команда форума
  • #2
Primo,
Как у тебя:
PHP:
new const String:SoundF[] = //Название файлов треков
...
new String:SoundName[] = //Названия треков
Как должно быть:
PHP:
new const String:SoundF[][] = //Название файлов треков
...
new const String:SoundName[][] = //Названия треков
Не указал размер строки.

PHP:
#include <sourcemod> 
#include <dpinfo> 
#include <sdktools> 
#include <emitsoundany> 

new const String:SoundF[][] = //Название файлов треков 
{ 
	"beentohell", 
	"calypso", 
	"extinction", 
	"henniegath", 
	"higher", 
	"landline", 
	"mambo", 
	"mechalove", 
	"mryeah", 
	"mywinona", 
	"something", 
	"parasite", 
	"theonly", 
	"thesparpestlives", 
	"thriftshop", 
	"turnitup", 
	"undead", 
	"warofchange", 
	"whore", 
	"witchcraft", 
	"apologize", 
	"anthem", 
	"immatry", 
	"getfree", 
	"painkiller", 
	"shook", 
} 

new String:SoundName[][] = //Названия треков 
{ 
	"Hollywood Undead - Been To Hell", 
	"Blonde Acid Cult – Calypso", 
	"Thousand Foot Krutch - E For Extinction", 
	"Kraddy - Henniegath", 
	"Just Blaze and Baauer – Higher", 
	"A-Trak ft. GTA - Landline", 
	"Tropkillaz – Mambo", 
	"Hadouken! - Mecha Love", 
	"Mr. Yeah! – Get Ya Hands Up", 
	"Fall Out Boy – Shes My Winona", 
	"Hadouken! - Something Very Bad", 
	"Hadouken! - Parasite", 
	"Static-X - The Only", 
	"My Chemical Romance - The Sharpest Lives", 
	"Macklemore - Thrift Shop (Remix)", 
	"Yellow Claw – DJ Turn It Up", 
	"Hollywood Undead - Undead", 
	"Thousand Foot Krutch - War of Change", 
	"Papa Roach - Hollywood Whore", 
	"Pendulum - Witchcraft", 
	"Hollywood Undead - Apologize", 
	"Kraddy - Bomb Anthem", 
	"Skrillex - Imma Try It Out", 
	"Major Lazer – Get Free ft. Amber (What So Not Remix)", 
	"Freestylers feat. Pendulum – Painkiller", 
	"Thousand Foot Krutch - Shook",     
} 

public Plugin:myinfo =  
{  
	name = "dP_EndSound",  
	author = "Primo",  
	description = "Playing sounds on end round.",  
	version = "1.1",  
}  

public OnPluginStart()  
{ 
	HookEvent("round_end", RoundEnd); 
} 

public OnMapStart() 
{ 
	decl String:Sound[256]; 
	
	for(new i, iSize = sizeof(SoundF); i < iSize; ++i) 
	{ 
		FormatEx(Sound, sizeof(Sound), "sound/vround/%s.mp3", SoundF[i]); 
		if(FileExists(Sound))
		{
			AddFileToDownloadsTable(Sound); 
			FormatEx(Sound, sizeof(Sound), "vround/%s.mp3", SoundF[i]); 
			PrecacheSoundAny(Sound);
		}
	} 
} 

public RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)  
{ 
	new i = GetRandomInt(0, sizeof(SoundF)-1);  
	decl String:Sound[256]; 
	FormatEx(Sound, sizeof(Sound), "vround/%s.mp3", SoundF[i]); 
	EmitSoundToAllAny(Sound); 
	PrintToChatAll("Играет x01\x04 %s", SoundName[i]); 
}
 

Primo

типа серьёзный тип
Сообщения
1,532
Реакции
759
Разобрался. Спасибо
 
Последнее редактирование:
Сверху Снизу